Revision c4d1b547
b/snf-astakos-app/README | ||
---|---|---|
90 | 90 |
ASTAKOS_HELPDESK_NOTIFICATION_EMAIL_SUBJECT '%s alpha2 testing account activated (%%(user)s)' % SITENAME Account activation helpdesk notification email subject |
91 | 91 |
ASTAKOS_EMAIL_CHANGE_EMAIL_SUBJECT 'Email change on %s alpha2 testing' % SITENAME Email change subject |
92 | 92 |
ASTAKOS_PASSWORD_RESET_EMAIL_SUBJECT 'Password reset on %s alpha2 testing' % SITENAME Password change email subject |
93 |
ASTAKOS_PROJECT_CREATION_SUBJECT '%s alpha2 testing project application created (%%(name)s)' % SITENAME Project application creation subject |
|
94 |
ASTAKOS_PROJECT_APPROVED_SUBJECT '%s alpha2 testing project application approved (%%(name)s)' % SITENAME Project application approval subject |
|
95 |
ASTAKOS_PROJECT_TERMINATION_SUBJECT '%s alpha2 testing project terminated (%%(name)s)' % SITENAME Project termination subject |
|
96 |
ASTAKOS_PROJECT_SUSPENSION_SUBJECT '%s alpha2 testing project suspended (%%(name)s)' % SITENAME Project suspension subject |
|
97 |
ASTAKOS_PROJECT_MEMBERSHIP_CHANGE_SUBJECT '%s alpha2 testing project membership changed (%%(name)s)' % SITENAME Project membership change subject |
|
93 | 98 |
|
94 | 99 |
ASTAKOS_QUOTAHOLDER_URL '' The quotaholder URI |
95 | 100 |
e.g. ``http://localhost:8080/api/quotaholder/v`` |
b/snf-astakos-app/astakos/im/management/commands/project-update.py | ||
---|---|---|
75 | 75 |
except Http404: |
76 | 76 |
raise CommandError('Invalid id') |
77 | 77 |
else: |
78 |
if options['terminate']: |
|
79 |
p.terminate() |
|
80 |
elif options['suspend']: |
|
81 |
p.suspend() |
|
82 |
except BaseException, e: |
|
83 |
raise CommandError(e) |
|
78 |
try: |
|
79 |
if options['terminate']: |
|
80 |
p.terminate() |
|
81 |
elif options['suspend']: |
|
82 |
p.suspend() |
|
83 |
except BaseException, e: |
|
84 |
raise CommandError(e) |
b/snf-astakos-app/astakos/im/models.py | ||
---|---|---|
69 | 69 |
DEFAULT_USER_LEVEL, INVITATIONS_PER_LEVEL, |
70 | 70 |
AUTH_TOKEN_DURATION, BILLING_FIELDS, |
71 | 71 |
EMAILCHANGE_ACTIVATION_DAYS, LOGGING_LEVEL, |
72 |
GROUP_CREATION_SUBJECT, SITENAME, SERVICES |
|
72 |
SITENAME, SERVICES, |
|
73 |
PROJECT_CREATION_SUBJECT, PROJECT_APPROVED_SUBJECT, |
|
74 |
PROJECT_TERMINATION_SUBJECT, PROJECT_SUSPENSION_SUBJECT, |
|
75 |
PROJECT_MEMBERSHIP_CHANGE_SUBJECT |
|
73 | 76 |
) |
74 | 77 |
from astakos.im.endpoints.qh import ( |
75 | 78 |
register_users, send_quota, register_resources |
... | ... | |
1227 | 1230 |
|
1228 | 1231 |
if commit: |
1229 | 1232 |
application.save() |
1230 |
else: |
|
1231 |
notification = build_notification( |
|
1232 |
settings.SERVER_EMAIL, |
|
1233 |
[i[1] for i in settings.ADMINS], |
|
1234 |
_(GROUP_CREATION_SUBJECT) % {'group':application.definition.name}, |
|
1235 |
_('A new project application identified by %(id)s has been submitted.') % application.__dict__ |
|
1236 |
) |
|
1237 |
notification.send() |
|
1233 |
application.definition.resource_policies = resource_policies |
|
1234 |
# better implementation ??? |
|
1235 |
if precursor_application: |
|
1236 |
try: |
|
1237 |
precursor = ProjectApplication.objects.get(id=precursor_application_id) |
|
1238 |
except: |
|
1239 |
pass |
|
1240 |
application.precursor_application = precursor |
|
1241 |
application.save() |
|
1242 |
|
|
1243 |
notification = build_notification( |
|
1244 |
settings.SERVER_EMAIL, |
|
1245 |
[i[1] for i in settings.ADMINS], |
|
1246 |
_(PROJECT_CREATION_SUBJECT) % application.definition.__dict__, |
|
1247 |
template='im/projects/project_creation_notification.txt', |
|
1248 |
dictionary={'object':application} |
|
1249 |
) |
|
1250 |
notification.send() |
|
1238 | 1251 |
return application |
1239 | 1252 |
|
1240 | 1253 |
def approve(self, approval_user=None): |
... | ... | |
1280 | 1293 |
self.state = APPROVED |
1281 | 1294 |
self.save() |
1282 | 1295 |
|
1283 |
# self.definition.validate_name() |
|
1284 |
|
|
1285 | 1296 |
notification = build_notification( |
1286 | 1297 |
settings.SERVER_EMAIL, |
1287 | 1298 |
[self.owner.email], |
1288 |
_('Project application has been approved on %s alpha2 testing' % SITENAME), |
|
1289 |
_('Your application request %(id)s has been approved.') % self.id |
|
1299 |
_(PROJECT_APPROVED_SUBJECT) % self.definition.__dict__, |
|
1300 |
template='im/projects/project_approval_notification.txt', |
|
1301 |
dictionary={'object':self} |
|
1290 | 1302 |
) |
1291 | 1303 |
notification.send() |
1292 | 1304 |
|
... | ... | |
1445 | 1457 |
self.terminaton_date = datetime.now() |
1446 | 1458 |
self.save() |
1447 | 1459 |
|
1448 |
notification = build_notification( |
|
1449 |
settings.SERVER_EMAIL, |
|
1450 |
[self.application.owner.email], |
|
1451 |
_('Project %(name)s has been terminated.') % self.definition.__dict__, |
|
1452 |
_('Project %(name)s has been terminated.') % self.definition.__dict__ |
|
1453 |
) |
|
1454 |
notification.send() |
|
1460 |
notification = build_notification( |
|
1461 |
settings.SERVER_EMAIL, |
|
1462 |
[self.application.owner.email], |
|
1463 |
_(PROJECT_TERMINATION_SUBJECT) % self.definition.__dict__, |
|
1464 |
template='im/projects/project_termination_notification.txt', |
|
1465 |
dictionary={'object':self.application} |
|
1466 |
) |
|
1467 |
notification.send() |
|
1455 | 1468 |
|
1456 | 1469 |
def suspend(self): |
1457 | 1470 |
self.last_approval_date = None |
1458 | 1471 |
self.save() |
1472 |
self.sync() |
|
1459 | 1473 |
notification = build_notification( |
1460 | 1474 |
settings.SERVER_EMAIL, |
1461 | 1475 |
[self.application.owner.email], |
1462 |
_('Project %(name)s has been suspended.') % self.definition.__dict__, |
|
1463 |
_('Project %(name)s has been suspended.') % self.definition.__dict__ |
|
1476 |
_(PROJECT_SUSPENSION_SUBJECT) % self.definition.__dict__, |
|
1477 |
template='im/projects/project_suspension_notification.txt', |
|
1478 |
dictionary={'object':self.application} |
|
1464 | 1479 |
) |
1465 | 1480 |
notification.send() |
1466 | 1481 |
|
... | ... | |
1502 | 1517 |
notification = build_notification( |
1503 | 1518 |
settings.SERVER_EMAIL, |
1504 | 1519 |
[self.person.email], |
1505 |
_('Your membership on project %(name)s has been accepted.') % self.project.definition.__dict__, |
|
1506 |
_('Your membership on project %(name)s has been accepted.') % self.project.definition.__dict__ |
|
1520 |
_(PROJECT_MEMBERSHIP_CHANGE_SUBJECT) % self.project.definition.__dict__, |
|
1521 |
template='im/projects/project_membership_change_notification.txt', |
|
1522 |
dictionary={'object':self.project.application, 'action':'accepted'} |
|
1507 | 1523 |
).send() |
1508 | 1524 |
self.sync() |
1509 | 1525 |
|
... | ... | |
1530 | 1546 |
notification = build_notification( |
1531 | 1547 |
settings.SERVER_EMAIL, |
1532 | 1548 |
[self.person.email], |
1533 |
_('Your membership on project %(name)s has been rejected.') % self.project.definition.__dict__, |
|
1534 |
_('Your membership on project %(name)s has been rejected.') % self.project.definition.__dict__ |
|
1549 |
_(PROJECT_MEMBERSHIP_CHANGE_SUBJECT) % self.project.definition.__dict__, |
|
1550 |
template='im/projects/project_membership_change_notification.txt', |
|
1551 |
dictionary={'object':self.project.application, 'action':'rejected'} |
|
1535 | 1552 |
).send() |
1536 | 1553 |
|
1537 | 1554 |
def remove(self, request_user=None): |
... | ... | |
1558 | 1575 |
notification = build_notification( |
1559 | 1576 |
settings.SERVER_EMAIL, |
1560 | 1577 |
[self.person.email], |
1561 |
_('Your membership on project %(name)s has been removed.') % self.project.definition.__dict__, |
|
1562 |
_('Your membership on project %(name)s has been removed.') % self.project.definition.__dict__ |
|
1578 |
_(PROJECT_MEMBERSHIP_CHANGE_SUBJECT) % self.project.definition.__dict__, |
|
1579 |
template='im/projects/project_membership_change_notification.txt', |
|
1580 |
dictionary={'object':self.project.application, 'action':'removed'} |
|
1563 | 1581 |
).send() |
1564 | 1582 |
self.sync() |
1565 | 1583 |
|
b/snf-astakos-app/astakos/im/notifications.py | ||
---|---|---|
39 | 39 |
from django.conf import settings |
40 | 40 |
from django.core.mail import send_mail |
41 | 41 |
from django.utils.translation import ugettext as _ |
42 |
from django.template.loader import render_to_string |
|
42 | 43 |
|
43 | 44 |
import astakos.im.messages as astakos_messages |
44 | 45 |
|
45 | 46 |
logger = logging.getLogger(__name__) |
46 | 47 |
|
47 |
def build_notification(sender, recipients, subject, message): |
|
48 |
return EmailNotification(sender, recipients, subject, message) |
|
48 |
def build_notification( |
|
49 |
sender, recipients, subject, message=None, template=None, dictionary=None |
|
50 |
): |
|
51 |
return EmailNotification( |
|
52 |
sender, recipients, subject, message, template, dictionary |
|
53 |
) |
|
49 | 54 |
|
50 | 55 |
class Notification(object): |
51 |
def __init__(self, sender, recipients, subject, message): |
|
56 |
def __init__( |
|
57 |
self, sender, recipients, subject, |
|
58 |
message=None, template=None, dictionary=None |
|
59 |
): |
|
60 |
if not message and not template: |
|
61 |
raise InputError('message and template cannot be both None.') |
|
62 |
dictionary = dictionary or {} |
|
52 | 63 |
self.sender = sender |
53 | 64 |
self.recipients = recipients |
54 | 65 |
self.subject = subject |
55 |
self.message = message |
|
66 |
self.message = message or render_to_string(template, dictionary)
|
|
56 | 67 |
|
57 | 68 |
def send(self): |
58 | 69 |
pass |
b/snf-astakos-app/astakos/im/settings.py | ||
---|---|---|
117 | 117 |
ACCOUNT_CREATION_SUBJECT = getattr( |
118 | 118 |
settings, 'ASTAKOS_ACCOUNT_CREATION_SUBJECT', |
119 | 119 |
'%s alpha2 testing account created (%%(user)s)' % SITENAME) |
120 |
GROUP_CREATION_SUBJECT = getattr(settings, 'ASTAKOS_GROUP_CREATION_SUBJECT', |
|
121 |
'%s alpha2 testing group created (%%(group)s)' % SITENAME) |
|
120 |
GROUP_CREATION_SUBJECT = getattr( |
|
121 |
settings, 'ASTAKOS_GROUP_CREATION_SUBJECT', |
|
122 |
'%s alpha2 testing group created (%%(group)s)' % SITENAME) |
|
122 | 123 |
HELPDESK_NOTIFICATION_EMAIL_SUBJECT = getattr( |
123 | 124 |
settings, 'ASTAKOS_HELPDESK_NOTIFICATION_EMAIL_SUBJECT', |
124 | 125 |
'%s alpha2 testing account activated (%%(user)s)' % SITENAME) |
... | ... | |
128 | 129 |
PASSWORD_RESET_EMAIL_SUBJECT = getattr( |
129 | 130 |
settings, 'ASTAKOS_PASSWORD_RESET_EMAIL_SUBJECT', |
130 | 131 |
'Password reset on %s alpha2 testing' % SITENAME) |
132 |
PROJECT_CREATION_SUBJECT = getattr( |
|
133 |
settings, 'ASTAKOS_PROJECT_CREATION_SUBJECT', |
|
134 |
'%s alpha2 testing project application created (%%(name)s)' % SITENAME) |
|
135 |
PROJECT_APPROVED_SUBJECT = getattr( |
|
136 |
settings, 'ASTAKOS_PROJECT_APPROVED_SUBJECT', |
|
137 |
'%s alpha2 testing project application approved (%%(name)s)' % SITENAME) |
|
138 |
PROJECT_TERMINATION_SUBJECT = getattr( |
|
139 |
settings, 'ASTAKOS_PROJECT_TERMINATION_SUBJECT', |
|
140 |
'%s alpha2 testing project terminated (%%(name)s)' % SITENAME) |
|
141 |
PROJECT_SUSPENSION_SUBJECT = getattr( |
|
142 |
settings, 'ASTAKOS_PROJECT_SUSPENSION_SUBJECT', |
|
143 |
'%s alpha2 testing project suspended (%%(name)s)' % SITENAME) |
|
144 |
PROJECT_MEMBERSHIP_CHANGE_SUBJECT = getattr( |
|
145 |
settings, 'ASTAKOS_PROJECT_MEMBERSHIP_CHANGE_SUBJECT', |
|
146 |
'%s alpha2 testing project membership changed (%%(name)s)' % SITENAME) |
|
131 | 147 |
|
132 | 148 |
# Set the quota holder component URI |
133 | 149 |
QUOTAHOLDER_URL = getattr(settings, 'ASTAKOS_QUOTAHOLDER_URL', '') |
b/snf-astakos-app/astakos/im/synnefo_settings.py | ||
---|---|---|
44 | 44 |
'django.contrib.sessions', |
45 | 45 |
'django.contrib.messages', |
46 | 46 |
# 'djcelery', |
47 |
# 'debug_toolbar',
|
|
47 |
'debug_toolbar', |
|
48 | 48 |
] |
49 | 49 |
|
50 | 50 |
context_processors = [ |
... | ... | |
69 | 69 |
'synnefo.lib.middleware.LoggingConfigMiddleware', |
70 | 70 |
'synnefo.lib.middleware.SecureMiddleware', |
71 | 71 |
'django.middleware.csrf.CsrfViewMiddleware', |
72 |
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
|
|
72 |
'debug_toolbar.middleware.DebugToolbarMiddleware', |
|
73 | 73 |
] |
74 | 74 |
|
75 | 75 |
loggers = { |
... | ... | |
97 | 97 |
|
98 | 98 |
BROKER_URL = '' |
99 | 99 |
|
100 |
# INTERNAL_IPS = ('127.0.0.1',) |
|
100 |
INTERNAL_IPS = ('127.0.0.1',) |
b/snf-astakos-app/astakos/im/templates/im/projects/project_approval_notification.txt | ||
---|---|---|
1 |
--- A translation in English follows --- |
|
2 |
|
|
3 |
Η αίτησή σας για το project {{object.definition.name}} έχει γίνει δεκτή. |
|
4 |
|
|
5 |
-- |
|
6 |
|
|
7 |
Your project application request ({{object.definition.name}}) has been approved. |
b/snf-astakos-app/astakos/im/templates/im/projects/project_creation_notification.txt | ||
---|---|---|
1 |
--- A translation in English follows --- |
|
2 |
|
|
3 |
Έχει δημιουργηθεί το παρακάτω project: |
|
4 |
|
|
5 |
Id: {{object.id}} |
|
6 |
Name: {{object.definition.name}} |
|
7 |
Issue date: {{object.issue_date|date:"d/m/Y"}} |
|
8 |
Start date: {{object.definition.start_date|date:"d/m/Y"}} |
|
9 |
End date: {{object.definition.end_date|date:"d/m/Y"}} |
|
10 |
Member Join Policy: {{object.definition.member_join_policy.policy}} |
|
11 |
Member Leave Policy: {{object.definition.member_leave_policy.policy}} |
|
12 |
Owner: {{object.owner}} |
|
13 |
Applicant: {{object.applicant}} |
|
14 |
Maximum participant number: {{object.definition.limit_on_members_number}} |
|
15 |
Precursor: {{object.precursor_application.id}} |
|
16 |
Policies: |
|
17 |
{% for p in object.definition.projectresourcegrant_set.all %} |
|
18 |
{{p.resource}}: uplimit:{% if p.member_limit %}{{p.member_limit}}{% else %}inf{% endif %} |
|
19 |
{% endfor %} |
|
20 |
|
|
21 |
Για την ενεργοποίησή του μπορείτε να χρησιμοποιήσετε το command line εργαλείο: |
|
22 |
snf-manage project-application-approve <id> |
|
23 |
-- |
|
24 |
|
|
25 |
The following project has been created: |
|
26 |
|
|
27 |
|
|
28 |
Id: {{object.id}} |
|
29 |
Name: {{object.definition.name}} |
|
30 |
Issue date: {{object.issue_date|date:"d/m/Y"}} |
|
31 |
Start date: {{object.definition.start_date|date:"d/m/Y"}} |
|
32 |
End date: {{object.definition.end_date|date:"d/m/Y"}} |
|
33 |
Member Join Policy: {{object.definition.member_join_policy.policy}} |
|
34 |
Member Leave Policy: {{object.definition.member_leave_policy.policy}} |
|
35 |
Owner: {{object.owner}} |
|
36 |
Applicant: {{object.applicant}} |
|
37 |
Maximum participant number: {{object.definition.limit_on_members_number}} |
|
38 |
Precursor: {{object.precursor_application.id}} |
|
39 |
Policies: |
|
40 |
{% for p in object.definition.projectresourcegrant_set.all %} |
|
41 |
{{p.resource}}: uplimit:{% if p.member_limit %}{{p.member_limit}}{% else %}inf{% endif %} |
|
42 |
{% endfor %} |
|
43 |
|
|
44 |
For approving it you can use the command line tool: |
|
45 |
snf-manage project-application-approve <id> |
b/snf-astakos-app/astakos/im/templates/im/projects/project_membership_change_notification.txt | ||
---|---|---|
1 |
--- A translation in English follows --- |
|
2 |
|
|
3 |
{% if action == 'accepted' %} |
|
4 |
Η συμμετοχή σας στο project {{object.definition.name}} έχει γίνει δεκτή. |
|
5 |
{% else %} |
|
6 |
{% if action == 'rejected' %} |
|
7 |
Η συμμετοχή σας στο project {{object.definition.name}} έχει απορριφθεί. |
|
8 |
{% else %} |
|
9 |
Η συμμετοχή σας στο project {{object.definition.name}} έχει διαγραφεί. |
|
10 |
{% endif %} |
|
11 |
{% endif %} |
|
12 |
-- |
|
13 |
|
|
14 |
Your project membership ({{object.definition.name}}) has been {{action}}. |
b/snf-astakos-app/astakos/im/templates/im/projects/project_suspension_notification.txt | ||
---|---|---|
1 |
--- A translation in English follows --- |
|
2 |
|
|
3 |
Tο project {{object.definition.name}} έχει ανασταλεί. |
|
4 |
|
|
5 |
-- |
|
6 |
|
|
7 |
Your project application request ({{object.definition.name}}) has been suspended. |
b/snf-astakos-app/astakos/im/templates/im/projects/project_termination_notification.txt | ||
---|---|---|
1 |
--- A translation in English follows --- |
|
2 |
|
|
3 |
Το project {{object.definition.name}} έχει τερματιστεί. |
|
4 |
|
|
5 |
-- |
|
6 |
|
|
7 |
Your project application request ({{object.definition.name}}) has been terminated. |
b/snf-astakos-app/conf/20-snf-astakos-app-settings.conf | ||
---|---|---|
112 | 112 |
#ASTAKOS_HELPDESK_NOTIFICATION_EMAIL_SUBJECT = '%s alpha2 testing account activated (%%(user)s)' % SITENAME |
113 | 113 |
#ASTAKOS_EMAIL_CHANGE_EMAIL_SUBJECT = 'Email change on %s alpha2 testing' % SITENAME |
114 | 114 |
#ASTAKOS_PASSWORD_RESET_EMAIL_SUBJECT = 'Password reset on %s alpha2 testing' % SITENAME |
115 |
#ASTAKOS_PROJECT_CREATION_SUBJECT = '%s alpha2 testing project application created (%%(name)s)' % SITENAME |
|
116 |
#ASTAKOS_PROJECT_APPROVED_SUBJECT = '%s alpha2 testing project application approved (%%(name)s)' % SITENAME |
|
117 |
#ASTAKOS_PROJECT_TERMINATION_SUBJECT = '%s alpha2 testing project terminated (%%(name)s)' % SITENAME |
|
118 |
#ASTAKOS_PROJECT_SUSPENSION_SUBJECT = '%s alpha2 testing project suspended (%%(name)s)' % SITENAME |
|
119 |
#ASTAKOS_PROJECT_MEMBERSHIP_CHANGE_SUBJECT = '%s alpha2 testing project membership changed (%%(name)s)' % SITENAME |
|
115 | 120 |
|
116 | 121 |
# Set the quotaholder component URI and token |
117 | 122 |
#ASTAKOS_QUOTAHOLDER_URL = '' |
Also available in: Unified diff