.
This commit is contained in:
+7
-7
@@ -374,14 +374,14 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
if not exam.active:
|
||||
raise Http404("No available exam")
|
||||
|
||||
exam_json_cache = cache.get("{}_exam_json_{}_{}".format(self.app_name, pk, sk))
|
||||
question_json_cache = cache.get("{}_question_json_{}".format(self.app_name, sk))
|
||||
|
||||
if exam_json_cache is not None and not exam.recreate_json:
|
||||
exam_json_cache["cached"] = True
|
||||
return JsonResponse(exam_json_cache)
|
||||
if question_json_cache is not None and not exam.recreate_json:
|
||||
question_json_cache["cached"] = True
|
||||
return JsonResponse(question_json_cache)
|
||||
|
||||
exam_json = exam.get_exam_question_json(sk)
|
||||
question_json = exam.get_exam_question_json(sk)
|
||||
|
||||
cache.set("{}_exam_json_{}_{}".format(self.app_name, pk, sk), exam_json, 3600)
|
||||
cache.set("{}_question_json_{}".format(self.app_name, sk), question_json, 3600)
|
||||
|
||||
return JsonResponse(exam_json)
|
||||
return JsonResponse(question_json)
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.1.3 on 2021-02-28 16:28
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('longs', '0029_auto_20210225_1819'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='long',
|
||||
name='recreate_json',
|
||||
field=models.BooleanField(default=False, help_text='If the json cache needs updating'),
|
||||
),
|
||||
]
|
||||
@@ -114,6 +114,10 @@ class Long(models.Model):
|
||||
help_text="If a question should be freely available to browse", default=True
|
||||
)
|
||||
|
||||
recreate_json = models.BooleanField(
|
||||
help_text="If the json cache needs updating", default=False
|
||||
)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse("longs:long_detail", kwargs={"pk": self.pk})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user