This commit is contained in:
Ross
2021-10-17 09:55:51 +01:00
parent 9039469eae
commit 3d1d2ea481
2 changed files with 14 additions and 3 deletions
@@ -54,15 +54,19 @@
{{ author }}, {{ author }},
{% endfor %} {% endfor %}
</div> </div>
{% if can_edit %}
<p><button id='button-edit-order'>Edit exam order</button></p> <p><button id='button-edit-order'>Edit exam order</button></p>
{% endif %}
<div> <div>
JSON creation time: {{exam.json_creation_time}} ({{exam.json_creation_time|date:"c"}}), JSON creation time: {{exam.json_creation_time}} ({{exam.json_creation_time|date:"c"}}),
JSON creation id: {{exam.exam_json_id}} JSON creation id: {{exam.exam_json_id}}
</div> </div>
<a href="{% url 'anatomy:exam_json' pk=exam.pk %}">JSON</a> <a href="{% url 'anatomy:exam_json' pk=exam.pk %}">JSON</a>
<a href="{% url 'anatomy:exam_json_recreate' pk=exam.pk %}">Refresh JSON cache</a> <a href="{% url 'anatomy:exam_json_recreate' pk=exam.pk %}">Refresh JSON cache</a>
{% if request.user.is_superuser %}
<button id='button-open-access'>Make questions open access</button> <button id='button-open-access'>Make questions open access</button>
<button id='button-closed-access'>Make questions closed access</button> <button id='button-closed-access'>Make questions closed access</button>
{% endif %}
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
+7
View File
@@ -203,6 +203,9 @@ class ExamViews(View, LoginRequiredMixin):
Returns: Returns:
[boolean]: True if the user has access [boolean]: True if the user has access
""" """
if user in self.exam.get_author_objects():
return True
if self.app_name == "rapids" and not user.groups.filter(name='rapid_checker').exists(): if self.app_name == "rapids" and not user.groups.filter(name='rapid_checker').exists():
return False return False
if self.app_name == "anatomy" and not user.groups.filter(name='anatomy_checker').exists(): if self.app_name == "anatomy" and not user.groups.filter(name='anatomy_checker').exists():
@@ -224,6 +227,10 @@ class ExamViews(View, LoginRequiredMixin):
Returns: Returns:
[boolean]: True if the user has access [boolean]: True if the user has access
""" """
# If a user is an exam author they should have acccess
if user in self.exam.get_author_objects():
return True
if self.app_name == "rapids" and not user.groups.filter(name='rapid_checker').exists(): if self.app_name == "rapids" and not user.groups.filter(name='rapid_checker').exists():
return False return False
if self.app_name == "anatomy" and not user.groups.filter(name='anatomy_checker').exists(): if self.app_name == "anatomy" and not user.groups.filter(name='anatomy_checker').exists():