diff --git a/TODO.md b/TODO.md index 4cc1856c..b6e953c8 100644 --- a/TODO.md +++ b/TODO.md @@ -6,7 +6,10 @@ - Improve documentation - Test coverage +- Privacy policy +- Cookie policy # Future -- Clean up user results / score pages \ No newline at end of file +- Clean up user results / score pages +- Remove external javascript dependencies \ No newline at end of file diff --git a/anatomy/static/css/anatomy.css b/anatomy/static/css/anatomy.css index c6ab1581..80e5ef6d 100644 --- a/anatomy/static/css/anatomy.css +++ b/anatomy/static/css/anatomy.css @@ -902,4 +902,9 @@ tr:has(.errorlist){ .inline-form { display: inline-grid; +} + +form .submit-button { + margin-top: 10px; + margin-bottom: 10px; } \ No newline at end of file diff --git a/generic/forms.py b/generic/forms.py index 71ed4d1b..2404c47a 100755 --- a/generic/forms.py +++ b/generic/forms.py @@ -143,6 +143,22 @@ class QuestionNoteForm(ModelForm): class CidUserForm(ModelForm): + + class Meta: + model = CidUser + fields = [ + "passcode", + "active", + "internal_candidate", + "name", + "email", + "supervisor", + "login_email_sent", + "results_email_sent", + "group", + ] + +class CidUserExamForm(ModelForm): def __init__(self, *args, **kwargs): if kwargs.get("instance"): # We get the 'initial' keyword argument or initialize it @@ -169,7 +185,7 @@ class CidUserForm(ModelForm): ModelForm.__init__(self, *args, **kwargs) - super(CidUserForm, self).__init__(*args, **kwargs) + super(CidUserExamForm, self).__init__(*args, **kwargs) self.fields["physics_exams"] = ModelMultipleChoiceField( required=False, @@ -244,21 +260,9 @@ class CidUserForm(ModelForm): self.save_m2m() return instance - class Meta: model = CidUser - fields = [ - "passcode", - "active", - "internal_candidate", - "name", - "email", - "supervisor", - "login_email_sent", - "results_email_sent", - "group", - ] - + fields = [] class CidUserGroupModelChoiceField(ModelMultipleChoiceField): def label_from_instance(self, obj): diff --git a/generic/models.py b/generic/models.py index b9bab9ee..d2f2759e 100644 --- a/generic/models.py +++ b/generic/models.py @@ -1,3 +1,4 @@ +from collections import defaultdict from django.contrib.auth.mixins import LoginRequiredMixin from django.db import models from django.http import HttpRequest @@ -619,6 +620,13 @@ class CidUserExam(models.Model): # TODO switch to json field? results_emailed_status = models.CharField(max_length=255, blank=True) +CID_GROUP_EXAMS = ( + ("SBAs", "sba_cid_user_groups"), + ("Physics", "physics_cid_user_groups"), + ("Anatomy", "anatomy_cid_user_groups"), + ("Rapids", "rapid_cid_user_groups"), + ("Longs", "longs_cid_user_groups"), +) class CidUserGroup(models.Model): name = models.CharField(blank=True, max_length=50) @@ -633,8 +641,19 @@ class CidUserGroup(models.Model): s = ", ".join([f"{user.id} - {user.name}" for user in cid_users]) return s + def GetGroupExams(self): + exams = defaultdict(list) + for t, rel in CID_GROUP_EXAMS: + exam_rel = getattr(self, rel) + if exam_rel.exists(): + exams[t].extend(exam_rel.all()) + + return dict(exams) + + def get_absolute_url(self): return reverse("generic:cid_group_update", kwargs={"pk": self.pk}) + class UserUserGroup(models.Model): diff --git a/generic/templates/generic/cid_group_view_detail.html b/generic/templates/generic/cid_group_view_detail.html index 5582458f..31595e32 100755 --- a/generic/templates/generic/cid_group_view_detail.html +++ b/generic/templates/generic/cid_group_view_detail.html @@ -2,22 +2,36 @@ {% block content %}

Group: {{group.name}}

- Count: {{users|length}} - - - - - - {% for user in users %} - +

Users

+

Count: {{users|length}}

+ {% if users %} +
EmailCIDPasscode
{{user.email}}{{user.cid}}{{user.passcode}}
+ + + + {% for user in users %} + + {% endfor %} +
EmailCIDPasscode
{{user.email}}{{user.cid}}{{user.passcode}}
+ {% else %} + This group has no users. They can be created (or added) here + {% endif %} +

Exams

+ The group is currently associated with the following exams + {% with group.GetGroupExams as exam_map %} + {% for key, value in exam_map.items %} +

{{key}}

+ {% endfor %} - + {% endwith %} {% endblock %} diff --git a/generic/templates/generic/cid_view.html b/generic/templates/generic/cid_view.html index 65111150..cf9419d1 100644 --- a/generic/templates/generic/cid_view.html +++ b/generic/templates/generic/cid_view.html @@ -29,14 +29,34 @@

Add/Edit CID users

- - - +
+ Groups
+ +
+

Edit existing users

+

Users can be edited using the below buttons once they have been selected in the table. If you need to add a group to a user(s) select it above. Once a CID user is part of a group they can be added to exams via the exam candidate page.

+

Create New Users

+

New CID users can be created by the two below buttons. If you want to create blank users you can specify the number in the associated box and click the relevant button. If you have a list of email addresses you can enter them in the relevant box and click "Add New Users From Email" and a new user will be created for each user (you do not need to specify the number of users). Ideally you will have already created a CID user group that you can add to the newly generated users using the above select box.

+ +
+

or

+ + + +
+ Edit CID exams +

This should be done via the exams pages one via group management.

Select exams below to add user(s) to (or edit existing user(s)).

@@ -96,21 +116,11 @@
-
- Groups
- -
-

Create New Users

- -
- - + + + + +
{% endblock %} @@ -299,6 +309,9 @@ });