Compare commits

..

3 Commits

Author SHA1 Message Date
vilmibm 77d728a153 bootleg anti-spam measure 2019-12-16 22:22:01 +00:00
vilmibm 2385446e74 increase timeout to help with bulk add of users 2019-12-16 22:21:44 +00:00
vilmibm 5220d9bfad atomic user creation/notification 2019-10-11 22:53:39 +00:00
3 changed files with 14 additions and 4 deletions

View File

@ -9,4 +9,4 @@ VENV=/town/venvs/ttadmin
source $VENV/bin/activate source $VENV/bin/activate
export DJANGO_SETTINGS_MODULE=settings_live export DJANGO_SETTINGS_MODULE=settings_live
cd $APP_ROOT cd $APP_ROOT
gunicorn -b0.0.0.0:$PORT ttadmin.wsgi gunicorn -t120 -b0.0.0.0:$PORT ttadmin.wsgi

View File

@ -1,3 +1,5 @@
import re
from django.shortcuts import redirect from django.shortcuts import redirect
from django.views.generic import TemplateView from django.views.generic import TemplateView
from django.views.generic.edit import FormView from django.views.generic.edit import FormView
@ -5,6 +7,8 @@ from django.views.generic.edit import FormView
from .forms import GuestbookForm from .forms import GuestbookForm
from .models import GuestbookMessage from .models import GuestbookMessage
SUSPICIOUS_RE = re.compile(r'https?://')
class GuestbookView(FormView): class GuestbookView(FormView):
form_class = GuestbookForm form_class = GuestbookForm
@ -17,5 +21,7 @@ class GuestbookView(FormView):
def form_valid(self, form): def form_valid(self, form):
del form.cleaned_data['captcha'] del form.cleaned_data['captcha']
if SUSPICIOUS_RE.search(form.cleaned_data['msg']) != None:
return redirect('guestbook:guestbook')
t = GuestbookMessage.objects.create(**form.cleaned_data) t = GuestbookMessage.objects.create(**form.cleaned_data)
return redirect('guestbook:guestbook') return redirect('guestbook:guestbook')

View File

@ -246,9 +246,13 @@ def on_townie_pre_save(sender, instance, **kwargs):
# See if we need to create the user on disk. # See if we need to create the user on disk.
if existing.unreviewed and instance.accepted: if existing.unreviewed and instance.accepted:
logger.info('Creating user {} on disk.'.format(instance.username)) logger.info('Creating user {} on disk.'.format(instance.username))
try:
instance.create_on_disk() instance.create_on_disk()
instance.send_welcome_email()
instance.write_authorized_keys() instance.write_authorized_keys()
except Exception as e:
logger.error('Failed syncing user {} to disk: {}'.format(instance.username, e)
else:
instance.send_welcome_email()
return return
else: else:
# This user state transition is currently undefined. In the future, we can check for things # This user state transition is currently undefined. In the future, we can check for things