[damned-lies] Updated MIDDLEWARE_CLASSES, use new get_current_site
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Updated MIDDLEWARE_CLASSES, use new get_current_site
- Date: Sat, 26 Sep 2015 14:24:02 +0000 (UTC)
commit d24e180ac459c94d026d764b06531f7508847c29
Author: Claude Paroz <claude 2xlibre net>
Date: Sat Sep 19 11:48:13 2015 +0200
Updated MIDDLEWARE_CLASSES, use new get_current_site
common/views.py | 2 +-
damnedlies/settings.py | 4 +++-
people/forms.py | 6 +++---
people/views.py | 4 ++--
4 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/common/views.py b/common/views.py
index 19f6763..6846f46 100644
--- a/common/views.py
+++ b/common/views.py
@@ -101,7 +101,7 @@ def site_register(request):
if request.method == 'POST':
form = RegistrationForm(data = request.POST)
if form.is_valid():
- new_user = form.save()
+ new_user = form.save(request)
return HttpResponseRedirect(reverse('register_success'))
else:
form = RegistrationForm()
diff --git a/damnedlies/settings.py b/damnedlies/settings.py
index e0f27a1..6f62814 100644
--- a/damnedlies/settings.py
+++ b/damnedlies/settings.py
@@ -113,7 +113,9 @@ MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
+ 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ATOMIC_REQUESTS = True
@@ -151,7 +153,7 @@ LOGIN_REDIRECT_URL = '/'
ADMIN_GROUP = ''
try:
- from local_settings import *
+ from .local_settings import *
except ImportError:
pass
diff --git a/people/forms.py b/people/forms.py
index 0684fc9..5ca6f8e 100644
--- a/people/forms.py
+++ b/people/forms.py
@@ -3,7 +3,7 @@ import hashlib, random
from django import forms
from django.conf import settings
-from django.contrib.sites.models import Site
+from django.contrib.sites.shortcuts import get_current_site
from django.core.urlresolvers import reverse
from django.utils.encoding import force_bytes
from django.utils.translation import ugettext_lazy, ugettext as _
@@ -57,7 +57,7 @@ class RegistrationForm(forms.Form):
raise forms.ValidationError(_(u'The passwords do not match'))
return cleaned_data
- def save(self):
+ def save(self, request):
""" Create the user """
username = self.cleaned_data['username']
email = self.cleaned_data['email']
@@ -77,7 +77,7 @@ class RegistrationForm(forms.Form):
new_user.save()
# Send activation email
from django.core.mail import send_mail
- current_site = Site.objects.get_current()
+ current_site = get_current_site(request)
subject = settings.EMAIL_SUBJECT_PREFIX + _(u'Account activation')
message = _(u"This is a confirmation that your registration on %s succeeded. To activate your
account, please click on the link below or copy and paste it in a browser.") % current_site.name
message += "\n\nhttps://%s%s\n\n" % (current_site.domain, str(reverse("register_activation",
kwargs={'key': activation_key})))
diff --git a/people/views.py b/people/views.py
index 88bf7ae..e5cef73 100644
--- a/people/views.py
+++ b/people/views.py
@@ -24,7 +24,7 @@ from django.conf.locale import LANG_INFO
from django.contrib.auth.decorators import login_required
from django.contrib.auth.forms import PasswordChangeForm
from django.contrib import messages
-from django.contrib.sites.models import Site
+from django.contrib.sites.shortcuts import get_current_site
from django.core import urlresolvers
from django.db import IntegrityError
from django.http import HttpResponseRedirect
@@ -100,7 +100,7 @@ def person_team_join(request):
messages.success(request, _("You have successfully joined the team '%s'.") %
team.get_description())
team.send_mail_to_coordinator(subject=ugettext_lazy("A new person joined your team"),
message=ugettext_lazy("%(name)s has just joined your
translation team on %(site)s"),
- messagekw = {'name': person.name, 'site':
Site.objects.get_current()})
+ messagekw = {'name': person.name, 'site':
get_current_site(request)})
except IntegrityError:
messages.info(request, _("You are already member of this team."))
else:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]