From 68e2d4dd8bac0aa4629420984ec7fe32b8696a02 Mon Sep 17 00:00:00 2001 From: Nick Sergeant Date: Tue, 10 May 2016 11:35:51 -0400 Subject: [PATCH] Require email activation before posting snipts. Effing spammers. --- settings.py | 2 +- snipts/templates/snipts/list.html | 6 +++++- snipts/utils.py | 3 --- templates/add-snipt.html | 10 ++++++---- templates/registration/activation_email.txt | 4 ++++ urls.py | 4 +++- utils/views.py | 2 +- 7 files changed, 20 insertions(+), 11 deletions(-) diff --git a/settings.py b/settings.py index 6b6eea5..b524cac 100644 --- a/settings.py +++ b/settings.py @@ -29,7 +29,7 @@ if 'DATABASE_URL' in os.environ: } ABSOLUTE_URL_OVERRIDES = {'auth.user': lambda u: "/%s/" % u.username} -ACCOUNT_ACTIVATION_DAYS = 0 +ACCOUNT_ACTIVATION_DAYS = 14 ADMINS = (('Nick Sergeant', 'nick@snipt.net'),) ALLOWED_HOSTS = ['*'] AUTH_PROFILE_MODULE = 'accounts.UserProfile' diff --git a/snipts/templates/snipts/list.html b/snipts/templates/snipts/list.html index 54f5b1f..20f47b0 100644 --- a/snipts/templates/snipts/list.html +++ b/snipts/templates/snipts/list.html @@ -26,7 +26,11 @@ {% include "snipts/snipt-list.html" %} {% empty %}
- No snipts to show here. Sorry! + {% if request.user == user and not request.user.is_active %} + Welcome! Please click the activation link in your email in order to create your first snipt. + {% else %} + No snipts to show here. Sorry! + {% endif %}
{% endfor %} {% paginate %} diff --git a/snipts/utils.py b/snipts/utils.py index 769ea7a..dc3c062 100644 --- a/snipts/utils.py +++ b/snipts/utils.py @@ -22,9 +22,6 @@ def slugify_uniquely(value, model, slugfield="slug"): def activate_user(user, request, **kwargs): - user.is_active = True - user.save() - user = authenticate(username=request.POST['username'], password=request.POST['password1']) login(request, user) diff --git a/templates/add-snipt.html b/templates/add-snipt.html index 882db0f..ea51587 100644 --- a/templates/add-snipt.html +++ b/templates/add-snipt.html @@ -1,8 +1,10 @@
  • - + {% if request.user.is_active %} + + {% endif %} {% if request.user.profile.has_teams %}