Revision b6b88056 invitations/invitations.py
b/invitations/invitations.py | ||
---|---|---|
42 | 42 |
from django.template.loader import render_to_string |
43 | 43 |
from django.core.validators import validate_email |
44 | 44 |
from django.views.decorators.csrf import csrf_protect |
45 |
from django.utils.translation import ugettext as _ |
|
45 | 46 |
from synnefo.logic.email_send import send_async |
46 | 47 |
|
47 | 48 |
from synnefo.api.common import method_not_allowed |
... | ... | |
70 | 71 |
inv = add_invitation(request.user, name, email) |
71 | 72 |
send_invitation(inv) |
72 | 73 |
|
73 |
except Exception as e: |
|
74 |
try : |
|
75 |
errors += ["Invitation to %s <%s> not sent. Reason: %s" % |
|
76 |
(name, email, e.messages[0])] |
|
77 |
except: |
|
78 |
errors += ["Invitation to %s <%s> not sent. Reason: %s" % |
|
79 |
(name, email, e.message)] |
|
74 |
except ValidationError as e: |
|
75 |
errors += [_("Invitation to %s <%s> not sent. Reason: %s") % |
|
76 |
(name, email, e.messages[0])] |
|
77 |
except Exception: |
|
78 |
# generic error |
|
79 |
errors += [_("Invitation to %s <%s> cannot be sent.") % (name, email)] |
|
80 | 80 |
|
81 | 81 |
respose = None |
82 | 82 |
if errors: |
... | ... | |
93 | 93 |
|
94 | 94 |
def validate_name(name): |
95 | 95 |
if name is None or name.strip() == '' : |
96 |
raise ValidationError("Name is empty")
|
|
96 |
raise ValidationError(_("Name is empty"))
|
|
97 | 97 |
|
98 | 98 |
if name.find(' ') is -1: |
99 |
raise ValidationError("Name must contain at least one space")
|
|
99 |
raise ValidationError(_("Name must contain at least one space"))
|
|
100 | 100 |
|
101 | 101 |
return True |
102 | 102 |
|
Also available in: Unified diff