diff --git a/generic/views.py b/generic/views.py index a0f04362..73ab0a07 100644 --- a/generic/views.py +++ b/generic/views.py @@ -320,7 +320,7 @@ class ExamViews(View, LoginRequiredMixin): for exam in exams: if exam.active: if exam.json_creation_time: - creation_time = exam.json_creation_time.timestamp() + creation_time = exam.json_creation_time.isoformat() else: creation_time = "None" active_exams["exams"].append( @@ -378,15 +378,16 @@ class ExamViews(View, LoginRequiredMixin): return redirect(url) return JsonResponse(exam_json_cache) + time = datetime.now() with open(path, "w+") as f: exam_json = exam.get_exam_json() - exam_json["generated"] = datetime.now().timestamp() + exam_json["generated"] = time.isoformat() f.write(json.dumps(exam_json)) exam.recreate_json = False - exam.json_creation_time = datetime.now() + exam.json_creation_time = time exam.save() # We also try to clear the cache of any associated questions (longs) diff --git a/longs/models.py b/longs/models.py index 3c13f76b..89e04481 100644 --- a/longs/models.py +++ b/longs/models.py @@ -120,7 +120,7 @@ class Long(models.Model): help_text="If the json cache needs updating", default=False ) - json_creation_time = models.DateTimeField(blank=True, default=None, null=True) + json_creation_time = models.DateTimeField(blank=True, default=None) #question_file = models.FileField(upload_to=question_file_directory_path, blank=True, null=True) @@ -182,7 +182,7 @@ class Long(models.Model): "title": "{}", "type": "long", "generated": "{}", - """.format(q.history, datetime.datetime.now().timestamp()) + """.format(q.history, datetime.datetime.now().isoformat()) )