Commit 272a22d6 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

Isolate astakos messages in separate module

parent da312ce8
...@@ -41,7 +41,10 @@ from astakos.im.util import get_invitation ...@@ -41,7 +41,10 @@ from astakos.im.util import get_invitation
from astakos.im.functions import (send_verification, send_activation, from astakos.im.functions import (send_verification, send_activation,
send_account_creation_notification, send_account_creation_notification,
send_group_creation_notification, activate) send_group_creation_notification, activate)
from astakos.im.settings import INVITATIONS_ENABLED, MODERATION_ENABLED, SITENAME, RE_USER_EMAIL_PATTERNS from astakos.im.settings import (INVITATIONS_ENABLED, MODERATION_ENABLED,
SITENAME, RE_USER_EMAIL_PATTERNS
)
from astakos.im.messages import as astakos_messages
import logging import logging
import re import re
...@@ -226,28 +229,23 @@ class ActivationResult(object): ...@@ -226,28 +229,23 @@ class ActivationResult(object):
class VerificationSent(ActivationResult): class VerificationSent(ActivationResult):
def __init__(self): def __init__(self):
message = _('Verification sent.') message = _(astakos_messages.VERIFICATION_SENT)
super(VerificationSent, self).__init__(message) super(VerificationSent, self).__init__(message)
class SwitchAccountsVerificationSent(ActivationResult): class SwitchAccountsVerificationSent(ActivationResult):
def __init__(self, email): def __init__(self, email):
message = _('This email is already associated with another \ message = _(astakos_messages.SWITCH_ACCOUNT_LINK_SENT)
local account. To change this account to a shibboleth \
one follow the link in the verification email sent \
to %s. Otherwise just ignore it.' % email)
super(SwitchAccountsVerificationSent, self).__init__(message) super(SwitchAccountsVerificationSent, self).__init__(message)
class NotificationSent(ActivationResult): class NotificationSent(ActivationResult):
def __init__(self): def __init__(self):
message = _('Your request for an account was successfully received and is now pending \ message = _(astakos_messages.NOTIFACATION_SENT)
approval. You will be notified by email in the next few days. Thanks for \
your interest in ~okeanos! The GRNET team.')
super(NotificationSent, self).__init__(message) super(NotificationSent, self).__init__(message)
class RegistationCompleted(ActivationResult): class RegistationCompleted(ActivationResult):
def __init__(self): def __init__(self):
message = _('Registration completed. You can now login.') message = _(astakos_messages.REGISTRATION_COMPLETED)
super(RegistationCompleted, self).__init__(message) super(RegistationCompleted, self).__init__(message)
...@@ -51,6 +51,7 @@ inf = float('inf') ...@@ -51,6 +51,7 @@ inf = float('inf')
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
inf = float('inf')
def call(func_name): def call(func_name):
"""Decorator function for QuotaholderHTTP client calls.""" """Decorator function for QuotaholderHTTP client calls."""
......
...@@ -60,6 +60,8 @@ from astakos.im.functions import send_change_email ...@@ -60,6 +60,8 @@ from astakos.im.functions import send_change_email
from astakos.im.util import reserved_email, get_query from astakos.im.util import reserved_email, get_query
import astakos.im.messages as astakos_messages
import logging import logging
import hashlib import hashlib
import recaptcha.client.captcha as captcha import recaptcha.client.captcha as captcha
...@@ -116,15 +118,15 @@ class LocalUserCreationForm(UserCreationForm): ...@@ -116,15 +118,15 @@ class LocalUserCreationForm(UserCreationForm):
def clean_email(self): def clean_email(self):
email = self.cleaned_data['email'] email = self.cleaned_data['email']
if not email: if not email:
raise forms.ValidationError(_("This field is required")) raise forms.ValidationError(_(astakos_messages.REQUIRED_FIELD))
if reserved_email(email): if reserved_email(email):
raise forms.ValidationError(_("This email is already used")) raise forms.ValidationError(_(astakos_messages.EMAIL_USED))
return email return email
def clean_has_signed_terms(self): def clean_has_signed_terms(self):
has_signed_terms = self.cleaned_data['has_signed_terms'] has_signed_terms = self.cleaned_data['has_signed_terms']
if not has_signed_terms: if not has_signed_terms:
raise forms.ValidationError(_('You have to agree with the terms')) raise forms.ValidationError(_(astakos_messages.SIGN_TERMS))
return has_signed_terms return has_signed_terms
def clean_recaptcha_response_field(self): def clean_recaptcha_response_field(self):
...@@ -142,8 +144,7 @@ class LocalUserCreationForm(UserCreationForm): ...@@ -142,8 +144,7 @@ class LocalUserCreationForm(UserCreationForm):
rrf = self.cleaned_data['recaptcha_response_field'] rrf = self.cleaned_data['recaptcha_response_field']
check = captcha.submit(rcf, rrf, RECAPTCHA_PRIVATE_KEY, self.ip) check = captcha.submit(rcf, rrf, RECAPTCHA_PRIVATE_KEY, self.ip)
if not check.is_valid: if not check.is_valid:
raise forms.ValidationError( raise forms.ValidationError(_(astakos_messages.CAPTCHA_VALIDATION_ERR))
_('You have not entered the correct words'))
def save(self, commit=True): def save(self, commit=True):
""" """
...@@ -222,13 +223,13 @@ class ThirdPartyUserCreationForm(forms.ModelForm): ...@@ -222,13 +223,13 @@ class ThirdPartyUserCreationForm(forms.ModelForm):
def clean_email(self): def clean_email(self):
email = self.cleaned_data['email'] email = self.cleaned_data['email']
if not email: if not email:
raise forms.ValidationError(_("This field is required")) raise forms.ValidationError(_(astakos_messages.REQUIRED_FIELD))
return email return email
def clean_has_signed_terms(self): def clean_has_signed_terms(self):
has_signed_terms = self.cleaned_data['has_signed_terms'] has_signed_terms = self.cleaned_data['has_signed_terms']
if not has_signed_terms: if not has_signed_terms:
raise forms.ValidationError(_('You have to agree with the terms')) raise forms.ValidationError(_(astakos_messages.SIGN_TERMS))
return has_signed_terms return has_signed_terms
def save(self, commit=True): def save(self, commit=True):
...@@ -287,10 +288,9 @@ class ShibbolethUserCreationForm(ThirdPartyUserCreationForm): ...@@ -287,10 +288,9 @@ class ShibbolethUserCreationForm(ThirdPartyUserCreationForm):
email = self.cleaned_data['email'] email = self.cleaned_data['email']
for user in AstakosUser.objects.filter(email=email): for user in AstakosUser.objects.filter(email=email):
if user.provider == 'shibboleth': if user.provider == 'shibboleth':
raise forms.ValidationError(_("This email is already associated with another shibboleth account.")) raise forms.ValidationError(_(astakos_messages.SHIBBOLETH_EMAIL_USED))
elif not user.is_active: elif not user.is_active:
raise forms.ValidationError(_("This email is already associated with an inactive account. \ raise forms.ValidationError(_(astakos_messages.SHIBBOLETH_INACTIVE_ACC))
You need to wait to be activated before being able to switch to a shibboleth account."))
super(ShibbolethUserCreationForm, self).clean_email() super(ShibbolethUserCreationForm, self).clean_email()
return email return email
...@@ -343,13 +343,12 @@ class LoginForm(AuthenticationForm): ...@@ -343,13 +343,12 @@ class LoginForm(AuthenticationForm):
rrf = self.cleaned_data['recaptcha_response_field'] rrf = self.cleaned_data['recaptcha_response_field']
check = captcha.submit(rcf, rrf, RECAPTCHA_PRIVATE_KEY, self.ip) check = captcha.submit(rcf, rrf, RECAPTCHA_PRIVATE_KEY, self.ip)
if not check.is_valid: if not check.is_valid:
raise forms.ValidationError( raise forms.ValidationError(_(astakos_messages.CAPTCHA_VALIDATION_ERR))
_('You have not entered the correct words'))
def clean(self): def clean(self):
super(LoginForm, self).clean() super(LoginForm, self).clean()
if self.user_cache and self.user_cache.provider not in ('local', ''): if self.user_cache and self.user_cache.provider not in ('local', ''):
raise forms.ValidationError(_('Local login is not the current authentication method for this account.')) raise forms.ValidationError(_(astakos_messages.SUSPENDED_LOCAL_ACC))
return self.cleaned_data return self.cleaned_data
...@@ -419,10 +418,9 @@ class ExtendedPasswordResetForm(PasswordResetForm): ...@@ -419,10 +418,9 @@ class ExtendedPasswordResetForm(PasswordResetForm):
try: try:
user = AstakosUser.objects.get(email=email, is_active=True) user = AstakosUser.objects.get(email=email, is_active=True)
if not user.has_usable_password(): if not user.has_usable_password():
raise forms.ValidationError( raise forms.ValidationError(_(astakos_messages.UNUSABLE_PASSWORD))
_("This account has not a usable password."))
except AstakosUser.DoesNotExist: except AstakosUser.DoesNotExist:
raise forms.ValidationError(_('That e-mail address doesn\'t have an associated user account. Are you sure you\'ve registered?')) raise forms.ValidationError(_(astakos_messages.EMAIL_UNKNOWN))
return email return email
def save( def save(
...@@ -460,7 +458,7 @@ class EmailChangeForm(forms.ModelForm): ...@@ -460,7 +458,7 @@ class EmailChangeForm(forms.ModelForm):
def clean_new_email_address(self): def clean_new_email_address(self):
addr = self.cleaned_data['new_email_address'] addr = self.cleaned_data['new_email_address']
if AstakosUser.objects.filter(email__iexact=addr): if AstakosUser.objects.filter(email__iexact=addr):
raise forms.ValidationError(_(u'This email address is already in use. Please supply a different email address.')) raise forms.ValidationError(_(astakos_messages.EMAIL_USED))
return addr return addr
def save(self, email_template_name, request, commit=True): def save(self, email_template_name, request, commit=True):
...@@ -485,7 +483,7 @@ class SignApprovalTermsForm(forms.ModelForm): ...@@ -485,7 +483,7 @@ class SignApprovalTermsForm(forms.ModelForm):
def clean_has_signed_terms(self): def clean_has_signed_terms(self):
has_signed_terms = self.cleaned_data['has_signed_terms'] has_signed_terms = self.cleaned_data['has_signed_terms']
if not has_signed_terms: if not has_signed_terms:
raise forms.ValidationError(_('You have to agree with the terms')) raise forms.ValidationError(_(astakos_messages.SIGN_TERMS))
return has_signed_terms return has_signed_terms
...@@ -503,8 +501,7 @@ class InvitationForm(forms.ModelForm): ...@@ -503,8 +501,7 @@ class InvitationForm(forms.ModelForm):
username = self.cleaned_data['username'] username = self.cleaned_data['username']
try: try:
Invitation.objects.get(username=username) Invitation.objects.get(username=username)
raise forms.ValidationError( raise forms.ValidationError(_(astakos_messages.INVITATION_EMAIL_EXISTS))
_('There is already invitation for this email.'))
except Invitation.DoesNotExist: except Invitation.DoesNotExist:
pass pass
return username return username
...@@ -688,7 +685,7 @@ class AstakosGroupUpdateForm(forms.ModelForm): ...@@ -688,7 +685,7 @@ class AstakosGroupUpdateForm(forms.ModelForm):
class AddGroupMembersForm(forms.Form): class AddGroupMembersForm(forms.Form):
q = forms.CharField( q = forms.CharField(
max_length=800, widget=forms.Textarea, label=_('Add users'), max_length=800, widget=forms.Textarea, label=_('Add users'),
help_text=_('Add comma separated user emails, eg. user1@user.com, user2@user.com'), help_text=_(astakos_messages.ADD_GROUP_MEMBERS_Q_HELP),
required=True) required=True)
def clean(self): def clean(self):
...@@ -698,8 +695,7 @@ class AddGroupMembersForm(forms.Form): ...@@ -698,8 +695,7 @@ class AddGroupMembersForm(forms.Form):
db_entries = AstakosUser.objects.filter(email__in=users) db_entries = AstakosUser.objects.filter(email__in=users)
unknown = list(set(users) - set(u.email for u in db_entries)) unknown = list(set(users) - set(u.email for u in db_entries))
if unknown: if unknown:
raise forms.ValidationError( raise forms.ValidationError(_(astakos_messages.UNKNOWN_USERS) % ','.join(unknown))
_('Unknown users: %s' % ','.join(unknown)))
self.valid_users = db_entries self.valid_users = db_entries
return self.cleaned_data return self.cleaned_data
......
...@@ -61,6 +61,7 @@ from astakos.im.settings import (DEFAULT_CONTACT_EMAIL, SITENAME, BASEURL, ...@@ -61,6 +61,7 @@ from astakos.im.settings import (DEFAULT_CONTACT_EMAIL, SITENAME, BASEURL,
FEEDBACK_EMAIL_SUBJECT, FEEDBACK_EMAIL_SUBJECT,
EMAIL_CHANGE_EMAIL_SUBJECT) EMAIL_CHANGE_EMAIL_SUBJECT)
import astakos.im.models import astakos.im.models
import astakos.im.messages as astakos_messages
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -303,41 +304,41 @@ class SendMailError(Exception): ...@@ -303,41 +304,41 @@ class SendMailError(Exception):
class SendAdminNotificationError(SendMailError): class SendAdminNotificationError(SendMailError):
def __init__(self): def __init__(self):
self.message = _('Failed to send notification') self.message = _(astakos_messages.ADMIN_NOTIFICATION_SEND_ERR)
super(SendAdminNotificationError, self).__init__() super(SendAdminNotificationError, self).__init__()
class SendVerificationError(SendMailError): class SendVerificationError(SendMailError):
def __init__(self): def __init__(self):
self.message = _('Failed to send verification') self.message = _(astakos_messages.VERIFICATION_SEND_ERR)
super(SendVerificationError, self).__init__() super(SendVerificationError, self).__init__()
class SendInvitationError(SendMailError): class SendInvitationError(SendMailError):
def __init__(self): def __init__(self):
self.message = _('Failed to send invitation') self.message = _(astakos_messages.INVITATION_SEND_ERR)
super(SendInvitationError, self).__init__() super(SendInvitationError, self).__init__()
class SendGreetingError(SendMailError): class SendGreetingError(SendMailError):
def __init__(self): def __init__(self):
self.message = _('Failed to send greeting') self.message = _(astakos_messages.GREETING_SEND_ERR)
super(SendGreetingError, self).__init__() super(SendGreetingError, self).__init__()
class SendFeedbackError(SendMailError): class SendFeedbackError(SendMailError):
def __init__(self): def __init__(self):
self.message = _('Failed to send feedback') self.message = _(astakos_messages.FEEDBACK_SEND_ERR)
super(SendFeedbackError, self).__init__() super(SendFeedbackError, self).__init__()
class ChangeEmailError(SendMailError): class ChangeEmailError(SendMailError):
def __init__(self): def __init__(self):
self.message = _('Failed to send change email') self.message = self.message = _(astakos_messages.CHANGE_EMAIL_SEND_ERR)
super(ChangeEmailError, self).__init__() super(ChangeEmailError, self).__init__()
class SendNotificationError(SendMailError): class SendNotificationError(SendMailError):
def __init__(self): def __init__(self):
self.message = _('Failed to send notification email') self.message = _(astakos_messages.NOTIFICATION_SEND_ERR)
super(SendNotificationError, self).__init__() super(SendNotificationError, self).__init__()
# Copyright 2011-2012 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
#
# 1. Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
ACCOUNT_AUTHENTICATION_FAILED = 'Cannot authenticate account.'
ACCOUNT_INACTIVE = 'Inactive account.'
ACCOUNT_ALREADY_ACTIVE = 'Account is already active.'
TOKEN_UNKNOWN = 'There is no user matching this token.'
INVITATION_SENT = 'Invitation sent to %(emails.'
PROFILE_UPDATED = 'Profile has been updated successfully.'
FEEDBACK_SENT = 'Feedback successfully sent.'
EMAIL_CHANGED = 'Account email has been changed successfully.'
EMAIL_CHANGE_REGISTERED = 'Change email request has been registered succefully. \
You are going to receive a verification email in the new address.'
OBJECT_CREATED = 'The %(verbose_names was created successfully.'
MEMBER_JOINED_GROUP = '%(realnames has been successfully joined the group.'
MEMBER_REMOVED = '%(realnames has been successfully removed from the group.'
BILLING_ERROR = 'Service response status: %(status)d'
LOGOUT_SUCCESS = 'You have successfully logged out.'
GENERIC_ERROR = 'Something wrong has happened. \
Please contact the administrators for more details.'
MAX_INVITATION_NUMBER_REACHED = 'There are no invitations left.'
GROUP_MAX_PARTICIPANT_NUMBER_REACHED = 'Group maximum participant number has been reached.'
NO_APPROVAL_TERMS = 'There are no approval terms.'
PENDING_EMAIL_CHANGE_REQUEST = 'There is already a pending change email request.'
OBJECT_CREATED_FAILED = 'The %(verbose_names creation failed: %(reasons.'
GROUP_JOIN_FAILURE = 'Failed to join group.'
GROUPKIND_UNKNOWN = 'There is no such a group kind'
NOT_MEMBER = 'User is not member of the group.'
NOT_OWNER = 'User is not a group owner.'
OWNER_CANNOT_LEAVE_GROUP = 'Owner cannot leave the group.'
# Field validation fields
REQUIRED_FIELD = 'This field is required.'
EMAIL_USED = 'This email address is already in use. Please supply a different email address.'
SHIBBOLETH_EMAIL_USED = 'This email is already associated with another shibboleth account.'
SHIBBOLETH_INACTIVE_ACC = 'This email is already associated with an inactive account. \
You need to wait to be activated before being able to switch to a shibboleth account.'
SIGN_TERMS = 'You have to agree with the terms.'
CAPTCHA_VALIDATION_ERR = 'You have not entered the correct words.'
SUSPENDED_LOCAL_ACC = 'Local login is not the current authentication method for this account.'
UNUSABLE_PASSWORD = 'This account has not a usable password.'
EMAIL_UNKNOWN = 'That e-mail address doesn\'t have an associated user account. \
Are you sure you\'ve registered?'
INVITATION_EMAIL_EXISTS = 'There is already invitation for this email.'
INVITATION_CONSUMED_ERR = 'Invitation is used.'
UNKNOWN_USERS = 'Unknown users: %s'
UNIQUE_EMAIL_IS_ACTIVE_CONSTRAIN_ERR = 'Another account with the same email & is_active combination found.'
INVALID_ACTIVATION_KEY = 'Invalid activation key.'
NEW_EMAIL_ADDR_RESERVED = 'The new email address is reserved.'
EMAIL_RESERVED = 'Email: %(email)s is reserved'
# Field help text
ADD_GROUP_MEMBERS_Q_HELP = 'Add comma separated user emails, eg. user1@user.com, user2@user.com'
ASTAKOSUSER_GROUPS_HELP = 'In addition to the permissions manually assigned, \
this user will also get all permissions granted to each group he/she is in.'
EMAIL_CHANGE_NEW_ADDR_HELP = 'Your old email address will be used until you verify your new one.'
EMAIL_SEND_ERR = 'Failed to send %s.'
ADMIN_NOTIFICATION_SEND_ERR = EMAIL_SEND_ERR % 'admin notification'
VERIFICATION_SEND_ERR = EMAIL_SEND_ERR % 'verification'
INVITATION_SEND_ERR = EMAIL_SEND_ERR % 'invitation'
GREETING_SEND_ERR = EMAIL_SEND_ERR % 'greeting'
FEEDBACK_SEND_ERR = EMAIL_SEND_ERR % 'feedback'
CHANGE_EMAIL_SEND_ERR = EMAIL_SEND_ERR % 'feedback'
NOTIFICATION_SEND_ERR = EMAIL_SEND_ERR % 'notification'
MISSING_NEXT_PARAMETER = 'No next parameter'
VERIFICATION_SENT = 'Verification sent.'
SWITCH_ACCOUNT_LINK_SENT = 'This email is already associated with another local account. \
To change this account to a shibboleth one follow the link in the verification email sent to %(emails. \
Otherwise just ignore it.'
NOTIFACATION_SENT = 'Your request for an account was successfully received and is now pending approval. \
You will be notified by email in the next few days. \
Thanks for your interest in ~okeanos! The GRNET team.'
REGISTRATION_COMPLETED = 'Registration completed. You can now login.'
\ No newline at end of file
...@@ -63,6 +63,8 @@ from astakos.im.functions import send_invitation ...@@ -63,6 +63,8 @@ from astakos.im.functions import send_invitation
from astakos.im.tasks import propagate_groupmembers_quota from astakos.im.tasks import propagate_groupmembers_quota
from astakos.im.functions import send_invitation from astakos.im.functions import send_invitation
import astakos.im.messages as astakos_messages
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
DEFAULT_CONTENT_TYPE = None DEFAULT_CONTENT_TYPE = None
...@@ -340,9 +342,7 @@ class AstakosUser(User): ...@@ -340,9 +342,7 @@ class AstakosUser(User):
astakos_groups = models.ManyToManyField( astakos_groups = models.ManyToManyField(
AstakosGroup, verbose_name=_('agroups'), blank=True, AstakosGroup, verbose_name=_('agroups'), blank=True,
help_text=_("""In addition to the permissions manually assigned, this help_text=_(astakos_messages.ASTAKOSUSER_GROUPS_HELP),
user will also get all permissions granted to each group
he/she is in."""),
through='Membership') through='Membership')
__has_signed_terms = False __has_signed_terms = False
...@@ -519,7 +519,7 @@ class AstakosUser(User): ...@@ -519,7 +519,7 @@ class AstakosUser(User):
q = q.filter(email=self.email) q = q.filter(email=self.email)
q = q.filter(is_active=self.is_active) q = q.filter(is_active=self.is_active)
if q.count() != 0: if q.count() != 0:
raise ValidationError({'__all__': [_('Another account with the same email & is_active combination found.')]}) raise ValidationError({'__all__': [_(astakos_messages.UNIQUE_EMAIL_IS_ACTIVE_CONSTRAIN_ERR)]})
@property @property
def signed_terms(self): def signed_terms(self):
...@@ -690,7 +690,7 @@ class EmailChangeManager(models.Manager): ...@@ -690,7 +690,7 @@ class EmailChangeManager(models.Manager):
except AstakosUser.DoesNotExist: except AstakosUser.DoesNotExist:
pass pass
else: else:
raise ValueError(_('The new email address is reserved.')) raise ValueError(_(astakos_messages.NEW_EMAIL_ADDR_RESERVED))
# update user # update user
user = AstakosUser.objects.get(pk=email_change.user_id) user = AstakosUser.objects.get(pk=email_change.user_id)
user.email = email_change.new_email_address user.email = email_change.new_email_address
...@@ -698,12 +698,12 @@ class EmailChangeManager(models.Manager): ...@@ -698,12 +698,12 @@ class EmailChangeManager(models.Manager):
email_change.delete() email_change.delete()
return user return user
except EmailChange.DoesNotExist: except EmailChange.DoesNotExist:
raise ValueError(_('Invalid activation key')) raise ValueError(_(astakos_messages.INVALID_ACTIVATION_KEY))
class EmailChange(models.Model): class EmailChange(models.Model):
new_email_address = models.EmailField(_(u'new e-mail address'), new_email_address = models.EmailField(_(u'new e-mail address'),
help_text=_(u'Your old email address will be used until you verify your new one.')) help_text=_(astakos_messages.EMAIL_CHANGE_NEW_ADDR_HELP))
user = models.ForeignKey( user = models.ForeignKey(
AstakosUser, unique=True, related_name='emailchange_user') AstakosUser, unique=True, related_name='emailchange_user')
requested_at = models.DateTimeField(default=datetime.now()) requested_at = models.DateTimeField(default=datetime.now())
...@@ -851,4 +851,4 @@ post_delete.connect(send_quota_disturbed, sender=Membership) ...@@ -851,4 +851,4 @@ post_delete.connect(send_quota_disturbed, sender=Membership)
post_save.connect(send_quota_disturbed, sender=AstakosUserQuota) post_save.connect(send_quota_disturbed, sender=AstakosUserQuota)
post_delete.connect(send_quota_disturbed, sender=AstakosUserQuota) post_delete.connect(send_quota_disturbed, sender=AstakosUserQuota)
post_save.connect(send_quota_disturbed, sender=AstakosGroupQuota) post_save.connect(send_quota_disturbed, sender=AstakosGroupQuota)
post_delete.connect(send_quota_disturbed, sender=AstakosGroupQuota) post_delete.connect(send_quota_disturbed, sender=AstakosGroupQuota)
\ No newline at end of file
...@@ -43,6 +43,8 @@ from astakos.im.views import requires_anonymous ...@@ -43,6 +43,8 @@ from astakos.im.views import requires_anonymous
from astakos.im.forms import LoginForm from astakos.im.forms import LoginForm
from astakos.im.settings import RATELIMIT_RETRIES_ALLOWED from astakos.im.settings import RATELIMIT_RETRIES_ALLOWED
import astakos.im.messages as astakos_messages
from ratelimit.decorators import ratelimit from ratelimit.decorators import ratelimit
retries = RATELIMIT_RETRIES_ALLOWED - 1 retries = RATELIMIT_RETRIES_ALLOWED - 1
...@@ -72,9 +74,9 @@ def login(request, on_failure='im/login.html'): ...@@ -72,9 +74,9 @@ def login(request, on_failure='im/login.html'):
message = None message = None
if not user: if not user:
message = _('Cannot authenticate account') message = _(astakos_messages.ACCOUNT_AUTHENTICATION_FAILED)
elif not user.is_active: elif not user.is_active: