.
This commit is contained in:
+2
-2
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'),
|
||||
),
|
||||
]
|
||||
+6
-1
@@ -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)
|
||||
|
||||
+1
-1
@@ -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):
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<div class="date">
|
||||
{{ question.created_date }}
|
||||
</div>
|
||||
<p class="pre-whitespace"><b>Description:</b> {{ question.description }}</p>
|
||||
|
||||
<p class="pre-whitespace"><b>History:</b> {{ question.history }}</p>
|
||||
|
||||
|
||||
+2
-2
@@ -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"
|
||||
|
||||
@@ -15,4 +15,32 @@
|
||||
</div>
|
||||
{% render_table table %}
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
$("#button-select-add-exam").click(function () {
|
||||
$.ajax({
|
||||
url: "{% url 'rapids:exam_json_edit' pk=exam.pk %}",
|
||||
data: {
|
||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
||||
add_exam_questions: true,
|
||||
},
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
})
|
||||
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
||||
.done(function (data) {
|
||||
console.log(data);
|
||||
|
||||
if (data.status == "success") {
|
||||
toastr.info('Questions added to exams.')
|
||||
}
|
||||
})
|
||||
.always(function () {
|
||||
console.log('[Done]');
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
+1
-1
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user