fix: profanity detector
This commit is contained in:
parent
0dc6a34832
commit
e97e204a5e
3 changed files with 14 additions and 2 deletions
|
@ -1,5 +1,7 @@
|
|||
asgiref==3.8.1
|
||||
Django==5.1.7
|
||||
django-profanity-filter==0.2.1
|
||||
inflection==0.5.1
|
||||
python-dotenv==1.0.1
|
||||
sqlparse==0.5.3
|
||||
tzdata==2025.2
|
||||
python-dotenv==1.0.1
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
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})')
|
||||
|
|
|
@ -46,7 +46,8 @@ INSTALLED_APPS = [
|
|||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
|
||||
'server'
|
||||
'server',
|
||||
'profanity'
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue