[damned-lies] Replaced the Sites framework by a simple SITE_DOMAIN setting
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Replaced the Sites framework by a simple SITE_DOMAIN setting
- Date: Thu, 28 Sep 2017 16:02:25 +0000 (UTC)
commit 5b7435fe91728deaf6e3b0b97d9ab32342fd210a
Author: Claude Paroz <claude 2xlibre net>
Date: Thu Sep 28 18:01:50 2017 +0200
Replaced the Sites framework by a simple SITE_DOMAIN setting
README | 4 ++--
damnedlies/settings.py | 7 ++-----
people/forms.py | 11 ++++++-----
people/views.py | 9 +++++----
stats/utils.py | 4 +---
teams/forms.py | 10 ++++------
teams/models.py | 3 +--
teams/tests.py | 4 ++--
vertimus/feeds.py | 8 +++-----
vertimus/models.py | 6 ++----
vertimus/tests/tests.py | 2 +-
11 files changed, 29 insertions(+), 39 deletions(-)
---
diff --git a/README b/README
index f9a5767..9492e1c 100644
--- a/README
+++ b/README
@@ -38,8 +38,8 @@ Installation
1 - Create a damnedlies/local_settings.py and overwrite settings to match your
requirements and your configuration layouts. Typical settings to customize
include:
- DATABASES, SECRET_KEY, DEBUG, TEMPLATE_DEBUG, STATIC_SERVE, ADMINS,
- MANAGERS, ADMIN_GROUP, SCRATCHDIR and various EMAIL settings.
+ DATABASES, SECRET_KEY, DEBUG, STATIC_SERVE, ADMINS, ADMIN_GROUP,
+ SITE_DOMAIN, SCRATCHDIR, and various EMAIL settings.
Please refer to Database configuration below for more information.
diff --git a/damnedlies/settings.py b/damnedlies/settings.py
index 79d2fcf..f99b0e3 100644
--- a/damnedlies/settings.py
+++ b/damnedlies/settings.py
@@ -14,8 +14,6 @@ ADMINS = (
('Your Name', 'your_address example org'),
)
-MANAGERS = ADMINS
-
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
@@ -52,8 +50,6 @@ LANGUAGES = list(global_settings.LANGUAGES) + [
('ku', gettext_noop('Kurdish')),
]
-SITE_ID = 1
-
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
@@ -138,7 +134,6 @@ INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
- 'django.contrib.sites',
'django.contrib.admin',
'django.contrib.humanize',
'django.contrib.messages',
@@ -154,6 +149,8 @@ INSTALLED_APPS = (
INTERNAL_IPS=('127.0.0.1',)
+SITE_DOMAIN = 'l10n.gnome.org'
+
LOGIN_REDIRECT_URL = '/'
# Members of this group can edit all team's details and change team coordinatorship
diff --git a/people/forms.py b/people/forms.py
index 22b3e30..fb2b45f 100644
--- a/people/forms.py
+++ b/people/forms.py
@@ -4,7 +4,6 @@ from urllib.request import urlopen
from django import forms
from django.conf import settings
-from django.contrib.sites.shortcuts import get_current_site
from django.core.exceptions import ValidationError
from django.urls import reverse
from django.utils.encoding import force_bytes
@@ -80,10 +79,12 @@ class RegistrationForm(forms.Form):
new_user.is_active = False
new_user.save()
# Send activation email
- current_site = get_current_site(request)
- message = _("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})))
- message += _("Administrators of %s" % current_site.name)
+ message = _("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.") % settings.SITE_DOMAIN
+ message += "\n\nhttps://%s%s\n\n" % (
+ settings.SITE_DOMAIN,
+ str(reverse("register_activation", kwargs={'key': activation_key}))
+ )
+ message += _("Administrators of %s" % settings.SITE_DOMAIN)
send_mail(_('Account activation'), message, to=[email])
return new_user
diff --git a/people/views.py b/people/views.py
index 9a4b79d..780919a 100644
--- a/people/views.py
+++ b/people/views.py
@@ -5,7 +5,6 @@ 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.shortcuts import get_current_site
from django.db import IntegrityError
from django.http import HttpResponseRedirect
from django.shortcuts import render, get_object_or_404
@@ -80,9 +79,11 @@ def person_team_join(request):
try:
new_role.save()
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':
get_current_site(request)})
+ 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': settings.SITE_DOMAIN}
+ )
except IntegrityError:
messages.info(request, _("You are already member of this team."))
else:
diff --git a/stats/utils.py b/stats/utils.py
index f545e1a..9d2e5fe 100644
--- a/stats/utils.py
+++ b/stats/utils.py
@@ -16,7 +16,6 @@ except ImportError:
has_toolkit = False
from django.conf import settings
-from django.contrib.sites.models import Site
from django.core.files.base import File
from django.template.loader import get_template
from django.utils.encoding import force_text
@@ -684,11 +683,10 @@ def compute_md5(full_path):
def notify_list(branch, diff):
"""Send notification about string changes described in diff."""
- current_site = Site.objects.get_current()
template = get_template('freeze-notification.txt')
text = template.render({
'module': '%s.%s' % (branch.module.name, branch.name),
- 'ourweb': current_site.domain,
+ 'ourweb': settings.SITE_DOMAIN,
'potdiff': force_text("\n ".join(diff)),
'commit_log': branch.get_vcs_web_log_url(),
})
diff --git a/teams/forms.py b/teams/forms.py
index c2a4aa4..6f789e2 100644
--- a/teams/forms.py
+++ b/teams/forms.py
@@ -1,6 +1,5 @@
from django import forms
from django.conf import settings
-from django.contrib.sites.shortcuts import get_current_site
from django.utils.translation import ugettext as _
from common.utils import is_site_admin, send_mail
@@ -76,7 +75,6 @@ class EditMemberRoleForm(forms.Form):
yield self[key]
def save(self, request):
- current_site = get_current_site(request)
for key, field in self.fields.items():
form_value = self.cleaned_data[key]
if field.initial != form_value:
@@ -86,9 +84,9 @@ class EditMemberRoleForm(forms.Form):
role.delete()
message = _("You have been removed from the %(team)s team on %(site)s") % {
'team': team,
- 'site': current_site,
+ 'site': settings.SITE_DOMAIN,
}
- message += "\n\n" + _("This is an automatic message sent from %(site)s. Please do not
answer.") % {'site': current_site}
+ message += "\n\n" + _("This is an automatic message sent from %(site)s. Please do not
answer.") % {'site': settings.SITE_DOMAIN}
send_mail(_('Removed from team'), message, to=[role.person.email])
elif form_value == "inactivate":
role.is_active = False
@@ -98,8 +96,8 @@ class EditMemberRoleForm(forms.Form):
role.save()
message = _("Your role in the %(team)s team on %(site)s has been set to “%(role)s”") % {
'team': role.team.description,
- 'site': current_site,
+ 'site': settings.SITE_DOMAIN,
'role': role.get_role_display(),
}
- message += "\n\n" + _("This is an automatic message sent from %(site)s. Please do not
answer.") % {'site': current_site}
+ message += "\n\n" + _("This is an automatic message sent from %(site)s. Please do not
answer.") % {'site': settings.SITE_DOMAIN}
send_mail(_('Role changed'), message, to=[role.person.email])
diff --git a/teams/models.py b/teams/models.py
index 47a4891..8ba1294 100644
--- a/teams/models.py
+++ b/teams/models.py
@@ -1,7 +1,6 @@
from datetime import datetime, timedelta
from django.conf import settings
-from django.contrib.sites.models import Site
from django.db import models
from django.urls import reverse
from django.utils import translation
@@ -180,7 +179,7 @@ class Team(models.Model):
return
with translation.override(self.language_set.first().locale):
message = "%s\n--\n" % (message % messagekw,)
- message += _("This is an automated message sent from %s.") % Site.objects.get_current()
+ message += _("This is an automated message sent from %s.") % settings.SITE_DOMAIN
send_mail(
str(subject), message, to=recipients,
headers={settings.EMAIL_HEADER_NAME: "coordinator-mail"}
diff --git a/teams/tests.py b/teams/tests.py
index af22a94..af9a70c 100644
--- a/teams/tests.py
+++ b/teams/tests.py
@@ -186,7 +186,7 @@ class TeamTest(TeamsAndRolesTests):
self.assertEqual(len(mail.outbox), 1)
self.assertIn('Role changed', mail.outbox[0].subject)
self.assertIn(
- "Your role in the French team on example.com has been set to “Committer”",
+ "Your role in the French team on %s has been set to “Committer”" % settings.SITE_DOMAIN,
mail.outbox[0].body
)
mail.outbox = []
@@ -198,7 +198,7 @@ class TeamTest(TeamsAndRolesTests):
self.assertEqual(len(mail.outbox), 1)
self.assertIn('Removed from team', mail.outbox[0].subject)
self.assertIn(
- "You have been removed from the French team on example.com",
+ "You have been removed from the French team on %s" % settings.SITE_DOMAIN,
mail.outbox[0].body
)
diff --git a/vertimus/feeds.py b/vertimus/feeds.py
index 54074bd..c91eac9 100644
--- a/vertimus/feeds.py
+++ b/vertimus/feeds.py
@@ -1,4 +1,4 @@
-from django.contrib.sites.models import Site
+from django.conf import settings
from django.contrib.syndication.views import Feed, FeedDoesNotExist
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
@@ -16,9 +16,8 @@ class LatestActionsByLanguage(Feed):
return Language.objects.get(locale=locale)
def title(self, obj):
- current_site = Site.objects.get_current()
return _("%(site)s — Workflow actions for the %(lang)s language") % {
- 'site': current_site, 'lang': obj.name }
+ 'site': settings.SITE_DOMAIN, 'lang': obj.name }
def link(self, obj):
if not obj:
@@ -59,9 +58,8 @@ class LatestActionsByTeam(Feed):
return Team.objects.get(name=team_name)
def title(self, obj):
- current_site = Site.objects.get_current()
return _("%(site)s — Workflow actions of the %(lang)s team") % {
- 'site': current_site, 'lang': obj}
+ 'site': settings.SITE_DOMAIN, 'lang': obj}
def link(self, obj):
if not obj:
diff --git a/vertimus/models.py b/vertimus/models.py
index 2e4aa30..106ed94 100644
--- a/vertimus/models.py
+++ b/vertimus/models.py
@@ -3,7 +3,6 @@ import shutil
from datetime import datetime, timedelta
from django.conf import settings
-from django.contrib.sites.models import Site
from django.db import models
from django.db.models import Max
from django.db.models.signals import post_save, pre_delete
@@ -505,8 +504,7 @@ class Action(ActionAbstract):
if not recipient_list:
return
- current_site = Site.objects.get_current()
- url = "https://%s%s" % (current_site.domain, reverse(
+ url = "https://%s%s" % (settings.SITE_DOMAIN, reverse(
'vertimus_by_names',
args = (
state.branch.module.name,
@@ -526,7 +524,7 @@ class Action(ActionAbstract):
}
message += self.comment or ugettext("Without comment")
message += "\n\n" + self.person.name
- message += "\n--\n" + ugettext("This is an automated message sent from %s.") %
current_site.domain
+ message += "\n--\n" + ugettext("This is an automated message sent from %s.") %
settings.SITE_DOMAIN
try:
send_mail(
subject, message, to=recipient_list,
diff --git a/vertimus/tests/tests.py b/vertimus/tests/tests.py
index 2d5f755..98287c3 100644
--- a/vertimus/tests/tests.py
+++ b/vertimus/tests/tests.py
@@ -652,7 +652,7 @@ class VertimusTest(TeamsAndRolesTests):
)
self.assertEqual(
doc.getElementsByTagName('guid')[0].toxml(),
- """<guid>http://example.com/vertimus/gedit/gnome-2-24/po/fr#%d</guid>""" % action.id
+ """<guid>http://testserver/vertimus/gedit/gnome-2-24/po/fr#%d</guid>""" % action.pk
)
response = self.client.get(reverse('team_feed', args=[self.l.team.name]))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]