start taking more advantage of class based views
This commit is contained in:
+11
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user