some refactoring and atlas improvements
This commit is contained in:
+15
-42
@@ -2,7 +2,7 @@ import json
|
||||
import os
|
||||
import pathlib
|
||||
|
||||
from django.http import Http404
|
||||
from django.http import Http404, HttpRequest
|
||||
from rad.settings import REMOTE_URL
|
||||
from django.db.models.fields.files import ImageField
|
||||
from django.db.models.fields.related import ForeignKey
|
||||
@@ -46,6 +46,7 @@ from generic.models import (
|
||||
SeriesBase,
|
||||
SeriesImageBase,
|
||||
Modality,
|
||||
UserUserGroup,
|
||||
)
|
||||
|
||||
# from generic.models import Examination, Site, Condition, Sign
|
||||
@@ -413,18 +414,8 @@ class Series(SeriesBase):
|
||||
class CaseCollection(ExamCollectionGenericBase):
|
||||
app_name = "atlas"
|
||||
|
||||
name = models.CharField(max_length=255, unique=True)
|
||||
|
||||
cases = models.ManyToManyField(Case, through="CaseDetail")
|
||||
|
||||
publish_results = models.BooleanField(
|
||||
help_text="If a collection should published", default=False
|
||||
)
|
||||
|
||||
active = models.BooleanField(
|
||||
help_text="If a collection should be available", default=True
|
||||
)
|
||||
|
||||
show_title_pre = models.BooleanField(
|
||||
default=False, help_text="Show the title of the cases (pre exam)"
|
||||
)
|
||||
@@ -461,20 +452,31 @@ class CaseCollection(ExamCollectionGenericBase):
|
||||
settings.AUTH_USER_MODEL,
|
||||
blank=True,
|
||||
help_text="Author of the collection",
|
||||
# related_name="atlas_authored_cases",
|
||||
related_name="casecollection_authored_cases",
|
||||
)
|
||||
|
||||
valid_cid_users = models.ManyToManyField(
|
||||
CidUser, blank=True, related_name="casecollection_exams"
|
||||
)
|
||||
|
||||
valid_user_users = models.ManyToManyField(
|
||||
settings.AUTH_USER_MODEL, blank=True, related_name="user_casecollection_exams"
|
||||
)
|
||||
|
||||
cid_user_groups = models.ManyToManyField(
|
||||
CidUserGroup,
|
||||
blank=True,
|
||||
help_text="These groups define which candidates are able to be added to the exams/collection.",
|
||||
related_name="casecollection_cid_user_groups",
|
||||
)
|
||||
|
||||
user_user_groups = models.ManyToManyField(
|
||||
UserUserGroup,
|
||||
blank=True,
|
||||
help_text="These groups define which candidates are able to be added to the exams/collection.",
|
||||
related_name="casecollection_user_user_groups",
|
||||
)
|
||||
|
||||
archive = models.BooleanField(default=False)
|
||||
exam_mode = models.BooleanField(default=False)
|
||||
|
||||
# This should override the publish setting
|
||||
@@ -483,11 +485,6 @@ class CaseCollection(ExamCollectionGenericBase):
|
||||
help_text="If true allows users self complete and review cases in a self directed way.",
|
||||
)
|
||||
|
||||
open_access = models.BooleanField(
|
||||
help_text="If the exam is freely accessible (to view and edit on the test system)",
|
||||
default=False,
|
||||
)
|
||||
|
||||
class COLLECTION_TYPE_CHOICES(models.TextChoices):
|
||||
REVIEW = (
|
||||
"REV",
|
||||
@@ -525,30 +522,6 @@ class CaseCollection(ExamCollectionGenericBase):
|
||||
return False
|
||||
|
||||
|
||||
def check_user_can_take(self, cid, passcode, request):
|
||||
"""
|
||||
Helper to check if a user is allowed to access a collection
|
||||
|
||||
Args:
|
||||
cid (_type_): _description_
|
||||
passcode (_type_): _description_
|
||||
request (_type_): _description_
|
||||
|
||||
Raises:
|
||||
Http404: If user does not have access
|
||||
"""
|
||||
if not self.active:
|
||||
raise Http404("Exam not found")
|
||||
|
||||
#if self.collection_is_review():
|
||||
# return True
|
||||
|
||||
#if not self.self_review:
|
||||
|
||||
if not self.check_cid_user(cid, passcode, request):
|
||||
raise Http404("Error accessing exam")
|
||||
|
||||
|
||||
class CaseDetail(models.Model):
|
||||
case = models.ForeignKey(Case, on_delete=models.CASCADE)
|
||||
collection = models.ForeignKey(CaseCollection, on_delete=models.CASCADE)
|
||||
|
||||
Reference in New Issue
Block a user