This commit is contained in:
Ross
2021-03-09 15:18:19 +00:00
parent 6b2c7a1a80
commit f0efcd0c32
4 changed files with 34 additions and 10 deletions
+6 -2
View File
@@ -120,6 +120,8 @@ class Long(models.Model):
help_text="If the json cache needs updating", default=False
)
json_creation_time = models.DateTimeField(blank=True)
#question_file = models.FileField(upload_to=question_file_directory_path, blank=True, null=True)
def get_absolute_url(self):
@@ -175,11 +177,11 @@ class Long(models.Model):
url= "{0}longs/questions/{1}.json".format(settings.MEDIA_URL, question_id)
with open(path, "w+") as f:
# We manually create the json for long questions to reducem memroy usade
f.write("""{{
"title": "{}",
"image_titles": "{}",
"type": "long",
"generated": "long",
"generated": "{}",
""".format(q.history, datetime.datetime.now().isoformat())
)
@@ -209,6 +211,8 @@ class Long(models.Model):
f.write('"image_titles" : {} }}'.format(json.dumps(image_titles)))
self.json_creation_time = datetime.datetime.now()
self.save()
#exam_question = {
# "title": q.history,