<commit_before>from django.http import HttpResponse, HttpResponseBadRequest  # JsonResponse
from django.views.decorators.csrf import csrf_exempt
from django.conf import settings
from bellman import Bellman
# Create your views here.


def check_token_safe(token):
    return token == settings.SLACK_TOKEN


@csrf_exempt
def announce(request):
    print "---------------------------------------"
    # default empty text field will be ignored by slack

    # security check
    if request.method == 'POST' and check_token_safe(request.POST['token']):

        # Checker statements (to be deleted)
        print 'POST from northhq slack'
        print request.POST
        args = request.POST['text'].split()
        print 'args:', args
        num_of_args = len(args)
        print 'num_of_args:', num_of_args

        # check that POST has the correct form?

        app = Bellman(
            text=request.POST['text'],
            user_name=request.POST['user_name'],
            user_id=request.POST['user_id'])

        app.execute()

        return HttpResponse(app.get_response())
    return HttpResponseBadRequest()<commit_msg>Added check statement to avoid print statements in view<commit_after>from django.http import HttpResponse, HttpResponseBadRequest  # JsonResponse
from django.views.decorators.csrf import csrf_exempt
from django.conf import settings
from bellman import Bellman
# Create your views here.


def check_token_safe(token):
    return token == settings.SLACK_TOKEN


@csrf_exempt
def announce(request):
    if settings.DEBUG:
        print "---------------------------------------"
    # default empty text field will be ignored by slack

    # security check
    if request.method == 'POST' and check_token_safe(request.POST['token']):

        if settings.DEBUG:
            print 'POST from northhq slack'
            print request.POST
            args = request.POST['text'].split()
            print 'args:', args
            num_of_args = len(args)
            print 'num_of_args:', num_of_args
            print "---------------------------------------"

        # check that POST has the correct form?

        app = Bellman(
            text=request.POST['text'],
            user_name=request.POST['user_name'],
            user_id=request.POST['user_id'])

        app.execute()

        return HttpResponse(app.get_response())
    if settings.DEBUG:
        print "---------------------------------------"
    return HttpResponseBadRequest()
{'fraction_non_alphanumeric': 0.14637096774193548, 'fraction_numerical': 0.0, 'mean_word_length': 2.205426356589147, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6767885', 'n_tokens_mistral': 655, 'n_tokens_neox': 636, 'n_words': 182}