Browse Source

Require email activation before posting snipts. Effing spammers.

master
Nick Sergeant 6 years ago
parent
commit
68e2d4dd8b
7 changed files with 20 additions and 11 deletions
  1. +1
    -1
      settings.py
  2. +5
    -1
      snipts/templates/snipts/list.html
  3. +0
    -3
      snipts/utils.py
  4. +6
    -4
      templates/add-snipt.html
  5. +4
    -0
      templates/registration/activation_email.txt
  6. +3
    -1
      urls.py
  7. +1
    -1
      utils/views.py

+ 1
- 1
settings.py View File

@@ -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'


+ 5
- 1
snipts/templates/snipts/list.html View File

@@ -26,7 +26,11 @@
{% include "snipts/snipt-list.html" %}
{% empty %}
<div class="empty-snipts">
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 %}
</div>
{% endfor %}
{% paginate %}


+ 0
- 3
snipts/utils.py View File

@@ -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)


+ 6
- 4
templates/add-snipt.html View File

@@ -1,8 +1,10 @@
<li class="add-snipt">
<button class="btn btn-info btn-large" id="add-snipt">
Add {% if request.user.username == 'blog' %}Post{% else %}Snipt{% endif %}
<i class="icon-search icon-plus icon-white"></i>
</button>
{% if request.user.is_active %}
<button class="btn btn-info btn-large" id="add-snipt">
Add {% if request.user.username == 'blog' %}Post{% else %}Snipt{% endif %}
<i class="icon-search icon-plus icon-white"></i>
</button>
{% endif %}
{% if request.user.profile.has_teams %}
<ul class="add-snipt-teams">
<li>


+ 4
- 0
templates/registration/activation_email.txt View File

@@ -2,6 +2,10 @@ Hey there,

Welcome to Snipt. If you ever have any thoughts or issues with the site whatsoever, please feel free to contact me directly.

To complete your registration, please activate your account here:

https://{{site.domain}}{% url 'registration_activate' activation_key %}

Thanks!

Nick Sergeant


+ 3
- 1
urls.py View File

@@ -3,7 +3,7 @@ import os
from django.conf.urls import include, patterns, url
from django.contrib import admin
from django.http import HttpResponseRedirect
from django.views.generic import TemplateView
from django.views.generic import RedirectView, TemplateView
from snipts.api import (PublicSniptResource,
PublicUserResource, PrivateSniptResource,
PrivateFavoriteResource, PrivateUserProfileResource,
@@ -56,6 +56,8 @@ urlpatterns = \
url(r'^register/$', lambda x: HttpResponseRedirect('/signup/')),
url(r'^signup/$', SniptRegistrationView.as_view(),
name='registration_register'),
url(r'^activate/complete/$', RedirectView.as_view(
url='/login-redirect/')),
url(r'', include('registration.backends.default.urls')),

url(r'^', include('teams.urls')),


+ 1
- 1
utils/views.py View File

@@ -2,7 +2,7 @@ import requests

from django.conf import settings
from django.http import HttpResponse
from registration.backends.default.views import RegistrationView
from registration.backends.default.views import ActivationView, RegistrationView
from utils.forms import SniptRegistrationForm




Loading…
Cancel
Save