Compare commits
3 Commits
4e3977edd2
...
77d728a153
Author | SHA1 | Date |
---|---|---|
vilmibm | 77d728a153 | |
vilmibm | 2385446e74 | |
vilmibm | 5220d9bfad |
|
@ -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
|
||||||
|
|
|
@ -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')
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue