Revision eb9ff37a snf-astakos-app/astakos/im/functions.py
b/snf-astakos-app/astakos/im/functions.py | ||
---|---|---|
165 | 165 |
return _send_admin_notification(template_name, dictionary, subject=subject) |
166 | 166 |
|
167 | 167 |
|
168 |
def send_group_creation_notification(template_name, dictionary=None): |
|
169 |
group = dictionary.get('group') |
|
170 |
if not group: |
|
171 |
return |
|
172 |
subject = _(GROUP_CREATION_SUBJECT) % {'group':group.get('name', '')} |
|
173 |
return _send_admin_notification(template_name, dictionary, subject=subject) |
|
174 |
|
|
175 |
|
|
176 | 168 |
def send_helpdesk_notification(user, template_name='im/helpdesk_notification.txt'): |
177 | 169 |
""" |
178 | 170 |
Send email to DEFAULT_CONTACT_EMAIL to notify for a new user activation. |
... | ... | |
425 | 417 |
raise IOError( |
426 | 418 |
_(astakos_messages.UNKNOWN_PROJECT_APPLICATION_ID) % project_application_id) |
427 | 419 |
|
420 |
def get_project_by_id(project_id): |
|
421 |
try: |
|
422 |
return Project.objects.get(id=project_id) |
|
423 |
except Project.DoesNotExist: |
|
424 |
raise IOError( |
|
425 |
_(astakos_messages.UNKNOWN_PROJECT_ID) % project_id) |
|
426 |
|
|
428 | 427 |
def get_user_by_id(user_id): |
429 | 428 |
try: |
430 | 429 |
return AstakosUser.objects.get(id=user_id) |
... | ... | |
623 | 622 |
notification.send() |
624 | 623 |
except NotificationError, e: |
625 | 624 |
logger.error(e.message) |
625 |
|
|
626 |
def terminate(project_id): |
|
627 |
project = get_project_by_id(project_id) |
|
628 |
project.set_termination_start_date() |
|
629 |
trigger_sync() |
|
630 |
project.set_termination_date() |
|
631 |
|
|
632 |
try: |
|
633 |
notification = build_notification( |
|
634 |
settings.SERVER_EMAIL, |
|
635 |
[project.application.owner.email], |
|
636 |
_(PROJECT_TERMINATION_SUBJECT) % project.__dict__, |
|
637 |
template='im/projects/project_termination_notification.txt', |
|
638 |
dictionary={'object':project.application} |
|
639 |
).send() |
|
640 |
except NotificationError, e: |
|
641 |
logger.error(e.message) |
|
642 |
|
|
643 |
def suspend(project_id): |
|
644 |
project = get_project_by_id(project_id) |
|
645 |
project.last_approval_date = None |
|
646 |
project.save() |
|
647 |
trigger_sync() |
|
648 |
|
|
649 |
try: |
|
650 |
notification = build_notification( |
|
651 |
settings.SERVER_EMAIL, |
|
652 |
[project.application.owner.email], |
|
653 |
_(PROJECT_SUSPENSION_SUBJECT) % project.__dict__, |
|
654 |
template='im/projects/project_suspension_notification.txt', |
|
655 |
dictionary={'object':project.application} |
|
656 |
).send() |
|
657 |
except NotificationError, e: |
|
658 |
logger.error(e.message) |
Also available in: Unified diff