SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 4fceed8b authored by Jorran de Wit's avatar Jorran de Wit
Browse files

Send mails if stream is assigned

parent 33834df5
No related branches found
No related tags found
No related merge requests found
from common.utils import BaseMailUtil
def proofs_id_to_slug(id): def proofs_id_to_slug(id):
return int(id) + 8932 return int(id) + 8932
def proofs_slug_to_id(slug): def proofs_slug_to_id(slug):
return int(slug) - 8932 return int(slug) - 8932
class ProductionUtils(BaseMailUtil):
mail_sender = 'no-reply@scipost.org'
mail_sender_title = 'SciPost Production'
@classmethod
def email_assigned_invitation_officer(cls):
"""
Email invitation officer about his/her new assigned stream.
"""
cls._send_mail(cls, 'email_assigned_invitation_officer',
[cls._context['stream'].invitations_officer.user.email],
'SciPost: you have a new task')
@classmethod
def email_assigned_production_officer(cls):
"""
Email production officer about his/her new assigned stream.
"""
cls._send_mail(cls, 'email_assigned_production_officer',
[cls._context['stream'].officer.user.email],
'SciPost: you have a new task')
@classmethod
def email_assigned_supervisor(cls):
"""
Email production officer about his/her new assigned stream.
"""
cls._send_mail(cls, 'email_assigned_supervisor',
[cls._context['stream'].supervisor.user.email],
'SciPost: you have a new supervisory task')
...@@ -25,7 +25,7 @@ from .forms import ProductionEventForm, AssignOfficerForm, UserToOfficerForm,\ ...@@ -25,7 +25,7 @@ from .forms import ProductionEventForm, AssignOfficerForm, UserToOfficerForm,\
AssignInvitationsOfficerForm AssignInvitationsOfficerForm
from .permissions import is_production_user from .permissions import is_production_user
from .signals import notify_stream_status_change, notify_new_stream_assignment from .signals import notify_stream_status_change, notify_new_stream_assignment
from .utils import proofs_slug_to_id from .utils import proofs_slug_to_id, ProductionUtils
###################### ######################
...@@ -248,6 +248,11 @@ def add_officer(request, stream_id): ...@@ -248,6 +248,11 @@ def add_officer(request, stream_id):
noted_to=officer, noted_to=officer,
noted_by=request.user.production_user) noted_by=request.user.production_user)
event.save() event.save()
# Temp fix.
# TODO: Implement proper email
ProductionUtils.load({'stream': stream})
ProductionUtils.email_assigned_production_officer()
else: else:
for key, error in form.errors.items(): for key, error in form.errors.items():
messages.warning(request, error[0]) messages.warning(request, error[0])
...@@ -278,6 +283,11 @@ def add_invitations_officer(request, stream_id): ...@@ -278,6 +283,11 @@ def add_invitations_officer(request, stream_id):
noted_to=officer, noted_to=officer,
noted_by=request.user.production_user) noted_by=request.user.production_user)
event.save() event.save()
# Temp fix.
# TODO: Implement proper email
ProductionUtils.load({'stream': stream})
ProductionUtils.email_assigned_invitation_officer()
else: else:
for key, error in form.errors.items(): for key, error in form.errors.items():
messages.warning(request, error[0]) messages.warning(request, error[0])
...@@ -349,6 +359,11 @@ def add_supervisor(request, stream_id): ...@@ -349,6 +359,11 @@ def add_supervisor(request, stream_id):
assign_perm('can_work_for_stream', supervisor.user, stream) assign_perm('can_work_for_stream', supervisor.user, stream)
assign_perm('can_perform_supervisory_actions', supervisor.user, stream) assign_perm('can_perform_supervisory_actions', supervisor.user, stream)
# Temp fix.
# TODO: Implement proper email
ProductionUtils.load({'stream': stream})
ProductionUtils.email_assigned_supervisor()
else: else:
for key, error in form.errors.items(): for key, error in form.errors.items():
messages.warning(request, error[0]) messages.warning(request, error[0])
......
<p>
Dear {{ stream.invitations_officer.user.last }},
</p>
<p>
You are now assigned as Invitations Officer to the stream
</p>
<p>
{{ stream }}
<br>
Production Supervisor: {{ stream.supervisor }}
</p>
<p>
The stream will now be open for you on the <a href="https://scipost.org/{% url 'production:production' %}">Production page</a>.
</p>
<p><em>
This mail is automatically generated and therefore not signed.
</em></p>
Dear {{ stream.invitations_officer.user.last }},
\n
\n
You are now assigned as Invitations Officer to the stream
\n
\n
{{ stream }}
\n
Production Supervisor: {{ stream.supervisor }}
\n
\n
The stream will now be open for you on the Production page (https://scipost.org/{% url 'production:production' %}).
\n\n
This mail is automatically generated and therefore not signed.
<p>
Dear {{ stream.invitations_officer.user.last }},
</p>
<p>
You are now assigned as Production Officer to the stream
</p>
<p>
{{ stream }}
<br>
Production Supervisor: {{ stream.supervisor }}
</p>
<p>
The stream will now be open for you on the <a href="https://scipost.org/{% url 'production:production' %}">Production page</a>.
</p>
<p><em>
This mail is automatically generated and therefore not signed.
</em></p>
Dear {{ stream.invitations_officer.user.last }},
\n
\n
You are now assigned as Production Officer to the stream
\n
\n
{{ stream }}
\n
Production Supervisor: {{ stream.supervisor }}
\n
\n
The stream will now be open for you on the Production page (https://scipost.org/{% url 'production:production' %}).
\n\n
This mail is automatically generated and therefore not signed.
<p>
Dear {{ stream.invitations_officer.user.last }},
</p>
<p>
You are now assigned as Production Supervisor to the stream
</p>
<p>
{{ stream }}
</p>
<p>
The stream will now be open for you on the <a href="https://scipost.org/{% url 'production:production' %}">Production page</a>.
</p>
<p><em>
This mail is automatically generated and therefore not signed.
</em></p>
Dear {{ stream.invitations_officer.user.last }},
\n
\n
You are now assigned as Production Supervisor to the stream
\n
\n
{{ stream }}
\n
\n
The stream will now be open for you on the Production page (https://scipost.org/{% url 'production:production' %}).
\n\n
This mail is automatically generated and therefore not signed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment