ASTAKOS_HELPDESK_NOTIFICATION_EMAIL_SUBJECT '%s alpha2 testing account activated (%%(user)s)' % SITENAME Account activation helpdesk notification email subject
ASTAKOS_EMAIL_CHANGE_EMAIL_SUBJECT 'Email change on %s alpha2 testing' % SITENAME Email change subject
ASTAKOS_PASSWORD_RESET_EMAIL_SUBJECT 'Password reset on %s alpha2 testing' % SITENAME Password change email subject
+ASTAKOS_PROJECT_CREATION_SUBJECT '%s alpha2 testing project application created (%%(name)s)' % SITENAME Project application creation subject
+ASTAKOS_PROJECT_APPROVED_SUBJECT '%s alpha2 testing project application approved (%%(name)s)' % SITENAME Project application approval subject
+ASTAKOS_PROJECT_TERMINATION_SUBJECT '%s alpha2 testing project terminated (%%(name)s)' % SITENAME Project termination subject
+ASTAKOS_PROJECT_SUSPENSION_SUBJECT '%s alpha2 testing project suspended (%%(name)s)' % SITENAME Project suspension subject
+ASTAKOS_PROJECT_MEMBERSHIP_CHANGE_SUBJECT '%s alpha2 testing project membership changed (%%(name)s)' % SITENAME Project membership change subject
ASTAKOS_QUOTAHOLDER_URL '' The quotaholder URI
e.g. ``http://localhost:8080/api/quotaholder/v``
except Http404:
raise CommandError('Invalid id')
else:
- if options['terminate']:
- p.terminate()
- elif options['suspend']:
- p.suspend()
- except BaseException, e:
- raise CommandError(e)
+ try:
+ if options['terminate']:
+ p.terminate()
+ elif options['suspend']:
+ p.suspend()
+ except BaseException, e:
+ raise CommandError(e)
DEFAULT_USER_LEVEL, INVITATIONS_PER_LEVEL,
AUTH_TOKEN_DURATION, BILLING_FIELDS,
EMAILCHANGE_ACTIVATION_DAYS, LOGGING_LEVEL,
- GROUP_CREATION_SUBJECT, SITENAME, SERVICES
+ SITENAME, SERVICES,
+ PROJECT_CREATION_SUBJECT, PROJECT_APPROVED_SUBJECT,
+ PROJECT_TERMINATION_SUBJECT, PROJECT_SUSPENSION_SUBJECT,
+ PROJECT_MEMBERSHIP_CHANGE_SUBJECT
)
from astakos.im.endpoints.qh import (
register_users, send_quota, register_resources
if commit:
application.save()
- else:
- notification = build_notification(
- settings.SERVER_EMAIL,
- [i[1] for i in settings.ADMINS],
- _(GROUP_CREATION_SUBJECT) % {'group':application.definition.name},
- _('A new project application identified by %(id)s has been submitted.') % application.__dict__
- )
- notification.send()
+ application.definition.resource_policies = resource_policies
+ # better implementation ???
+ if precursor_application:
+ try:
+ precursor = ProjectApplication.objects.get(id=precursor_application_id)
+ except:
+ pass
+ application.precursor_application = precursor
+ application.save()
+
+ notification = build_notification(
+ settings.SERVER_EMAIL,
+ [i[1] for i in settings.ADMINS],
+ _(PROJECT_CREATION_SUBJECT) % application.definition.__dict__,
+ template='im/projects/project_creation_notification.txt',
+ dictionary={'object':application}
+ )
+ notification.send()
return application
def approve(self, approval_user=None):
self.state = APPROVED
self.save()
-# self.definition.validate_name()
-
notification = build_notification(
settings.SERVER_EMAIL,
[self.owner.email],
- _('Project application has been approved on %s alpha2 testing' % SITENAME),
- _('Your application request %(id)s has been approved.') % self.id
+ _(PROJECT_APPROVED_SUBJECT) % self.definition.__dict__,
+ template='im/projects/project_approval_notification.txt',
+ dictionary={'object':self}
)
notification.send()
self.terminaton_date = datetime.now()
self.save()
- notification = build_notification(
- settings.SERVER_EMAIL,
- [self.application.owner.email],
- _('Project %(name)s has been terminated.') % self.definition.__dict__,
- _('Project %(name)s has been terminated.') % self.definition.__dict__
- )
- notification.send()
+ notification = build_notification(
+ settings.SERVER_EMAIL,
+ [self.application.owner.email],
+ _(PROJECT_TERMINATION_SUBJECT) % self.definition.__dict__,
+ template='im/projects/project_termination_notification.txt',
+ dictionary={'object':self.application}
+ )
+ notification.send()
def suspend(self):
self.last_approval_date = None
self.save()
+ self.sync()
notification = build_notification(
settings.SERVER_EMAIL,
[self.application.owner.email],
- _('Project %(name)s has been suspended.') % self.definition.__dict__,
- _('Project %(name)s has been suspended.') % self.definition.__dict__
+ _(PROJECT_SUSPENSION_SUBJECT) % self.definition.__dict__,
+ template='im/projects/project_suspension_notification.txt',
+ dictionary={'object':self.application}
)
notification.send()
notification = build_notification(
settings.SERVER_EMAIL,
[self.person.email],
- _('Your membership on project %(name)s has been accepted.') % self.project.definition.__dict__,
- _('Your membership on project %(name)s has been accepted.') % self.project.definition.__dict__
+ _(PROJECT_MEMBERSHIP_CHANGE_SUBJECT) % self.project.definition.__dict__,
+ template='im/projects/project_membership_change_notification.txt',
+ dictionary={'object':self.project.application, 'action':'accepted'}
).send()
self.sync()
notification = build_notification(
settings.SERVER_EMAIL,
[self.person.email],
- _('Your membership on project %(name)s has been rejected.') % self.project.definition.__dict__,
- _('Your membership on project %(name)s has been rejected.') % self.project.definition.__dict__
+ _(PROJECT_MEMBERSHIP_CHANGE_SUBJECT) % self.project.definition.__dict__,
+ template='im/projects/project_membership_change_notification.txt',
+ dictionary={'object':self.project.application, 'action':'rejected'}
).send()
def remove(self, request_user=None):
notification = build_notification(
settings.SERVER_EMAIL,
[self.person.email],
- _('Your membership on project %(name)s has been removed.') % self.project.definition.__dict__,
- _('Your membership on project %(name)s has been removed.') % self.project.definition.__dict__
+ _(PROJECT_MEMBERSHIP_CHANGE_SUBJECT) % self.project.definition.__dict__,
+ template='im/projects/project_membership_change_notification.txt',
+ dictionary={'object':self.project.application, 'action':'removed'}
).send()
self.sync()
from django.conf import settings
from django.core.mail import send_mail
from django.utils.translation import ugettext as _
+from django.template.loader import render_to_string
import astakos.im.messages as astakos_messages
logger = logging.getLogger(__name__)
-def build_notification(sender, recipients, subject, message):
- return EmailNotification(sender, recipients, subject, message)
+def build_notification(
+ sender, recipients, subject, message=None, template=None, dictionary=None
+):
+ return EmailNotification(
+ sender, recipients, subject, message, template, dictionary
+ )
class Notification(object):
- def __init__(self, sender, recipients, subject, message):
+ def __init__(
+ self, sender, recipients, subject,
+ message=None, template=None, dictionary=None
+ ):
+ if not message and not template:
+ raise InputError('message and template cannot be both None.')
+ dictionary = dictionary or {}
self.sender = sender
self.recipients = recipients
self.subject = subject
- self.message = message
+ self.message = message or render_to_string(template, dictionary)
def send(self):
pass
ACCOUNT_CREATION_SUBJECT = getattr(
settings, 'ASTAKOS_ACCOUNT_CREATION_SUBJECT',
'%s alpha2 testing account created (%%(user)s)' % SITENAME)
-GROUP_CREATION_SUBJECT = getattr(settings, 'ASTAKOS_GROUP_CREATION_SUBJECT',
- '%s alpha2 testing group created (%%(group)s)' % SITENAME)
+GROUP_CREATION_SUBJECT = getattr(
+ settings, 'ASTAKOS_GROUP_CREATION_SUBJECT',
+ '%s alpha2 testing group created (%%(group)s)' % SITENAME)
HELPDESK_NOTIFICATION_EMAIL_SUBJECT = getattr(
settings, 'ASTAKOS_HELPDESK_NOTIFICATION_EMAIL_SUBJECT',
'%s alpha2 testing account activated (%%(user)s)' % SITENAME)
PASSWORD_RESET_EMAIL_SUBJECT = getattr(
settings, 'ASTAKOS_PASSWORD_RESET_EMAIL_SUBJECT',
'Password reset on %s alpha2 testing' % SITENAME)
+PROJECT_CREATION_SUBJECT = getattr(
+ settings, 'ASTAKOS_PROJECT_CREATION_SUBJECT',
+ '%s alpha2 testing project application created (%%(name)s)' % SITENAME)
+PROJECT_APPROVED_SUBJECT = getattr(
+ settings, 'ASTAKOS_PROJECT_APPROVED_SUBJECT',
+ '%s alpha2 testing project application approved (%%(name)s)' % SITENAME)
+PROJECT_TERMINATION_SUBJECT = getattr(
+ settings, 'ASTAKOS_PROJECT_TERMINATION_SUBJECT',
+ '%s alpha2 testing project terminated (%%(name)s)' % SITENAME)
+PROJECT_SUSPENSION_SUBJECT = getattr(
+ settings, 'ASTAKOS_PROJECT_SUSPENSION_SUBJECT',
+ '%s alpha2 testing project suspended (%%(name)s)' % SITENAME)
+PROJECT_MEMBERSHIP_CHANGE_SUBJECT = getattr(
+ settings, 'ASTAKOS_PROJECT_MEMBERSHIP_CHANGE_SUBJECT',
+ '%s alpha2 testing project membership changed (%%(name)s)' % SITENAME)
# Set the quota holder component URI
QUOTAHOLDER_URL = getattr(settings, 'ASTAKOS_QUOTAHOLDER_URL', '')
'django.contrib.sessions',
'django.contrib.messages',
# 'djcelery',
-# 'debug_toolbar',
+ 'debug_toolbar',
]
context_processors = [
'synnefo.lib.middleware.LoggingConfigMiddleware',
'synnefo.lib.middleware.SecureMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
-# 'debug_toolbar.middleware.DebugToolbarMiddleware',
+ 'debug_toolbar.middleware.DebugToolbarMiddleware',
]
loggers = {
BROKER_URL = ''
-# INTERNAL_IPS = ('127.0.0.1',)
+INTERNAL_IPS = ('127.0.0.1',)
--- /dev/null
+--- A translation in English follows ---
+
+Η αίτησή σας για το project {{object.definition.name}} έχει γίνει δεκτή.
+
+--
+
+Your project application request ({{object.definition.name}}) has been approved.
\ No newline at end of file
--- /dev/null
+--- A translation in English follows ---
+
+Έχει δημιουργηθεί το παρακάτω project:
+
+Id: {{object.id}}
+Name: {{object.definition.name}}
+Issue date: {{object.issue_date|date:"d/m/Y"}}
+Start date: {{object.definition.start_date|date:"d/m/Y"}}
+End date: {{object.definition.end_date|date:"d/m/Y"}}
+Member Join Policy: {{object.definition.member_join_policy.policy}}
+Member Leave Policy: {{object.definition.member_leave_policy.policy}}
+Owner: {{object.owner}}
+Applicant: {{object.applicant}}
+Maximum participant number: {{object.definition.limit_on_members_number}}
+Precursor: {{object.precursor_application.id}}
+Policies:
+{% for p in object.definition.projectresourcegrant_set.all %}
+ {{p.resource}}: uplimit:{% if p.member_limit %}{{p.member_limit}}{% else %}inf{% endif %}
+{% endfor %}
+
+Για την ενεργοποίησή του μπορείτε να χρησιμοποιήσετε το command line εργαλείο:
+snf-manage project-application-approve <id>
+--
+
+The following project has been created:
+
+
+Id: {{object.id}}
+Name: {{object.definition.name}}
+Issue date: {{object.issue_date|date:"d/m/Y"}}
+Start date: {{object.definition.start_date|date:"d/m/Y"}}
+End date: {{object.definition.end_date|date:"d/m/Y"}}
+Member Join Policy: {{object.definition.member_join_policy.policy}}
+Member Leave Policy: {{object.definition.member_leave_policy.policy}}
+Owner: {{object.owner}}
+Applicant: {{object.applicant}}
+Maximum participant number: {{object.definition.limit_on_members_number}}
+Precursor: {{object.precursor_application.id}}
+Policies:
+{% for p in object.definition.projectresourcegrant_set.all %}
+ {{p.resource}}: uplimit:{% if p.member_limit %}{{p.member_limit}}{% else %}inf{% endif %}
+{% endfor %}
+
+For approving it you can use the command line tool:
+snf-manage project-application-approve <id>
--- /dev/null
+--- A translation in English follows ---
+
+{% if action == 'accepted' %}
+Η συμμετοχή σας στο project {{object.definition.name}} έχει γίνει δεκτή.
+{% else %}
+ {% if action == 'rejected' %}
+Η συμμετοχή σας στο project {{object.definition.name}} έχει απορριφθεί.
+ {% else %}
+Η συμμετοχή σας στο project {{object.definition.name}} έχει διαγραφεί.
+ {% endif %}
+{% endif %}
+--
+
+Your project membership ({{object.definition.name}}) has been {{action}}.
\ No newline at end of file
--- /dev/null
+--- A translation in English follows ---
+
+Tο project {{object.definition.name}} έχει ανασταλεί.
+
+--
+
+Your project application request ({{object.definition.name}}) has been suspended.
\ No newline at end of file
--- /dev/null
+--- A translation in English follows ---
+
+Το project {{object.definition.name}} έχει τερματιστεί.
+
+--
+
+Your project application request ({{object.definition.name}}) has been terminated.
\ No newline at end of file
#ASTAKOS_HELPDESK_NOTIFICATION_EMAIL_SUBJECT = '%s alpha2 testing account activated (%%(user)s)' % SITENAME
#ASTAKOS_EMAIL_CHANGE_EMAIL_SUBJECT = 'Email change on %s alpha2 testing' % SITENAME
#ASTAKOS_PASSWORD_RESET_EMAIL_SUBJECT = 'Password reset on %s alpha2 testing' % SITENAME
+#ASTAKOS_PROJECT_CREATION_SUBJECT = '%s alpha2 testing project application created (%%(name)s)' % SITENAME
+#ASTAKOS_PROJECT_APPROVED_SUBJECT = '%s alpha2 testing project application approved (%%(name)s)' % SITENAME
+#ASTAKOS_PROJECT_TERMINATION_SUBJECT = '%s alpha2 testing project terminated (%%(name)s)' % SITENAME
+#ASTAKOS_PROJECT_SUSPENSION_SUBJECT = '%s alpha2 testing project suspended (%%(name)s)' % SITENAME
+#ASTAKOS_PROJECT_MEMBERSHIP_CHANGE_SUBJECT = '%s alpha2 testing project membership changed (%%(name)s)' % SITENAME
# Set the quotaholder component URI and token
#ASTAKOS_QUOTAHOLDER_URL = ''