This commit is contained in:
Ross
2022-01-06 12:49:37 +00:00
parent cbfa3ef0f3
commit f8f0232dc4
4 changed files with 41 additions and 10 deletions
+4 -1
View File
@@ -350,6 +350,9 @@ class CidUser(models.Model):
html_msg = f"""""" html_msg = f""""""
def email_results(self, resend=False, additional_emails=[]): def email_results(self, resend=False, additional_emails=[]):
if not self.internal_candidate:
return False, "Not internal candidate."
if self.results_email_sent and not resend: if self.results_email_sent and not resend:
return False, "Already sent." return False, "Already sent."
@@ -400,7 +403,7 @@ class CidUser(models.Model):
Please note this inbox is not monitored. Direct all enquiries to ... Please note this inbox is not monitored. Direct all enquiries to plh-tr.radiology-academy@nhs.net
""" """
try: try:
+12 -9
View File
@@ -1,14 +1,17 @@
{% extends 'generic/base.html' %} {% extends 'generic/base.html' %}
{% block content %} {% block content %}
<h2>Groups</h2> <h2>Groups</h2>
{% for group in groups %} {% for group in groups %}
<p>{{group.name}} <button class="email-button" data-emailurl="{% url 'generic:group_email' pk=group.pk %} <p>{{group.name}}
">Email candidate details</button> <button class="email-button" data-emailurl="{% url 'generic:group_email' pk=group.pk %}
<button class="email-button" data-emailurl="{% url 'generic:group_email_resend' pk=group.pk %} ">Email candidate details</button>
">Resend candidate details</button> <button class="email-button" data-emailurl="{% url 'generic:group_email_resend' pk=group.pk %}
</p> ">Resend candidate details</button>
{% endfor %} <button class="email-button" data-emailurl="{% url 'generic:group_email_results' pk=group.pk %}
">Email candidate results</button>
</p>
{% endfor %}
<script type="text/javascript"> <script type="text/javascript">
@@ -16,5 +19,5 @@
window.location = evt.currentTarget.dataset.emailurl; window.location = evt.currentTarget.dataset.emailurl;
}) })
</script> </script>
{% endblock %} {% endblock %}
+1
View File
@@ -30,6 +30,7 @@ urlpatterns = [
path("cids/manage/", views.CidUserView.as_view(), name="manage_cids"), path("cids/manage/", views.CidUserView.as_view(), name="manage_cids"),
path("cids/group/", views.group_view, name="group_view"), path("cids/group/", views.group_view, name="group_view"),
path("cids/group/<int:pk>/email", views.group_email, name="group_email"), path("cids/group/<int:pk>/email", views.group_email, name="group_email"),
path("cids/group/<int:pk>/email_results", views.group_email_results, name="group_email_results"),
path("cids/group/<int:pk>/email/resend", views.group_email_resend, name="group_email_resend"), path("cids/group/<int:pk>/email/resend", views.group_email_resend, name="group_email_resend"),
path("cids/create", views.manage_cid_users, name="manage_cid_users"), path("cids/create", views.manage_cid_users, name="manage_cid_users"),
] ]
+24
View File
@@ -1339,6 +1339,30 @@ def group_email(request, pk, resend=False):
{"sent": sent, "not_sent": not_sent, "users_count": users.count()}, {"sent": sent, "not_sent": not_sent, "users_count": users.count()},
) )
@login_required
@user_is_cid_user_manager
def group_email_results(request, pk, resend=False):
group = get_object_or_404(CidUserGroup, pk=pk)
if resend:
users = group.ciduser_set.filter()
else:
users = group.ciduser_set.filter(results_email_sent=False)
sent = []
not_sent = []
for u in users:
success, msg = u.email_results(resend=resend)
if success:
sent.append(u)
else:
not_sent.append((u, msg))
return render(
request,
"generic/group_emailed.html",
{"sent": sent, "not_sent": not_sent, "users_count": users.count()},
)
@login_required @login_required
@user_is_cid_user_manager @user_is_cid_user_manager