Commit e97e204a authored by Gerard Gascón's avatar Gerard Gascón
Browse files

fix: profanity detector

parent 0dc6a348
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
import json
import random

import profanity.templatetags.profanity
from django.db import IntegrityError
from django.http import HttpResponse, Http404

@@ -15,6 +16,14 @@ def add(request, origin, name, color, shirt, hat, decor):
    hat = int(hat.strip())
    decor = int(decor.strip())

    if profanity.templatetags.profanity.is_profane(name):
        print("profanity detected")
        return HttpResponse("profanity detected")

    if profanity.templatetags.profanity.is_profane(origin):
        print("profanity detected")
        return HttpResponse("profanity detected")

    try:
        dragon = Dragon.objects.create(origin=origin, name=name, color=color, shirt=shirt, hat=hat, decor=decor)
        print(f'Received dragon ({dragon})')
+2 −1
Original line number Diff line number Diff line
@@ -46,7 +46,8 @@ INSTALLED_APPS = [
    'django.contrib.messages',
    'django.contrib.staticfiles',

    'server'
    'server',
    'profanity'
]

MIDDLEWARE = [