Revision 674f9a52
b/snf-astakos-app/astakos/im/activation_backends.py | ||
---|---|---|
41 | 41 |
from astakos.im.functions import (send_verification, send_activation, |
42 | 42 |
send_account_creation_notification, |
43 | 43 |
send_group_creation_notification, activate) |
44 |
from astakos.im.settings import INVITATIONS_ENABLED, MODERATION_ENABLED, SITENAME, RE_USER_EMAIL_PATTERNS |
|
44 |
from astakos.im.settings import (INVITATIONS_ENABLED, MODERATION_ENABLED, |
|
45 |
SITENAME, RE_USER_EMAIL_PATTERNS |
|
46 |
) |
|
47 |
from astakos.im.messages import as astakos_messages |
|
45 | 48 |
|
46 | 49 |
import logging |
47 | 50 |
import re |
... | ... | |
226 | 229 |
|
227 | 230 |
class VerificationSent(ActivationResult): |
228 | 231 |
def __init__(self): |
229 |
message = _('Verification sent.')
|
|
232 |
message = _(astakos_messages.VERIFICATION_SENT)
|
|
230 | 233 |
super(VerificationSent, self).__init__(message) |
231 | 234 |
|
232 | 235 |
|
233 | 236 |
class SwitchAccountsVerificationSent(ActivationResult): |
234 | 237 |
def __init__(self, email): |
235 |
message = _('This email is already associated with another \ |
|
236 |
local account. To change this account to a shibboleth \ |
|
237 |
one follow the link in the verification email sent \ |
|
238 |
to %s. Otherwise just ignore it.' % email) |
|
238 |
message = _(astakos_messages.SWITCH_ACCOUNT_LINK_SENT) |
|
239 | 239 |
super(SwitchAccountsVerificationSent, self).__init__(message) |
240 | 240 |
|
241 | 241 |
|
242 | 242 |
class NotificationSent(ActivationResult): |
243 | 243 |
def __init__(self): |
244 |
message = _('Your request for an account was successfully received and is now pending \ |
|
245 |
approval. You will be notified by email in the next few days. Thanks for \ |
|
246 |
your interest in ~okeanos! The GRNET team.') |
|
244 |
message = _(astakos_messages.NOTIFACATION_SENT) |
|
247 | 245 |
super(NotificationSent, self).__init__(message) |
248 | 246 |
|
249 | 247 |
|
250 | 248 |
class RegistationCompleted(ActivationResult): |
251 | 249 |
def __init__(self): |
252 |
message = _('Registration completed. You can now login.')
|
|
250 |
message = _(astakos_messages.REGISTRATION_COMPLETED)
|
|
253 | 251 |
super(RegistationCompleted, self).__init__(message) |
b/snf-astakos-app/astakos/im/endpoints/quotaholder.py | ||
---|---|---|
51 | 51 |
|
52 | 52 |
logger = logging.getLogger(__name__) |
53 | 53 |
|
54 |
inf = float('inf') |
|
54 | 55 |
|
55 | 56 |
def call(func_name): |
56 | 57 |
"""Decorator function for QuotaholderHTTP client calls.""" |
b/snf-astakos-app/astakos/im/forms.py | ||
---|---|---|
60 | 60 |
|
61 | 61 |
from astakos.im.util import reserved_email, get_query |
62 | 62 |
|
63 |
import astakos.im.messages as astakos_messages |
|
64 |
|
|
63 | 65 |
import logging |
64 | 66 |
import hashlib |
65 | 67 |
import recaptcha.client.captcha as captcha |
... | ... | |
116 | 118 |
def clean_email(self): |
117 | 119 |
email = self.cleaned_data['email'] |
118 | 120 |
if not email: |
119 |
raise forms.ValidationError(_("This field is required"))
|
|
121 |
raise forms.ValidationError(_(astakos_messages.REQUIRED_FIELD))
|
|
120 | 122 |
if reserved_email(email): |
121 |
raise forms.ValidationError(_("This email is already used"))
|
|
123 |
raise forms.ValidationError(_(astakos_messages.EMAIL_USED))
|
|
122 | 124 |
return email |
123 | 125 |
|
124 | 126 |
def clean_has_signed_terms(self): |
125 | 127 |
has_signed_terms = self.cleaned_data['has_signed_terms'] |
126 | 128 |
if not has_signed_terms: |
127 |
raise forms.ValidationError(_('You have to agree with the terms'))
|
|
129 |
raise forms.ValidationError(_(astakos_messages.SIGN_TERMS))
|
|
128 | 130 |
return has_signed_terms |
129 | 131 |
|
130 | 132 |
def clean_recaptcha_response_field(self): |
... | ... | |
142 | 144 |
rrf = self.cleaned_data['recaptcha_response_field'] |
143 | 145 |
check = captcha.submit(rcf, rrf, RECAPTCHA_PRIVATE_KEY, self.ip) |
144 | 146 |
if not check.is_valid: |
145 |
raise forms.ValidationError( |
|
146 |
_('You have not entered the correct words')) |
|
147 |
raise forms.ValidationError(_(astakos_messages.CAPTCHA_VALIDATION_ERR)) |
|
147 | 148 |
|
148 | 149 |
def save(self, commit=True): |
149 | 150 |
""" |
... | ... | |
222 | 223 |
def clean_email(self): |
223 | 224 |
email = self.cleaned_data['email'] |
224 | 225 |
if not email: |
225 |
raise forms.ValidationError(_("This field is required"))
|
|
226 |
raise forms.ValidationError(_(astakos_messages.REQUIRED_FIELD))
|
|
226 | 227 |
return email |
227 | 228 |
|
228 | 229 |
def clean_has_signed_terms(self): |
229 | 230 |
has_signed_terms = self.cleaned_data['has_signed_terms'] |
230 | 231 |
if not has_signed_terms: |
231 |
raise forms.ValidationError(_('You have to agree with the terms'))
|
|
232 |
raise forms.ValidationError(_(astakos_messages.SIGN_TERMS))
|
|
232 | 233 |
return has_signed_terms |
233 | 234 |
|
234 | 235 |
def save(self, commit=True): |
... | ... | |
287 | 288 |
email = self.cleaned_data['email'] |
288 | 289 |
for user in AstakosUser.objects.filter(email=email): |
289 | 290 |
if user.provider == 'shibboleth': |
290 |
raise forms.ValidationError(_("This email is already associated with another shibboleth account."))
|
|
291 |
raise forms.ValidationError(_(astakos_messages.SHIBBOLETH_EMAIL_USED))
|
|
291 | 292 |
elif not user.is_active: |
292 |
raise forms.ValidationError(_("This email is already associated with an inactive account. \ |
|
293 |
You need to wait to be activated before being able to switch to a shibboleth account.")) |
|
293 |
raise forms.ValidationError(_(astakos_messages.SHIBBOLETH_INACTIVE_ACC)) |
|
294 | 294 |
super(ShibbolethUserCreationForm, self).clean_email() |
295 | 295 |
return email |
296 | 296 |
|
... | ... | |
343 | 343 |
rrf = self.cleaned_data['recaptcha_response_field'] |
344 | 344 |
check = captcha.submit(rcf, rrf, RECAPTCHA_PRIVATE_KEY, self.ip) |
345 | 345 |
if not check.is_valid: |
346 |
raise forms.ValidationError( |
|
347 |
_('You have not entered the correct words')) |
|
346 |
raise forms.ValidationError(_(astakos_messages.CAPTCHA_VALIDATION_ERR)) |
|
348 | 347 |
|
349 | 348 |
def clean(self): |
350 | 349 |
super(LoginForm, self).clean() |
351 | 350 |
if self.user_cache and self.user_cache.provider not in ('local', ''): |
352 |
raise forms.ValidationError(_('Local login is not the current authentication method for this account.'))
|
|
351 |
raise forms.ValidationError(_(astakos_messages.SUSPENDED_LOCAL_ACC))
|
|
353 | 352 |
return self.cleaned_data |
354 | 353 |
|
355 | 354 |
|
... | ... | |
419 | 418 |
try: |
420 | 419 |
user = AstakosUser.objects.get(email=email, is_active=True) |
421 | 420 |
if not user.has_usable_password(): |
422 |
raise forms.ValidationError( |
|
423 |
_("This account has not a usable password.")) |
|
421 |
raise forms.ValidationError(_(astakos_messages.UNUSABLE_PASSWORD)) |
|
424 | 422 |
except AstakosUser.DoesNotExist: |
425 |
raise forms.ValidationError(_('That e-mail address doesn\'t have an associated user account. Are you sure you\'ve registered?'))
|
|
423 |
raise forms.ValidationError(_(astakos_messages.EMAIL_UNKNOWN))
|
|
426 | 424 |
return email |
427 | 425 |
|
428 | 426 |
def save( |
... | ... | |
460 | 458 |
def clean_new_email_address(self): |
461 | 459 |
addr = self.cleaned_data['new_email_address'] |
462 | 460 |
if AstakosUser.objects.filter(email__iexact=addr): |
463 |
raise forms.ValidationError(_(u'This email address is already in use. Please supply a different email address.'))
|
|
461 |
raise forms.ValidationError(_(astakos_messages.EMAIL_USED))
|
|
464 | 462 |
return addr |
465 | 463 |
|
466 | 464 |
def save(self, email_template_name, request, commit=True): |
... | ... | |
485 | 483 |
def clean_has_signed_terms(self): |
486 | 484 |
has_signed_terms = self.cleaned_data['has_signed_terms'] |
487 | 485 |
if not has_signed_terms: |
488 |
raise forms.ValidationError(_('You have to agree with the terms'))
|
|
486 |
raise forms.ValidationError(_(astakos_messages.SIGN_TERMS))
|
|
489 | 487 |
return has_signed_terms |
490 | 488 |
|
491 | 489 |
|
... | ... | |
503 | 501 |
username = self.cleaned_data['username'] |
504 | 502 |
try: |
505 | 503 |
Invitation.objects.get(username=username) |
506 |
raise forms.ValidationError( |
|
507 |
_('There is already invitation for this email.')) |
|
504 |
raise forms.ValidationError(_(astakos_messages.INVITATION_EMAIL_EXISTS)) |
|
508 | 505 |
except Invitation.DoesNotExist: |
509 | 506 |
pass |
510 | 507 |
return username |
... | ... | |
688 | 685 |
class AddGroupMembersForm(forms.Form): |
689 | 686 |
q = forms.CharField( |
690 | 687 |
max_length=800, widget=forms.Textarea, label=_('Add users'), |
691 |
help_text=_('Add comma separated user emails, eg. user1@user.com, user2@user.com'),
|
|
688 |
help_text=_(astakos_messages.ADD_GROUP_MEMBERS_Q_HELP),
|
|
692 | 689 |
required=True) |
693 | 690 |
|
694 | 691 |
def clean(self): |
... | ... | |
698 | 695 |
db_entries = AstakosUser.objects.filter(email__in=users) |
699 | 696 |
unknown = list(set(users) - set(u.email for u in db_entries)) |
700 | 697 |
if unknown: |
701 |
raise forms.ValidationError( |
|
702 |
_('Unknown users: %s' % ','.join(unknown))) |
|
698 |
raise forms.ValidationError(_(astakos_messages.UNKNOWN_USERS) % ','.join(unknown)) |
|
703 | 699 |
self.valid_users = db_entries |
704 | 700 |
return self.cleaned_data |
705 | 701 |
|
b/snf-astakos-app/astakos/im/functions.py | ||
---|---|---|
61 | 61 |
FEEDBACK_EMAIL_SUBJECT, |
62 | 62 |
EMAIL_CHANGE_EMAIL_SUBJECT) |
63 | 63 |
import astakos.im.models |
64 |
import astakos.im.messages as astakos_messages |
|
64 | 65 |
|
65 | 66 |
logger = logging.getLogger(__name__) |
66 | 67 |
|
... | ... | |
303 | 304 |
|
304 | 305 |
class SendAdminNotificationError(SendMailError): |
305 | 306 |
def __init__(self): |
306 |
self.message = _('Failed to send notification')
|
|
307 |
self.message = _(astakos_messages.ADMIN_NOTIFICATION_SEND_ERR)
|
|
307 | 308 |
super(SendAdminNotificationError, self).__init__() |
308 | 309 |
|
309 | 310 |
|
310 | 311 |
class SendVerificationError(SendMailError): |
311 | 312 |
def __init__(self): |
312 |
self.message = _('Failed to send verification')
|
|
313 |
self.message = _(astakos_messages.VERIFICATION_SEND_ERR)
|
|
313 | 314 |
super(SendVerificationError, self).__init__() |
314 | 315 |
|
315 | 316 |
|
316 | 317 |
class SendInvitationError(SendMailError): |
317 | 318 |
def __init__(self): |
318 |
self.message = _('Failed to send invitation')
|
|
319 |
self.message = _(astakos_messages.INVITATION_SEND_ERR)
|
|
319 | 320 |
super(SendInvitationError, self).__init__() |
320 | 321 |
|
321 | 322 |
|
322 | 323 |
class SendGreetingError(SendMailError): |
323 | 324 |
def __init__(self): |
324 |
self.message = _('Failed to send greeting')
|
|
325 |
self.message = _(astakos_messages.GREETING_SEND_ERR)
|
|
325 | 326 |
super(SendGreetingError, self).__init__() |
326 | 327 |
|
327 | 328 |
|
328 | 329 |
class SendFeedbackError(SendMailError): |
329 | 330 |
def __init__(self): |
330 |
self.message = _('Failed to send feedback')
|
|
331 |
self.message = _(astakos_messages.FEEDBACK_SEND_ERR)
|
|
331 | 332 |
super(SendFeedbackError, self).__init__() |
332 | 333 |
|
333 | 334 |
|
334 | 335 |
class ChangeEmailError(SendMailError): |
335 | 336 |
def __init__(self): |
336 |
self.message = _('Failed to send change email')
|
|
337 |
self.message = self.message = _(astakos_messages.CHANGE_EMAIL_SEND_ERR)
|
|
337 | 338 |
super(ChangeEmailError, self).__init__() |
338 | 339 |
|
339 | 340 |
|
340 | 341 |
class SendNotificationError(SendMailError): |
341 | 342 |
def __init__(self): |
342 |
self.message = _('Failed to send notification email')
|
|
343 |
self.message = _(astakos_messages.NOTIFICATION_SEND_ERR)
|
|
343 | 344 |
super(SendNotificationError, self).__init__() |
b/snf-astakos-app/astakos/im/messages.py | ||
---|---|---|
1 |
# Copyright 2011-2012 GRNET S.A. All rights reserved. |
|
2 |
# |
|
3 |
# Redistribution and use in source and binary forms, with or |
|
4 |
# without modification, are permitted provided that the following |
|
5 |
# conditions are met: |
|
6 |
# |
|
7 |
# 1. Redistributions of source code must retain the above |
|
8 |
# copyright notice, this list of conditions and the following |
|
9 |
# disclaimer. |
|
10 |
# |
|
11 |
# 2. Redistributions in binary form must reproduce the above |
|
12 |
# copyright notice, this list of conditions and the following |
|
13 |
# disclaimer in the documentation and/or other materials |
|
14 |
# provided with the distribution. |
|
15 |
# |
|
16 |
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS |
|
17 |
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
18 |
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
19 |
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR |
|
20 |
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
21 |
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
22 |
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
|
23 |
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED |
|
24 |
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
25 |
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN |
|
26 |
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
27 |
# POSSIBILITY OF SUCH DAMAGE. |
|
28 |
# |
|
29 |
# The views and conclusions contained in the software and |
|
30 |
# documentation are those of the authors and should not be |
|
31 |
# interpreted as representing official policies, either expressed |
|
32 |
# or implied, of GRNET S.A. |
|
33 |
|
|
34 |
ACCOUNT_AUTHENTICATION_FAILED = 'Cannot authenticate account.' |
|
35 |
ACCOUNT_INACTIVE = 'Inactive account.' |
|
36 |
ACCOUNT_ALREADY_ACTIVE = 'Account is already active.' |
|
37 |
TOKEN_UNKNOWN = 'There is no user matching this token.' |
|
38 |
|
|
39 |
INVITATION_SENT = 'Invitation sent to %(emails.' |
|
40 |
PROFILE_UPDATED = 'Profile has been updated successfully.' |
|
41 |
FEEDBACK_SENT = 'Feedback successfully sent.' |
|
42 |
EMAIL_CHANGED = 'Account email has been changed successfully.' |
|
43 |
EMAIL_CHANGE_REGISTERED = 'Change email request has been registered succefully. \ |
|
44 |
You are going to receive a verification email in the new address.' |
|
45 |
|
|
46 |
OBJECT_CREATED = 'The %(verbose_names was created successfully.' |
|
47 |
MEMBER_JOINED_GROUP = '%(realnames has been successfully joined the group.' |
|
48 |
MEMBER_REMOVED = '%(realnames has been successfully removed from the group.' |
|
49 |
BILLING_ERROR = 'Service response status: %(status)d' |
|
50 |
LOGOUT_SUCCESS = 'You have successfully logged out.' |
|
51 |
|
|
52 |
GENERIC_ERROR = 'Something wrong has happened. \ |
|
53 |
Please contact the administrators for more details.' |
|
54 |
|
|
55 |
MAX_INVITATION_NUMBER_REACHED = 'There are no invitations left.' |
|
56 |
GROUP_MAX_PARTICIPANT_NUMBER_REACHED = 'Group maximum participant number has been reached.' |
|
57 |
NO_APPROVAL_TERMS = 'There are no approval terms.' |
|
58 |
PENDING_EMAIL_CHANGE_REQUEST = 'There is already a pending change email request.' |
|
59 |
OBJECT_CREATED_FAILED = 'The %(verbose_names creation failed: %(reasons.' |
|
60 |
GROUP_JOIN_FAILURE = 'Failed to join group.' |
|
61 |
GROUPKIND_UNKNOWN = 'There is no such a group kind' |
|
62 |
NOT_MEMBER = 'User is not member of the group.' |
|
63 |
NOT_OWNER = 'User is not a group owner.' |
|
64 |
OWNER_CANNOT_LEAVE_GROUP = 'Owner cannot leave the group.' |
|
65 |
|
|
66 |
# Field validation fields |
|
67 |
REQUIRED_FIELD = 'This field is required.' |
|
68 |
EMAIL_USED = 'This email address is already in use. Please supply a different email address.' |
|
69 |
SHIBBOLETH_EMAIL_USED = 'This email is already associated with another shibboleth account.' |
|
70 |
SHIBBOLETH_INACTIVE_ACC = 'This email is already associated with an inactive account. \ |
|
71 |
You need to wait to be activated before being able to switch to a shibboleth account.' |
|
72 |
|
|
73 |
SIGN_TERMS = 'You have to agree with the terms.' |
|
74 |
CAPTCHA_VALIDATION_ERR = 'You have not entered the correct words.' |
|
75 |
SUSPENDED_LOCAL_ACC = 'Local login is not the current authentication method for this account.' |
|
76 |
UNUSABLE_PASSWORD = 'This account has not a usable password.' |
|
77 |
EMAIL_UNKNOWN = 'That e-mail address doesn\'t have an associated user account. \ |
|
78 |
Are you sure you\'ve registered?' |
|
79 |
INVITATION_EMAIL_EXISTS = 'There is already invitation for this email.' |
|
80 |
INVITATION_CONSUMED_ERR = 'Invitation is used.' |
|
81 |
UNKNOWN_USERS = 'Unknown users: %s' |
|
82 |
UNIQUE_EMAIL_IS_ACTIVE_CONSTRAIN_ERR = 'Another account with the same email & is_active combination found.' |
|
83 |
INVALID_ACTIVATION_KEY = 'Invalid activation key.' |
|
84 |
NEW_EMAIL_ADDR_RESERVED = 'The new email address is reserved.' |
|
85 |
EMAIL_RESERVED = 'Email: %(email)s is reserved' |
|
86 |
|
|
87 |
# Field help text |
|
88 |
ADD_GROUP_MEMBERS_Q_HELP = 'Add comma separated user emails, eg. user1@user.com, user2@user.com' |
|
89 |
ASTAKOSUSER_GROUPS_HELP = 'In addition to the permissions manually assigned, \ |
|
90 |
this user will also get all permissions granted to each group he/she is in.' |
|
91 |
EMAIL_CHANGE_NEW_ADDR_HELP = 'Your old email address will be used until you verify your new one.' |
|
92 |
|
|
93 |
EMAIL_SEND_ERR = 'Failed to send %s.' |
|
94 |
ADMIN_NOTIFICATION_SEND_ERR = EMAIL_SEND_ERR % 'admin notification' |
|
95 |
VERIFICATION_SEND_ERR = EMAIL_SEND_ERR % 'verification' |
|
96 |
INVITATION_SEND_ERR = EMAIL_SEND_ERR % 'invitation' |
|
97 |
GREETING_SEND_ERR = EMAIL_SEND_ERR % 'greeting' |
|
98 |
FEEDBACK_SEND_ERR = EMAIL_SEND_ERR % 'feedback' |
|
99 |
CHANGE_EMAIL_SEND_ERR = EMAIL_SEND_ERR % 'feedback' |
|
100 |
NOTIFICATION_SEND_ERR = EMAIL_SEND_ERR % 'notification' |
|
101 |
|
|
102 |
|
|
103 |
MISSING_NEXT_PARAMETER = 'No next parameter' |
|
104 |
|
|
105 |
VERIFICATION_SENT = 'Verification sent.' |
|
106 |
|
|
107 |
SWITCH_ACCOUNT_LINK_SENT = 'This email is already associated with another local account. \ |
|
108 |
To change this account to a shibboleth one follow the link in the verification email sent to %(emails. \ |
|
109 |
Otherwise just ignore it.' |
|
110 |
NOTIFACATION_SENT = 'Your request for an account was successfully received and is now pending approval. \ |
|
111 |
You will be notified by email in the next few days. \ |
|
112 |
Thanks for your interest in ~okeanos! The GRNET team.' |
|
113 |
REGISTRATION_COMPLETED = 'Registration completed. You can now login.' |
b/snf-astakos-app/astakos/im/models.py | ||
---|---|---|
63 | 63 |
from astakos.im.tasks import propagate_groupmembers_quota |
64 | 64 |
from astakos.im.functions import send_invitation |
65 | 65 |
|
66 |
import astakos.im.messages as astakos_messages |
|
67 |
|
|
66 | 68 |
logger = logging.getLogger(__name__) |
67 | 69 |
|
68 | 70 |
DEFAULT_CONTENT_TYPE = None |
... | ... | |
340 | 342 |
|
341 | 343 |
astakos_groups = models.ManyToManyField( |
342 | 344 |
AstakosGroup, verbose_name=_('agroups'), blank=True, |
343 |
help_text=_("""In addition to the permissions manually assigned, this |
|
344 |
user will also get all permissions granted to each group |
|
345 |
he/she is in."""), |
|
345 |
help_text=_(astakos_messages.ASTAKOSUSER_GROUPS_HELP), |
|
346 | 346 |
through='Membership') |
347 | 347 |
|
348 | 348 |
__has_signed_terms = False |
... | ... | |
519 | 519 |
q = q.filter(email=self.email) |
520 | 520 |
q = q.filter(is_active=self.is_active) |
521 | 521 |
if q.count() != 0: |
522 |
raise ValidationError({'__all__': [_('Another account with the same email & is_active combination found.')]})
|
|
522 |
raise ValidationError({'__all__': [_(astakos_messages.UNIQUE_EMAIL_IS_ACTIVE_CONSTRAIN_ERR)]})
|
|
523 | 523 |
|
524 | 524 |
@property |
525 | 525 |
def signed_terms(self): |
... | ... | |
690 | 690 |
except AstakosUser.DoesNotExist: |
691 | 691 |
pass |
692 | 692 |
else: |
693 |
raise ValueError(_('The new email address is reserved.'))
|
|
693 |
raise ValueError(_(astakos_messages.NEW_EMAIL_ADDR_RESERVED))
|
|
694 | 694 |
# update user |
695 | 695 |
user = AstakosUser.objects.get(pk=email_change.user_id) |
696 | 696 |
user.email = email_change.new_email_address |
... | ... | |
698 | 698 |
email_change.delete() |
699 | 699 |
return user |
700 | 700 |
except EmailChange.DoesNotExist: |
701 |
raise ValueError(_('Invalid activation key'))
|
|
701 |
raise ValueError(_(astakos_messages.INVALID_ACTIVATION_KEY))
|
|
702 | 702 |
|
703 | 703 |
|
704 | 704 |
class EmailChange(models.Model): |
705 | 705 |
new_email_address = models.EmailField(_(u'new e-mail address'), |
706 |
help_text=_(u'Your old email address will be used until you verify your new one.'))
|
|
706 |
help_text=_(astakos_messages.EMAIL_CHANGE_NEW_ADDR_HELP))
|
|
707 | 707 |
user = models.ForeignKey( |
708 | 708 |
AstakosUser, unique=True, related_name='emailchange_user') |
709 | 709 |
requested_at = models.DateTimeField(default=datetime.now()) |
... | ... | |
851 | 851 |
post_save.connect(send_quota_disturbed, sender=AstakosUserQuota) |
852 | 852 |
post_delete.connect(send_quota_disturbed, sender=AstakosUserQuota) |
853 | 853 |
post_save.connect(send_quota_disturbed, sender=AstakosGroupQuota) |
854 |
post_delete.connect(send_quota_disturbed, sender=AstakosGroupQuota) |
|
854 |
post_delete.connect(send_quota_disturbed, sender=AstakosGroupQuota) |
b/snf-astakos-app/astakos/im/target/local.py | ||
---|---|---|
43 | 43 |
from astakos.im.forms import LoginForm |
44 | 44 |
from astakos.im.settings import RATELIMIT_RETRIES_ALLOWED |
45 | 45 |
|
46 |
import astakos.im.messages as astakos_messages |
|
47 |
|
|
46 | 48 |
from ratelimit.decorators import ratelimit |
47 | 49 |
|
48 | 50 |
retries = RATELIMIT_RETRIES_ALLOWED - 1 |
... | ... | |
72 | 74 |
|
73 | 75 |
message = None |
74 | 76 |
if not user: |
75 |
message = _('Cannot authenticate account')
|
|
77 |
message = _(astakos_messages.ACCOUNT_AUTHENTICATION_FAILED)
|
|
76 | 78 |
elif not user.is_active: |
77 |
message = _('Inactive account')
|
|
79 |
message = _(astakos_messages.ACCOUNT_INACTIVE)
|
|
78 | 80 |
if message: |
79 | 81 |
messages.error(request, message) |
80 | 82 |
return render_to_response(on_failure, |
b/snf-astakos-app/astakos/im/target/redirect.py | ||
---|---|---|
45 | 45 |
from astakos.im.util import set_cookie |
46 | 46 |
from astakos.im.functions import login as auth_login, logout |
47 | 47 |
|
48 |
import astakos.im.messages as astakos_messages |
|
49 |
|
|
48 | 50 |
import logging |
49 | 51 |
|
50 | 52 |
logger = logging.getLogger(__name__) |
... | ... | |
62 | 64 |
""" |
63 | 65 |
next = request.GET.get('next') |
64 | 66 |
if not next: |
65 |
return HttpResponseBadRequest(_('No next parameter'))
|
|
67 |
return HttpResponseBadRequest(_(astakos_messages.MISSING_NEXT_PARAMETER))
|
|
66 | 68 |
force = request.GET.get('force', None) |
67 | 69 |
response = HttpResponse() |
68 | 70 |
if force == '': |
b/snf-astakos-app/astakos/im/target/shibboleth.py | ||
---|---|---|
43 | 43 |
from astakos.im.forms import LoginForm |
44 | 44 |
from astakos.im.activation_backends import get_backend, SimpleBackend |
45 | 45 |
|
46 |
import astakos.im.messages as astakos_messages |
|
46 | 47 |
|
47 | 48 |
class Tokens: |
48 | 49 |
# these are mapped by the Shibboleth SP software |
... | ... | |
89 | 90 |
request.GET.get('next'), |
90 | 91 |
'renew' in request.GET) |
91 | 92 |
else: |
92 |
message = _('Inactive account')
|
|
93 |
message = _(astakos_messages.ACCOUNT_INACTIVE)
|
|
93 | 94 |
messages.error(request, message) |
94 | 95 |
return render_response(on_login_template, |
95 | 96 |
login_form=LoginForm(request=request), |
b/snf-astakos-app/astakos/im/util.py | ||
---|---|---|
45 | 45 |
from django.core.urlresolvers import reverse |
46 | 46 |
from django.core.exceptions import ValidationError, ObjectDoesNotExist |
47 | 47 |
from django.db.models.fields import Field |
48 |
from django.utils.translation import ugettext as _ |
|
49 |
|
|
48 | 50 |
from astakos.im.models import AstakosUser, Invitation |
49 | 51 |
from astakos.im.settings import COOKIE_NAME, \ |
50 | 52 |
COOKIE_DOMAIN, COOKIE_SECURE, FORCE_PROFILE_UPDATE, LOGGING_LEVEL |
51 | 53 |
from astakos.im.functions import login |
52 | 54 |
|
55 |
import astakos.im.messages as astakos_messages |
|
56 |
|
|
53 | 57 |
logger = logging.getLogger(__name__) |
54 | 58 |
|
55 | 59 |
|
... | ... | |
94 | 98 |
return |
95 | 99 |
invitation = Invitation.objects.get(code=code) |
96 | 100 |
if invitation.is_consumed: |
97 |
raise ValueError(_('Invitation is used'))
|
|
101 |
raise ValueError(_(astakos_messages.INVITATION_CONSUMED_ERR))
|
|
98 | 102 |
if reserved_email(invitation.username): |
99 |
raise ValueError(_('Email: %s is reserved' % invitation.username)) |
|
103 |
email = invitation.username |
|
104 |
raise ValueError(_(astakos_messages.EMAIL_RESRVED) % locals())) |
|
100 | 105 |
return invitation |
101 | 106 |
|
102 | 107 |
|
b/snf-astakos-app/astakos/im/views.py | ||
---|---|---|
90 | 90 |
from astakos.im.tasks import request_billing |
91 | 91 |
from astakos.im.api.callpoint import AstakosCallpoint |
92 | 92 |
|
93 |
import astakos.im.messages as astakos_messages |
|
94 |
|
|
93 | 95 |
logger = logging.getLogger(__name__) |
94 | 96 |
|
95 | 97 |
|
... | ... | |
229 | 231 |
email = form.cleaned_data.get('username') |
230 | 232 |
realname = form.cleaned_data.get('realname') |
231 | 233 |
inviter.invite(email, realname) |
232 |
message = _('Invitation sent to %s' % email)
|
|
234 |
message = _(astakos_messages.INVITATION_SENT) % locals()
|
|
233 | 235 |
messages.success(request, message) |
234 | 236 |
except SendMailError, e: |
235 | 237 |
message = e.message |
236 | 238 |
messages.error(request, message) |
237 | 239 |
transaction.rollback() |
238 | 240 |
except BaseException, e: |
239 |
message = _('Something went wrong.')
|
|
241 |
message = _(astakos_messages.GENERIC_ERROR)
|
|
240 | 242 |
messages.error(request, message) |
241 | 243 |
logger.exception(e) |
242 | 244 |
transaction.rollback() |
243 | 245 |
else: |
244 | 246 |
transaction.commit() |
245 | 247 |
else: |
246 |
message = _('No invitations left')
|
|
248 |
message = _(astakos_messages.MAX_INVITATION_NUMBER_REACHED)
|
|
247 | 249 |
messages.error(request, message) |
248 | 250 |
|
249 | 251 |
sent = [{'email': inv.username, |
... | ... | |
305 | 307 |
next = request.POST.get('next') |
306 | 308 |
if next: |
307 | 309 |
return redirect(next) |
308 |
msg = _('Profile has been updated successfully')
|
|
310 |
msg = _(astakos_messages.PROFILE_UPDATED)
|
|
309 | 311 |
messages.success(request, msg) |
310 | 312 |
except ValueError, ve: |
311 | 313 |
messages.success(request, ve) |
... | ... | |
397 | 399 |
messages.error(request, message) |
398 | 400 |
transaction.rollback() |
399 | 401 |
except BaseException, e: |
400 |
message = _('Something went wrong.')
|
|
402 |
message = _(astakos_messages.GENERIC_ERROR)
|
|
401 | 403 |
messages.error(request, message) |
402 | 404 |
logger.exception(e) |
403 | 405 |
transaction.rollback() |
... | ... | |
452 | 454 |
except SendMailError, e: |
453 | 455 |
messages.error(request, message) |
454 | 456 |
else: |
455 |
message = _('Feedback successfully sent')
|
|
457 |
message = _(astakos_messages.FEEDBACK_SENT)
|
|
456 | 458 |
messages.success(request, message) |
457 | 459 |
return render_response(template_name, |
458 | 460 |
feedback_form=form, |
... | ... | |
481 | 483 |
response['Location'] = LOGOUT_NEXT |
482 | 484 |
response.status_code = 301 |
483 | 485 |
return response |
484 |
messages.success(request, _('You have successfully logged out.'))
|
|
486 |
messages.success(request, _(astakos_messages.LOGOUT_SUCCESS))
|
|
485 | 487 |
context = get_context(request, extra_context) |
486 | 488 |
response.write( |
487 | 489 |
template_loader.render_to_string(template, context_instance=context)) |
... | ... | |
504 | 506 |
try: |
505 | 507 |
user = AstakosUser.objects.get(auth_token=token) |
506 | 508 |
except AstakosUser.DoesNotExist: |
507 |
return HttpResponseBadRequest(_('No such user'))
|
|
509 |
return HttpResponseBadRequest(_(astakos_messages.ACCOUNT_UNKNOWN))
|
|
508 | 510 |
|
509 | 511 |
if user.is_active: |
510 |
message = _('Account already active.')
|
|
512 |
message = _(astakos_messages.ACCOUNT_ALREADY_ACTIVE)
|
|
511 | 513 |
messages.error(request, message) |
512 | 514 |
return index(request) |
513 | 515 |
|
... | ... | |
534 | 536 |
transaction.rollback() |
535 | 537 |
return index(request) |
536 | 538 |
except BaseException, e: |
537 |
message = _('Something went wrong.')
|
|
539 |
message = _(astakos_messages.GENERIC_ERROR)
|
|
538 | 540 |
messages.error(request, message) |
539 | 541 |
logger.exception(e) |
540 | 542 |
transaction.rollback() |
... | ... | |
555 | 557 |
transaction.rollback() |
556 | 558 |
return index(request) |
557 | 559 |
except BaseException, e: |
558 |
message = _('Something went wrong.')
|
|
560 |
message = _(astakos_messages.GENERIC_ERROR)
|
|
559 | 561 |
messages.error(request, message) |
560 | 562 |
logger.exception(e) |
561 | 563 |
transaction.rollback() |
... | ... | |
578 | 580 |
pass |
579 | 581 |
|
580 | 582 |
if not term: |
581 |
messages.error(request, 'There are no approval terms.')
|
|
583 |
messages.error(request, _(astakos_messages.NO_APPROVAL_TERMS))
|
|
582 | 584 |
return HttpResponseRedirect(reverse('index')) |
583 | 585 |
f = open(term.location, 'r') |
584 | 586 |
terms = f.read() |
... | ... | |
626 | 628 |
try: |
627 | 629 |
user = EmailChange.objects.change_email(activation_key) |
628 | 630 |
if request.user.is_authenticated() and request.user == user: |
629 |
msg = _('Email changed successfully.')
|
|
631 |
msg = _(astakos_messages.EMAIL_CHANGED)
|
|
630 | 632 |
messages.success(request, msg) |
631 | 633 |
auth_logout(request) |
632 | 634 |
response = prepare_response(request, user) |
... | ... | |
653 | 655 |
messages.error(request, msg) |
654 | 656 |
transaction.rollback() |
655 | 657 |
except IntegrityError, e: |
656 |
msg = _('There is already a pending change email request.')
|
|
658 |
msg = _(astakos_messages.PENDING_EMAIL_CHANGE_REQUEST)
|
|
657 | 659 |
messages.error(request, msg) |
658 | 660 |
else: |
659 |
msg = _('Change email request has been registered succefully.\ |
|
660 |
You are going to receive a verification email in the new address.') |
|
661 |
msg = _(astakos_messages.EMAIL_CHANGE_REGISTERED) |
|
661 | 662 |
messages.success(request, msg) |
662 | 663 |
transaction.commit() |
663 | 664 |
return render_response(form_template_name, |
... | ... | |
744 | 745 |
try: |
745 | 746 |
kind = GroupKind.objects.get(name=kind_name) |
746 | 747 |
except: |
747 |
return HttpResponseBadRequest(_('No such group kind'))
|
|
748 |
return HttpResponseBadRequest(_(astakos_messages.GROUPKIND_UNKNOWN))
|
|
748 | 749 |
|
749 | 750 |
|
750 | 751 |
|
... | ... | |
801 | 802 |
result = callpoint.create_groups((d,)).next() |
802 | 803 |
if result.is_success: |
803 | 804 |
new_object = result.data[0] |
804 |
msg = _("The %(verbose_name)s was created successfully.") %\
|
|
805 |
msg = _(astakos_messages.OBJECT_CREATED) %\
|
|
805 | 806 |
{"verbose_name": model._meta.verbose_name} |
806 | 807 |
messages.success(request, msg, fail_silently=True) |
807 | 808 |
|
... | ... | |
820 | 821 |
post_save_redirect = '/im/group/%(id)s/' |
821 | 822 |
return HttpResponseRedirect(post_save_redirect % new_object) |
822 | 823 |
else: |
823 |
msg = _("The %(verbose_name)s creation failed: %(reason)s.") %\
|
|
824 |
msg = _(astakos_messages.OBJECT_CREATED_FAILED) %\
|
|
824 | 825 |
{"verbose_name": model._meta.verbose_name, |
825 | 826 |
"reason":result.reason} |
826 | 827 |
messages.error(request, msg, fail_silently=True) |
... | ... | |
1074 | 1075 |
return HttpResponseRedirect(post_save_redirect) |
1075 | 1076 |
except IntegrityError, e: |
1076 | 1077 |
logger.exception(e) |
1077 |
msg = _('Failed to join group.')
|
|
1078 |
msg = _(astakos_messages.GROUP_JOIN_FAILURE)
|
|
1078 | 1079 |
messages.error(request, msg) |
1079 | 1080 |
return group_search(request) |
1080 | 1081 |
|
... | ... | |
1088 | 1089 |
group__id=group_id, |
1089 | 1090 |
person=request.user) |
1090 | 1091 |
except Membership.DoesNotExist: |
1091 |
return HttpResponseBadRequest(_('Invalid membership.'))
|
|
1092 |
return HttpResponseBadRequest(_(astakos_messages.NOT_A_MEMBER))
|
|
1092 | 1093 |
if request.user in m.group.owner.all(): |
1093 |
return HttpResponseForbidden(_('Owner can not leave the group.'))
|
|
1094 |
return HttpResponseForbidden(_(astakos_messages.OWNER_CANNOT_LEAVE_GROUP))
|
|
1094 | 1095 |
return delete_object( |
1095 | 1096 |
request, |
1096 | 1097 |
model=Membership, |
... | ... | |
1109 | 1110 |
group__id=group_id, |
1110 | 1111 |
person__id=user_id) |
1111 | 1112 |
except Membership.DoesNotExist: |
1112 |
return HttpResponseBadRequest(_('Invalid membership.'))
|
|
1113 |
return HttpResponseBadRequest(_(astakos_messages.NOT_MEMBER))
|
|
1113 | 1114 |
else: |
1114 | 1115 |
if request.user not in m.group.owner.all(): |
1115 |
return HttpResponseForbidden(_('User is not a group owner.'))
|
|
1116 |
return HttpResponseForbidden(_(astakos_messages.NOT_OWNER))
|
|
1116 | 1117 |
func(request, m) |
1117 | 1118 |
return group_detail(request, group_id) |
1118 | 1119 |
return wrapper |
... | ... | |
1127 | 1128 |
try: |
1128 | 1129 |
membership.approve() |
1129 | 1130 |
realname = membership.person.realname |
1130 |
msg = _('%s has been successfully joined the group.' % realname)
|
|
1131 |
msg = _(astakos_messages.MEMBER_JOINED_GROUP) % locals()
|
|
1131 | 1132 |
messages.success(request, msg) |
1132 | 1133 |
except BaseException, e: |
1133 | 1134 |
logger.exception(e) |
1134 | 1135 |
realname = membership.person.realname |
1135 |
msg = _('Something went wrong during %s\'s approval.' % realname)
|
|
1136 |
msg = _(astakos_messages.GENERIC_ERROR)
|
|
1136 | 1137 |
messages.error(request, msg) |
1137 | 1138 |
|
1138 | 1139 |
|
... | ... | |
1143 | 1144 |
try: |
1144 | 1145 |
membership.disapprove() |
1145 | 1146 |
realname = membership.person.realname |
1146 |
msg = _('%s has been successfully removed from the group.' % realname)
|
|
1147 |
msg = MEMBER_REMOVED % realname
|
|
1147 | 1148 |
messages.success(request, msg) |
1148 | 1149 |
except BaseException, e: |
1149 | 1150 |
logger.exception(e) |
1150 |
msg = _('Something went wrong during %s\'s disapproval.' % realname)
|
|
1151 |
msg = _(astakos_messages.GENERIC_ERROR)
|
|
1151 | 1152 |
messages.error(request, msg) |
1152 | 1153 |
|
1153 | 1154 |
|
... | ... | |
1237 | 1238 |
status, data = r.result |
1238 | 1239 |
data = _clear_billing_data(data) |
1239 | 1240 |
if status != 200: |
1240 |
messages.error(request, _('Service response status: %d' % status))
|
|
1241 |
messages.error(request, _(astakos_messages.BILLING_ERROR) % status)
|
|
1241 | 1242 |
except: |
1242 | 1243 |
messages.error(request, r.result) |
1243 | 1244 |
|
Also available in: Unified diff