fix a few things
This commit is contained in:
+19
-8
@@ -116,6 +116,7 @@ class QuestionBase(models.Model):
|
||||
"""If this makes sense in the question/answer context override"""
|
||||
return None
|
||||
|
||||
|
||||
class SeriesImageBase(models.Model):
|
||||
position = models.IntegerField(default=0)
|
||||
upload_filename = models.CharField(max_length=255, blank=True)
|
||||
@@ -206,9 +207,9 @@ class SeriesBase(models.Model):
|
||||
thumbnailer = get_thumbnailer(img)
|
||||
thumbnail = thumbnailer["exam-list"]
|
||||
except InvalidImageFormatError:
|
||||
return format_html('<img title="{}" src="/static/not-found-image.jpg" />', img), len(
|
||||
images
|
||||
)
|
||||
return format_html(
|
||||
'<img title="{}" src="/static/not-found-image.jpg" />', img
|
||||
), len(images)
|
||||
return format_html('<img src="/media/{}" />', thumbnail), len(images)
|
||||
|
||||
def get_thumbnail_link(self):
|
||||
@@ -216,21 +217,30 @@ class SeriesBase(models.Model):
|
||||
"<a href='{}'>{}<a/>", self.get_absolute_url(), self.get_thumbnail()[0]
|
||||
)
|
||||
|
||||
def get_block(self):
|
||||
def get_block(self, series_number: None | int = None):
|
||||
examination = self.get_examination_full()
|
||||
thumb, image_number = self.get_thumbnail()
|
||||
|
||||
series_html = ""
|
||||
if series_number is not None:
|
||||
series_html = format_html(
|
||||
"<span class='series-block-series-number'>Series {}</span><br>",
|
||||
series_number,
|
||||
)
|
||||
|
||||
return format_html(
|
||||
"""<span>
|
||||
"""{}
|
||||
<span>
|
||||
<span class='series-block-examination'>{}</span><br/>
|
||||
<span class='series-block-thumbnail'>{}</span><br/>
|
||||
<span class='series-block-image-number'>Images: <span class='series-block-image-number-count'>{}</span></span>
|
||||
</span>""",
|
||||
series_html,
|
||||
examination,
|
||||
thumb,
|
||||
image_number,
|
||||
)
|
||||
|
||||
|
||||
def order_by_upload_filename(self):
|
||||
images = self.images.all()
|
||||
|
||||
@@ -311,12 +321,14 @@ class SeriesBase(models.Model):
|
||||
except pydicom.errors.InvalidDicomError:
|
||||
pass
|
||||
|
||||
|
||||
class ExamCollectionGenericBase(models.Model):
|
||||
"""Holds functions that relate to both case and other exams
|
||||
|
||||
e.g. user management
|
||||
|
||||
"""
|
||||
|
||||
# Is this actually used?
|
||||
cid_users = GenericRelation("generic.CidUserExam")
|
||||
|
||||
@@ -429,6 +441,7 @@ class ExamCollectionGenericBase(models.Model):
|
||||
content_type=content_type, object_id=self.pk, user_user=user_user
|
||||
)
|
||||
|
||||
|
||||
class ExamBase(ExamCollectionGenericBase):
|
||||
name = models.CharField(max_length=200, help_text="Name of the exam")
|
||||
# exam_questions = SortedManyToManyField(Long, related_name="exams", blank="true")
|
||||
@@ -490,7 +503,6 @@ class ExamBase(ExamCollectionGenericBase):
|
||||
|
||||
user_scores = models.JSONField(default=dict)
|
||||
|
||||
|
||||
exam_results_emailed = models.DateTimeField(default=None, null=True)
|
||||
|
||||
class Meta:
|
||||
@@ -547,7 +559,6 @@ class ExamBase(ExamCollectionGenericBase):
|
||||
def get_question_index(self, question):
|
||||
return list(self.exam_questions.all()).index(question)
|
||||
|
||||
|
||||
def get_cid_user_score(self, cid_user):
|
||||
c = "c/" + str(cid_user)
|
||||
if c in self.user_scores:
|
||||
|
||||
Reference in New Issue
Block a user