allow logged in users to assign user groups

This commit is contained in:
Ross
2023-06-19 13:31:45 +01:00
parent c9bbb5de50
commit 4e5c1c213d
2 changed files with 49 additions and 43 deletions
+4 -3
View File
@@ -63,12 +63,13 @@ class ExamFormMixin:
def __init__(self, *args, user, **kwargs) -> None: def __init__(self, *args, user, **kwargs) -> None:
super(ModelForm, self).__init__(*args, **kwargs) super(ModelForm, self).__init__(*args, **kwargs)
if user.is_superuser or user.groups.filter(name="cid_manager").exists(): if user.is_superuser or user.groups.filter(name="cid_user_manager").exists():
cid_user_group_queryset = CidUserGroup.objects.all() cid_user_group_queryset = CidUserGroup.objects.all()
user_user_group_queryset = UserUserGroup.objects.all()
else: else:
cid_user_group_queryset = CidUserGroup.objects.none() cid_user_group_queryset = CidUserGroup.objects.none()
user_user_group_queryset = UserUserGroup.objects.none()
user_user_group_queryset = UserUserGroup.objects.all()
self.fields["cid_user_groups"] = ModelMultipleChoiceField( self.fields["cid_user_groups"] = ModelMultipleChoiceField(
required=False, required=False,
queryset=cid_user_group_queryset, queryset=cid_user_group_queryset,
@@ -7,6 +7,9 @@
User answer scores are cached, if you update or change an answer you will need to <a href="{% url exam.app_name|add:':exam_scores_refresh' exam.pk %}">refresh the scores</a>. User answer scores are cached, if you update or change an answer you will need to <a href="{% url exam.app_name|add:':exam_scores_refresh' exam.pk %}">refresh the scores</a>.
{% endif %} {% endif %}
{% if missing_cids or missing_users %}
<details>
<summary>This exam has candidates / users with unsubmitted results</summary>
{% if missing_cids %} {% if missing_cids %}
<div class="alert alert-warning" role="alert"> <div class="alert alert-warning" role="alert">
The following CIDs results have not been submitted: The following CIDs results have not been submitted:
@@ -23,6 +26,8 @@
{% endfor %} {% endfor %}
</div> </div>
{% endif %} {% endif %}
</details>
{% endif %}
{% if unmarked %} {% if unmarked %}
<div class="alert alert-warning" role="alert"> <div class="alert alert-warning" role="alert">
The following questions need marking The following questions need marking