Revision 2ecbbc70
b/snf-astakos-app/README | ||
---|---|---|
50 | 50 |
ASTAKOS_INVITATIONS_PER_LEVEL {0:100, 1:2, 2:0, 3:0, 4:0} Number of user invitations per user level |
51 | 51 |
ASTAKOS_DEFAULT_FROM_EMAIL GRNET Cloud <no-reply\@grnet.gr> ``from`` parameter passed in ``django.core.mail.send_mail`` |
52 | 52 |
ASTAKOS_DEFAULT_CONTACT_EMAIL support\@cloud.grnet.gr Contact email |
53 |
ASTAKOS_DEFAULT_ADMIN_EMAIL support\@cloud.grnet.gr Administrator email to receive user creation notifications |
|
53 | 54 |
ASTAKOS_IM_MODULES ['local', 'twitter', 'shibboleth'] Signup modules |
54 | 55 |
ASTAKOS_FORCE_PROFILE_UPDATE True Force user profile verification |
55 | 56 |
ASTAKOS_INVITATIONS_ENABLED True Enable invitations |
b/snf-astakos-app/astakos/im/backends.py | ||
---|---|---|
48 | 48 |
from astakos.im.models import AstakosUser, Invitation |
49 | 49 |
from astakos.im.forms import * |
50 | 50 |
from astakos.im.util import get_invitation |
51 |
from astakos.im.settings import INVITATIONS_ENABLED, DEFAULT_CONTACT_EMAIL, DEFAULT_FROM_EMAIL, MODERATION_ENABLED, SITENAME, BASEURL |
|
51 |
from astakos.im.settings import INVITATIONS_ENABLED, DEFAULT_CONTACT_EMAIL, DEFAULT_FROM_EMAIL, MODERATION_ENABLED, SITENAME, BASEURL, DEFAULT_ADMIN_EMAIL
|
|
52 | 52 |
|
53 | 53 |
import socket |
54 | 54 |
import logging |
... | ... | |
143 | 143 |
return False |
144 | 144 |
|
145 | 145 |
@transaction.commit_manually |
146 |
def signup(self, form): |
|
146 |
def signup(self, form, admin_email_template_name='im/admin_notification.txt'):
|
|
147 | 147 |
""" |
148 | 148 |
Initially creates an inactive user account. If the user is preaccepted |
149 | 149 |
(has a valid invitation code) the user is activated and if the request |
... | ... | |
161 | 161 |
user.save() |
162 | 162 |
message = _('Registration completed. You can now login.') |
163 | 163 |
else: |
164 |
_send_notification(user, admin_email_template_name) |
|
164 | 165 |
message = _('Registration completed. You will receive an email upon your account\'s activation.') |
165 | 166 |
status = messages.SUCCESS |
166 | 167 |
except Invitation.DoesNotExist, e: |
... | ... | |
201 | 202 |
return globals()[formclass](initial_data, ip=self.request.META['REMOTE_ADDR']) |
202 | 203 |
|
203 | 204 |
@transaction.commit_manually |
204 |
def signup(self, form, email_template_name='im/activation_email.txt'): |
|
205 |
def signup(self, form, email_template_name='im/activation_email.txt', admin_email_template_name='im/admin_notification.txt'):
|
|
205 | 206 |
""" |
206 | 207 |
Creates an inactive user account and sends a verification email. |
207 | 208 |
|
... | ... | |
226 | 227 |
user = form.save() |
227 | 228 |
status = messages.SUCCESS |
228 | 229 |
if MODERATION_ENABLED: |
229 |
message = _('Registration completed. You will receive an email upon your account\'s activation.') |
|
230 |
try: |
|
231 |
_send_notification(user, admin_email_template_name) |
|
232 |
message = _('Registration completed. You will receive an email upon your account\'s activation.') |
|
233 |
except (SMTPException, socket.error) as e: |
|
234 |
status = messages.ERROR |
|
235 |
name = 'strerror' |
|
236 |
message = getattr(e, name) if hasattr(e, name) else e |
|
230 | 237 |
else: |
231 | 238 |
try: |
232 | 239 |
_send_verification(self.request, user, email_template_name) |
... | ... | |
256 | 263 |
sender = DEFAULT_FROM_EMAIL |
257 | 264 |
send_mail('%s account activation' % SITENAME, message, sender, [user.email]) |
258 | 265 |
logger.info('Sent activation %s', user) |
266 |
|
|
267 |
def _send_notification(user, template_name): |
|
268 |
message = render_to_string(template_name, { |
|
269 |
'user': user, |
|
270 |
'baseurl': BASEURL, |
|
271 |
'site_name': SITENAME, |
|
272 |
'support': DEFAULT_CONTACT_EMAIL}) |
|
273 |
sender = DEFAULT_FROM_EMAIL |
|
274 |
send_mail('%s account notification' % SITENAME, message, sender, [DEFAULT_ADMIN_EMAIL]) |
|
275 |
logger.info('Sent admin notification for user %s', user) |
b/snf-astakos-app/astakos/im/settings.py | ||
---|---|---|
21 | 21 |
# Address to use for outgoing emails |
22 | 22 |
DEFAULT_FROM_EMAIL = getattr(settings, 'ASTAKOS_DEFAULT_FROM_EMAIL', 'GRNET Cloud <no-reply@grnet.gr>') |
23 | 23 |
DEFAULT_CONTACT_EMAIL = getattr(settings, 'ASTAKOS_DEFAULT_CONTACT_EMAIL', 'support@cloud.grnet.gr') |
24 |
DEFAULT_ADMIN_EMAIL = getattr(settings, 'ASTAKOS_DEFAULT_ADMIN_EMAIL', 'support@cloud.grnet.gr') |
|
24 | 25 |
|
25 | 26 |
# Identity Management enabled modules |
26 | 27 |
IM_MODULES = getattr(settings, 'ASTAKOS_IM_MODULES', ['local', 'twitter', 'shibboleth']) |
b/snf-astakos-app/astakos/im/templates/im/admin_notification.txt | ||
---|---|---|
1 |
--- A translation in English follows --- |
|
2 |
|
|
3 |
Έχει δημιουργηθεί ο παρακάτω λογαριασμός: |
|
4 |
|
|
5 |
Email: {{user.email}} |
|
6 |
First name: {{user.first_name}} |
|
7 |
Last name: {{user.last_name}} |
|
8 |
Is active: {{user.is_active}} |
|
9 |
Level: {{user.level}} |
|
10 |
Invitations: {{user.invitations}} |
|
11 |
|
|
12 |
Για την ενεργοποίησή του μπορείτε να χρησιμοποιήσετε το command line εργαλείο snf-manage activateuser |
|
13 |
-- |
|
14 |
|
|
15 |
The following account has been created: |
|
16 |
|
|
17 |
Email: {{user.email}} |
|
18 |
First name: {{user.first_name}} |
|
19 |
Last name: {{user.last_name}} |
|
20 |
Is active: {{user.is_active}} |
|
21 |
Level: {{user.level}} |
|
22 |
Invitations: {{user.invitations}} |
|
23 |
|
|
24 |
Fot its activation you can use the command line tool snf-manage activateuser |
Also available in: Unified diff