This commit is contained in:
Ross
2021-02-05 17:12:13 +00:00
parent f1ebc48d9c
commit 1420d74393
9 changed files with 210 additions and 303 deletions
+23 -3
View File
@@ -102,6 +102,11 @@ class Long(models.Model):
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 __str__(self):
examinations = [series.get_examination() for series in self.series.all()]
return "{} : {}".format(self.history, ", ".join(examinations))
@@ -143,6 +148,15 @@ class LongSeries(models.Model):
def __str__(self):
return "{} : {} [{}]".format(self.get_examination(), self.description, self.long.pk)
def get_author_objects(self):
"""Returns a comma seperated text list of authors"""
if self.long:
authors = [i for i in self.long.author.all()]
else:
authors = []
return authors
def get_examination(self):
"""Returns a comma seperated text list of regions"""
return str(self.examination)
@@ -156,16 +170,22 @@ class LongSeries(models.Model):
return ",".join(images)
def get_thumbnail(self):
img = findMiddle(self.images.all()).image
images = self.images.all()
if len(images) < 1:
return 'No images', 0
img = findMiddle(images).image
thumbnailer = get_thumbnailer(img)
thumbnail = thumbnailer["exam-list"]
return thumbnail
return '<img src="/media/{}" />'.format(thumbnail), len(images)
def get_block(self):
examination = self.get_examination()
return format_html('<div>{}<br/><img src="/media/{}" /></div>', examination, self.get_thumbnail() )
thumb, image_number = self.get_thumbnail()
return format_html('<div>{}<br/>{}<br/>Images: {}</div>', examination, thumb, image_number )
#class LongImage(models.Model):
# long = models.ForeignKey(Long,