Create Author mixin

This commit is contained in:
Ross
2024-02-05 09:34:47 +00:00
parent 1e16386e1e
commit 9e06cb45ca
5 changed files with 35 additions and 59 deletions
+2 -11
View File
@@ -4,6 +4,7 @@ import pathlib
from typing import Tuple
from django.http import Http404, HttpRequest
from generic.mixins import AuthorMixin
from rad.settings import REMOTE_URL
from django.db.models.fields.files import ImageField
from django.db.models.fields.related import ForeignKey
@@ -273,7 +274,7 @@ class Structure(SynMixin, models.Model):
@reversion.register
class Case(models.Model):
class Case(models.Model, AuthorMixin):
# class SubspecialtyChoices(models.TextChoices):
# BREAST = "BR", _("Breast")
# CARDIAC = "CA", _("Cardiac")
@@ -369,16 +370,6 @@ class Case(models.Model):
def get_absolute_url(self):
return reverse("atlas:case_detail", kwargs={"pk": self.pk})
def get_authors(self):
"""Returns a comma seperated text list of authors"""
authors = ", ".join([i.username for i in self.author.all()])
return authors
def get_author_objects(self):
"""Returns a comma seperated text list of authors"""
authors = [i for i in self.author.all()]
return authors
def get_link(self):
# return f"{self.pk}: {self.title}"
return format_html("<a href='{}'>{}</a>", self.get_absolute_url(), str(self))