diff --git a/generic/models.py b/generic/models.py index af9b5e48..78b976a6 100644 --- a/generic/models.py +++ b/generic/models.py @@ -73,6 +73,7 @@ class ExamBase(models.Model): ) json_creation_time = models.DateTimeField(blank=True, default=None, null=True) + json_creation_id = models.IntegerField(default=1, help_text="auto incrementing field when json recreated") #time_limit = models.IntegerField( # help_text="Exam time limit (in seconds). Default is 2100 secondse (35 minutes)", diff --git a/generic/views.py b/generic/views.py index f60b79ae..0a348873 100644 --- a/generic/views.py +++ b/generic/views.py @@ -401,6 +401,7 @@ class ExamViews(View, LoginRequiredMixin): "type": self.question_type, "eid": "{}/{}".format(self.question_type, exam.pk), "json_creation_time": creation_time + "json_creation_id": exam.creation_id } if self.question_type == "long": @@ -409,7 +410,7 @@ class ExamViews(View, LoginRequiredMixin): # Generate json if needed if question.json_creation_time is None: question.get_json(question.pk) - h[question.pk] = question.json_creation_time.isoformat() + h[question.pk] = question.json_creation_id obj["multi_question_json"] = h active_exams["exams"].append( obj ) @@ -476,9 +477,12 @@ class ExamViews(View, LoginRequiredMixin): time = datetime.now() + exam.json_creation_id += 1 + with open(path, "w+") as f: exam_json = exam.get_exam_json() - exam_json["generated"] = "test"+time.isoformat() + exam_json["generated"] = time.isoformat() + exam_json["creation_id"] = exam.json_creation_id f.write(json.dumps(exam_json)) exam.recreate_json = False diff --git a/longs/models.py b/longs/models.py index 7f79f69e..e60921f6 100644 --- a/longs/models.py +++ b/longs/models.py @@ -126,6 +126,8 @@ class Long(models.Model): json_creation_time = models.DateTimeField(blank=True, default=None, null=True) + json_creation_id = models.IntegerField(default=1, help_text="Auto incrementing json creation number") + #question_file = models.FileField(upload_to=question_file_directory_path, blank=True, null=True) def get_absolute_url(self): @@ -212,6 +214,8 @@ class Long(models.Model): url= "{0}longs/questions/{1}.json".format(settings.MEDIA_URL, question_id) timestamp = datetime.datetime.now() + q.json_creation_id += 1 + with open(path, "w+") as f: # We manually create the json for long questions to reducem memroy usade @@ -219,7 +223,8 @@ class Long(models.Model): "title": "{}", "type": "long", "generated": "{}", - """.format(q.history, timestamp.isoformat()) + "creation_id": "{}", + """.format(q.history, timestamp.isoformat(), q.json_creation_id) ) @@ -248,8 +253,8 @@ class Long(models.Model): f.write('"image_titles" : {} }}'.format(json.dumps(image_titles))) - self.json_creation_time = timestamp - self.save() + q.json_creation_time = timestamp + q.save() #exam_question = { # "title": q.history, @@ -584,7 +589,7 @@ class Exam(ExamBase): # If it is a new question we need to for a question json refresh if q.json_creation_time is None: q.get_json(q.pk) - exam_questions[q.id] = q.json_creation_time.isoformat() + exam_questions[q.id] = q.json_creation_id else: # TODO: combine with question_json diff --git a/longs/templates/longs/long_display_block.html b/longs/templates/longs/long_display_block.html index 36040e9b..ed372807 100755 --- a/longs/templates/longs/long_display_block.html +++ b/longs/templates/longs/long_display_block.html @@ -57,7 +57,8 @@
- JSON creation time: {{question.json_creation_time}} ({{question.json_creation_time|date:"c"}}) + JSON creation time: {{question.json_creation_time}} ({{question.json_creation_time|date:"c"}}), + JSON creation id: {{question.json_creation_id}}
JSON Refresh JSON cache \ No newline at end of file diff --git a/longs/templates/longs/long_series_viewer.html b/longs/templates/longs/long_series_viewer.html index 9617b76f..c89ebf7e 100755 --- a/longs/templates/longs/long_series_viewer.html +++ b/longs/templates/longs/long_series_viewer.html @@ -1,10 +1,9 @@ -
{{ series.modality}}, {{ series.examination }}, {{ series.plane }}, {{ series.contrast }}
{% if series.long %} -Associated case: +Associated case: {% for long in series.long.all %} -{{long}} +{{long}} {% endfor %} {% else %} This series is not associated with any cases. @@ -15,12 +14,20 @@ This series is not associated with any cases.
Author: {{ series.get_author_display }}
-Order dicoms by slice location -Order dicoms by instance number -Order dicoms by SeriesInstanceUID -Order by uploaded filename + Order dicoms + by slice location + Order dicoms by instance number + Order dicoms by SeriesInstanceUID + Order by uploaded filename
{% for image in series.images.all %} - {{image.image.url}}, pos: {{image.position}}, {{image.upload_filename}}
- -{% endfor %} \ No newline at end of file +{{image.image.url}}, pos: {{image.position}}, {{image.upload_filename}}
+ +{% endfor %} +
+ JSON creation time: {{question.json_creation_time}} ({{question.json_creation_time|date:"c"}}), + JSON creation id: {{question.json_creation_id}} +
\ No newline at end of file