Skip to content

Commit

Permalink
i18n and activation improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
samluescher committed Aug 17, 2010
1 parent 83b2ead commit 1873279
Show file tree
Hide file tree
Showing 12 changed files with 364 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% load i18n %}{% blocktrans with site.name as site_name %}Activation required for {{ site_name }}{% endblocktrans %}

This file was deleted.

17 changes: 13 additions & 4 deletions user_profiles/activation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,26 @@ def send_activation_link_to_user(user, activation_code=None):
activation_code = ActivationCode(user=user)
activation_code.save()

site = Site.objects.get_current()
try:
site = Site.objects.get_current()
except Site.DoesNotExist:
site = Site(domain='<unknown>', name='<unknown>')
domain = site.domain
profile = user.get_profile()
if profile and profile.__unicode__():
recipient = profile
else:
recipient = user
context_dict = {
'url': qualified_url(reverse('user_profiles_activation_activate', args=[activation_code.key]), site),
'form_url': qualified_url(reverse('user_profiles_activation_form'), site),
'site_url': qualified_url('', site),
'site': site,
'key': activation_code.key,
'user': user,
'recipient': user.get_profile() or user,
'recipient': recipient,
'profile': profile,
}
subject = get_template('activation/email/activation_subject.txt').render(Context(context_dict)).replace('\n', '')
message = get_template('activation/email/activation.txt').render(Context(context_dict))
subject = get_template('activation/email/activation_request.subject.txt').render(Context(context_dict, autoescape=False)).replace('\n', '')
message = get_template('activation/email/activation_request.txt').render(Context(context_dict, autoescape=False))
send_mail(subject, message, None, [user.email], fail_silently=False)
7 changes: 4 additions & 3 deletions user_profiles/forms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from user_profiles.utils import get_user_profile_model
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
Expand All @@ -19,7 +20,7 @@ def save(self, commit=True):
return user

class EmailAsUsernameSignupForm(SignupForm):
email = forms.EmailField(required=True, max_length=30, label=_('E-mail address'), help_text=_('Your e-mail address is your username. You need to provide a valid address in order to use your account.'))
email = forms.EmailField(required=True, max_length=30, label=_('E-mail address'), help_text=_('Your e-mail address is your username. You need to provide a valid address to log in.'))

class Meta:
model = User
Expand All @@ -30,8 +31,8 @@ def __init__(self, *args, **kwargs):
del(self.fields['username'])

def clean_email(self):
if User.objects.filter(email=self.cleaned_data['email']).exists():
raise forms.ValidationError('A user with this e-mail address already exists.')
if User.objects.filter(Q(email=self.cleaned_data['email']) | Q(username=self.cleaned_data['email'])).exists():
raise forms.ValidationError(_('A user with this e-mail address already exists.'))
return self.cleaned_data['email']

def save(self, commit=True):
Expand Down
Binary file added user_profiles/locale/de/LC_MESSAGES/django.mo
Binary file not shown.
295 changes: 295 additions & 0 deletions user_profiles/locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,295 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-08-17 18:02+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"

#: forms.py:23
msgid "E-mail address"
msgstr "E-Mail-Adresse"

#: forms.py:23
msgid ""
"Your e-mail address is your username. You need to provide a valid address in "
"order to use your account."
msgstr ""
"Die E-Mail-Adresse ist der Benutzername. Zur Anmeldung ist eine gültige "
"Adresse ist notwendig."

#: forms.py:35
msgid "A user with this e-mail address already exists."
msgstr "Ein Benutzer mit dieser E-Mail-Adresse existiert bereits."

#: models.py:20
msgid "user profile"
msgstr "Benutzerprofil"

#: models.py:21
msgid "user profiles"
msgstr "Benutzerprofile"

#: views.py:33
msgid "Signup was successful. You can now proceed to log in."
msgstr "Die Registration war erfolgreich. Sie können sich nun anmelden."

#: views.py:35
msgid ""
"Signup was successful. Activation ist required before you can proceed to log "
"in."
msgstr ""
"Die Registration war erfolgreich. Vor der Anmeldung ist eine Aktivierung "
"notwendig."

#: views.py:78
msgid "Your changes were saved."
msgstr "Die Änderungen wurden gespeichert."

#: views.py:84
msgid "Please correct the errors below."
msgstr "Bitte die untenstehenden Fehler korrigieren."

#: activation/views.py:16
msgid "Activation code"
msgstr "Aktivierungscode"

#: activation/views.py:33
msgid "This activation code has already been used."
msgstr "Dieser Aktivierungscode wurde bereits benutzt."

#: activation/views.py:37
msgid "Thank you, activation was successful. You can now proceed to log in."
msgstr ""
"Vielen Dank, die Aktivierung war erfolgreich. Sie können sich nun anmelden."

#: activation/views.py:39
msgid "Thank you, activation was successful."
msgstr "Vielen Dank, die Aktivierung war erfolgreich."

#: activation/views.py:46
msgid "This is not a valid activation code."
msgstr "Dies ist kein gültiger Aktivierungscode."

#: activation/views.py:58
#, python-format
msgid ""
"An activation code has been sent to the email address %(email)s. Please "
"click the link in the email in order to activate."
msgstr ""
"Ein Aktivierungscode wurde an die Adresse %(email)s geschickt. Bitte den in "
"der Nachricht enthaltenen Link zur Aktivierung anklicken."

#: activation/templates/activation/form.html:11
msgid "Activate"
msgstr "Aktivieren"

#: templates/user_profiles/logged_out.html:4
#: templates/user_profiles/password_change_done.html:4
#: templates/user_profiles/password_change_form.html:5
#: templates/user_profiles/password_reset_complete.html:4
#: templates/user_profiles/password_reset_confirm.html:4
#: templates/user_profiles/password_reset_done.html:4
#: templates/user_profiles/password_reset_form.html:4
msgid "Home"
msgstr "Start"

#: templates/user_profiles/logged_out.html:8
msgid "Thanks for spending some quality time with the Web site today."
msgstr ""

#: templates/user_profiles/logged_out.html:10
msgid "Log in again"
msgstr "Zur Anmeldung"

#: templates/user_profiles/login.html:4 templates/user_profiles/login.html:5
#: templates/user_profiles/login.html:24
#: templates/user_profiles/password_reset_complete.html:11
msgid "Log in"
msgstr "Anmelden"

#: templates/user_profiles/login.html:9
msgid "Your username and password didn't match. Please try again."
msgstr ""
"Diese Kombination von Benutzername und Passwort ist ungültig. Bitte erneut "
"versuchen."

#: templates/user_profiles/login.html:29
#: templates/user_profiles/signup.html:11
msgid "Sign up"
msgstr "Registrieren"

#: templates/user_profiles/login.html:30
msgid "Forgot your password?"
msgstr "Passwort vergessen?"

#: templates/user_profiles/password_change_done.html:3
#: templates/user_profiles/password_change_form.html:4
msgid "Documentation"
msgstr ""

#: templates/user_profiles/password_change_done.html:3
#: templates/user_profiles/password_change_form.html:4
msgid "Change password"
msgstr ""

#: templates/user_profiles/password_change_done.html:3
#: templates/user_profiles/password_change_form.html:4
msgid "Log out"
msgstr ""

#: templates/user_profiles/password_change_done.html:4
#: templates/user_profiles/password_change_form.html:5
#: templates/user_profiles/password_change_form.html:7
#: templates/user_profiles/password_change_form.html:8
msgid "Password change"
msgstr ""

#: templates/user_profiles/password_change_done.html:6
#: templates/user_profiles/password_change_done.html:7
msgid "Password change successful"
msgstr ""

#: templates/user_profiles/password_change_done.html:10
msgid "Your password was changed."
msgstr ""

#: templates/user_profiles/password_change_form.html:15
#: templates/user_profiles/password_reset_confirm.html:20
msgid "Change my password"
msgstr ""

#: templates/user_profiles/password_reset_complete.html:4
#: templates/user_profiles/password_reset_confirm.html:6
#: templates/user_profiles/password_reset_done.html:4
#: templates/user_profiles/password_reset_form.html:4
#: templates/user_profiles/password_reset_form.html:6
#: templates/user_profiles/password_reset_form.html:7
msgid "Password reset"
msgstr ""

#: templates/user_profiles/password_reset_complete.html:6
#: templates/user_profiles/password_reset_complete.html:7
msgid "Password reset complete"
msgstr ""

#: templates/user_profiles/password_reset_complete.html:10
msgid "Your password has been set. You may go ahead and log in now."
msgstr ""

#: templates/user_profiles/password_reset_confirm.html:4
msgid "Password reset confirmation"
msgstr ""

#: templates/user_profiles/password_reset_confirm.html:7
msgid "Enter new password"
msgstr ""

#: templates/user_profiles/password_reset_confirm.html:13
msgid ""
"Please enter your new password twice so we can verify you typed it in "
"correctly."
msgstr ""

#: templates/user_profiles/password_reset_confirm.html:17
msgid "New password:"
msgstr ""

#: templates/user_profiles/password_reset_confirm.html:19
msgid "Confirm password:"
msgstr ""

#: templates/user_profiles/password_reset_confirm.html:25
msgid "Password reset unsuccessful"
msgstr ""

#: templates/user_profiles/password_reset_confirm.html:27
msgid ""
"The password reset link was invalid, possibly because it has already been "
"used. Please request a new password reset."
msgstr ""

#: templates/user_profiles/password_reset_done.html:6
#: templates/user_profiles/password_reset_done.html:7
msgid "Password reset successful"
msgstr ""

#: templates/user_profiles/password_reset_done.html:11
msgid ""
"We've e-mailed you instructions for setting your password to the e-mail "
"address you submitted. You should be receiving it shortly."
msgstr ""

#: templates/user_profiles/password_reset_email.html:2
msgid "You're receiving this e-mail because you requested a password reset"
msgstr ""

#: templates/user_profiles/password_reset_email.html:3
#, python-format
msgid "for your user account at %(site_name)s"
msgstr ""

#: templates/user_profiles/password_reset_email.html:5
msgid "Please go to the following page and choose a new password:"
msgstr ""

#: templates/user_profiles/password_reset_email.html:9
msgid "Your username, in case you've forgotten:"
msgstr ""

#: templates/user_profiles/password_reset_email.html:11
msgid "Thanks for using our site!"
msgstr ""

#: templates/user_profiles/password_reset_email.html:13
#, python-format
msgid "The %(site_name)s team"
msgstr ""

#: templates/user_profiles/password_reset_form.html:10
msgid ""
"Forgotten your password? Enter your e-mail address below, and we'll e-mail "
"instructions for setting a new one."
msgstr ""

#: templates/user_profiles/password_reset_form.html:14
msgid "E-mail address:"
msgstr ""

#: templates/user_profiles/password_reset_form.html:14
msgid "Reset my password"
msgstr ""

#: templates/user_profiles/profile/change.html:11
msgid "Save"
msgstr ""

#: templatetags/user_profile_tags.py:7
#, python-format
msgid "Dear Mrs %(last_name)s,"
msgstr "Sehr geehrte Frau %(last_name)s"

#: templatetags/user_profile_tags.py:9
#, python-format
msgid "Dear Ms %(last_name)s,"
msgstr "Sehr geehrte Frau %(last_name)s"

#: templatetags/user_profile_tags.py:11
#, python-format
msgid "Dear %(last_name)s family,"
msgstr "Sehr geehrte Familie %(last_name)s"

#: templatetags/user_profile_tags.py:13
#, python-format
msgid "Dear Mr %(last_name)s,"
msgstr "Sehr geehrter Herr %(last_name)s"
24 changes: 24 additions & 0 deletions user_profiles/models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
# coding=utf-8
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import User
from django.db.models.signals import post_save

User._meta.get_field('username').max_length=75

def post_save_create_profile_for_new_user(sender, **kwargs):
from user_profiles.utils import create_profile_for_new_user
if kwargs['created'] and sender == User:
create_profile_for_new_user(kwargs['instance'])

post_save.connect(post_save_create_profile_for_new_user)

class UserProfileBase(models.Model):

class Meta:
abstract = True
verbose_name = _('user profile')
verbose_name_plural = _('user profiles')

def __unicode__(self):
if hasattr(self, 'name') and self.name:
return self.name
elif hasattr(self, 'first_name') and hasattr(self, 'last_name') and self.first_name and self.last_name:
return '%(first_name)s %(last_name)s' % {'first_name': self.first_name, 'last_name': self.last_name}
else:
if '@' in self.user.username:
return self.user.username.split('@')[0]+u'@…'
else:
return self.user.username

Empty file.
Loading

0 comments on commit 1873279

Please sign in to comment.