From f5b61f44882d93fa1c39349e917e044b8e455d55 Mon Sep 17 00:00:00 2001 From: Ross Date: Thu, 25 Feb 2021 18:02:02 +0000 Subject: [PATCH] . --- anatomy/views.py | 4 +-- generic/views.py | 9 ++++++ longs/migrations/0026_long_description.py | 18 ++++++++++++ longs/models.py | 7 ++++- longs/tables.py | 2 +- longs/templates/longs/long_display_block.html | 1 + longs/views.py | 4 +-- rapids/templates/rapids/view.html | 28 +++++++++++++++++++ rapids/views.py | 2 +- 9 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 longs/migrations/0026_long_description.py diff --git a/anatomy/views.py b/anatomy/views.py index cee79866..fa5a2f32 100644 --- a/anatomy/views.py +++ b/anatomy/views.py @@ -923,14 +923,14 @@ def get_structure_id(request): return HttpResponse("/") -class AnatomyQuestionView(SingleTableMixin, FilterView): +class AnatomyQuestionView(LoginRequiredMixin, SingleTableMixin, FilterView): model = AnatomyQuestion table_class = AnatomyQuestionTable template_name = "anatomy/anatomy_question_view.html" filterset_class = AnatomyQuestionFilter -class AnatomyUserAnswerView(SingleTableMixin, FilterView): +class AnatomyUserAnswerView(LoginRequiredMixin, SingleTableMixin, FilterView): model = CidUserAnswer table_class = AnatomyUserAnswerTable template_name = "anatomy/anatomy_question_view.html" diff --git a/generic/views.py b/generic/views.py index da4bb8c8..9773038d 100644 --- a/generic/views.py +++ b/generic/views.py @@ -131,6 +131,15 @@ class ExamViews(View, LoginRequiredMixin): exam = get_object_or_404(self.Exam, pk=pk) + if "add_exam_questions" in request.POST: + question_ids = json.loads(request.POST.get("add_exam_questions")) + question_objects = self.Question.objects.filter(pk__in=question_ids) + + exam.exam_questions.add(question_objects) + exam.save() + data = {"status": "success"} + return JsonResponse(data, status=200) + if "set_open_access" in request.POST: if request.POST.get("set_open_access") == "true": state = True diff --git a/longs/migrations/0026_long_description.py b/longs/migrations/0026_long_description.py new file mode 100644 index 00000000..085f8cc2 --- /dev/null +++ b/longs/migrations/0026_long_description.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.3 on 2021-02-25 17:59 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('longs', '0025_auto_20210217_2218'), + ] + + operations = [ + migrations.AddField( + model_name='long', + name='description', + field=models.TextField(blank=True, help_text='Description of the case, for admin organisation, will not be visible when taking'), + ), + ] diff --git a/longs/models.py b/longs/models.py index 12d38470..f7ba6faf 100644 --- a/longs/models.py +++ b/longs/models.py @@ -58,6 +58,11 @@ def findMiddle(input_list): class Long(models.Model): # author = models.ForeignKey('auth.User', on_delete=models.CASCADE) # image = models.ImageField() + description = models.TextField( + blank=True, + help_text="Description of the case, for admin organisation, will not be visible when taking", + ) + history = models.TextField(null=True, blank=True) feedback = models.TextField(null=True, blank=True) @@ -121,7 +126,7 @@ class Long(models.Model): def __str__(self): examinations = [series.get_examination() for series in self.series.all()] - return "{} : {}".format(self.history, ", ".join(examinations)) + return "{} : {}".format(self.description, ", ".join(examinations)) def GetExams(self): e = self.exams.all().values_list("name", flat=True) diff --git a/longs/tables.py b/longs/tables.py index 0b6d68f3..a6e40c58 100755 --- a/longs/tables.py +++ b/longs/tables.py @@ -70,7 +70,7 @@ class LongTable(tables.Table): class Meta: model = Long template_name = "django_tables2/bootstrap4.html" - fields = ("history", "created_date", "author") + fields = ("description", "history", "created_date", "author") sequence = ("view", "series", "exams") class PopupLinkColumn(tables.Column): diff --git a/longs/templates/longs/long_display_block.html b/longs/templates/longs/long_display_block.html index fcb65d39..7f96ec70 100755 --- a/longs/templates/longs/long_display_block.html +++ b/longs/templates/longs/long_display_block.html @@ -2,6 +2,7 @@
{{ question.created_date }}
+

Description: {{ question.description }}

History: {{ question.history }}

diff --git a/longs/views.py b/longs/views.py index 9c583115..d2c32383 100755 --- a/longs/views.py +++ b/longs/views.py @@ -586,14 +586,14 @@ def get_region_id(request): return HttpResponse("/") -class LongView(SingleTableMixin, FilterView): +class LongView(LoginRequiredMixin, SingleTableMixin, FilterView): model = Long table_class = LongTable template_name = "longs/view.html" filterset_class = LongFilter -class LongSeriesView(SingleTableMixin, FilterView): +class LongSeriesView(LoginRequiredMixin, SingleTableMixin, FilterView): model = LongSeries table_class = LongSeriesTable template_name = "longs/view.html" diff --git a/rapids/templates/rapids/view.html b/rapids/templates/rapids/view.html index 2d6dddd3..234f732c 100755 --- a/rapids/templates/rapids/view.html +++ b/rapids/templates/rapids/view.html @@ -15,4 +15,32 @@ {% render_table table %} + {% endblock %} \ No newline at end of file diff --git a/rapids/views.py b/rapids/views.py index 315bf2ed..0a9f36c4 100755 --- a/rapids/views.py +++ b/rapids/views.py @@ -486,7 +486,7 @@ def get_region_id(request): return HttpResponse("/") -class RapidView(SingleTableMixin, FilterView): +class RapidView(LoginRequiredMixin, SingleTableMixin, FilterView): model = Rapid table_class = RapidTable template_name = "rapids/view.html"