start taking more advantage of class based views

This commit is contained in:
Ross
2024-03-11 11:08:35 +00:00
parent 78e4ed871e
commit 0cb38f5c31
27 changed files with 244 additions and 104 deletions
+11 -2
View File
@@ -26,7 +26,7 @@ from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver
from generic.mixins import AuthorMixin
from generic.mixins import AuthorMixin, QuestionMixin
from helpers.images import get_image_hash, pretty_print_dicom
from rad.settings import REMOTE_URL
from django.utils.html import format_html
@@ -154,7 +154,7 @@ class Site(models.Model):
return self.short_code
class QuestionBase(models.Model, AuthorMixin):
class QuestionBase(models.Model, AuthorMixin, QuestionMixin):
authors_only = models.BooleanField(
help_text="If true only question authors will be able to view.",
default=False,
@@ -580,6 +580,15 @@ class ExamOrCollectionGenericBase(models.Model, AuthorMixin):
class Meta:
abstract = True
def get_app_name(self):
raise NotImplementedError("You must implement get_app_name in the derived class")
def get_base_template(self):
return f"{self.get_app_name()}/exams.html"
def get_link_headers(self):
return "generic/exam_link_headers.html"
def check_user_can_edit(self, user: User):
if user.is_superuser:
return True