start taking more advantage of class based views
This commit is contained in:
@@ -127,6 +127,9 @@ class AnatomyQuestion(QuestionBase):
|
||||
class Meta:
|
||||
permissions = ()
|
||||
|
||||
def get_app_name(self):
|
||||
return "anatomy"
|
||||
|
||||
def __str__(self):
|
||||
# Get first answer
|
||||
return "{}/{}: {} [{}, {}]".format(
|
||||
@@ -410,6 +413,9 @@ class Exam(ExamBase):
|
||||
|
||||
examcollection = models.ForeignKey(ExamCollection, blank=True, null=True, on_delete=models.SET_NULL, related_name="anatomy_exams")
|
||||
|
||||
def get_app_name(self):
|
||||
return "anatomy"
|
||||
|
||||
def get_exam_json(self, based=True):
|
||||
questions = self.get_questions()
|
||||
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
{% extends 'anatomy/exams.html' %}
|
||||
|
||||
{% block navigation %}
|
||||
{{ block.super }}
|
||||
{% include 'generic/exam_overview_headers.html' %}
|
||||
{% endblock navigation %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% load thumbnail %}
|
||||
<div class="anatomy">
|
||||
{% include 'generic/exam_overview_headers.html' %}
|
||||
|
||||
<ol id="full-question-list" class="sortable">
|
||||
{% for question in questions %}
|
||||
|
||||
|
||||
+11
-3
@@ -71,7 +71,7 @@ from helpers.images import image_as_base64
|
||||
|
||||
from django.template.defaulttags import register
|
||||
|
||||
from generic.mixins import SuperuserRequiredMixin
|
||||
from generic.mixins import CheckCanEditMixin, SuperuserRequiredMixin
|
||||
|
||||
from rest_framework import viewsets, permissions
|
||||
|
||||
@@ -805,10 +805,16 @@ class ExamCreate(ExamCreateBase):
|
||||
form_class = ExamForm
|
||||
|
||||
|
||||
class ExamUpdate(ExamUpdateBase, AuthorOrCheckerRequiredMixin):
|
||||
class ExamUpdate(CheckCanEditMixin, ExamUpdateBase, AuthorOrCheckerRequiredMixin):
|
||||
model = Exam
|
||||
form_class = ExamForm
|
||||
|
||||
#def get_context_data(self, **kwargs):
|
||||
# context = super().get_context_data(**kwargs)
|
||||
|
||||
# context["can_edit"] = self.object.check_user_can_edit(self.request.user)
|
||||
|
||||
# return context
|
||||
|
||||
class ExamDelete(AuthorOrCheckerRequiredMixin, ExamDeleteBase):
|
||||
model = Exam
|
||||
@@ -831,10 +837,12 @@ class ExamDelete(AuthorOrCheckerRequiredMixin, ExamDeleteBase):
|
||||
# return Exam.objects.filter(author__id=user.id)
|
||||
|
||||
|
||||
class ExamAuthorUpdate(RevisionMixin, LoginRequiredMixin, AuthorRequiredMixin, UpdateView):
|
||||
class ExamAuthorUpdate(RevisionMixin, CheckCanEditMixin, LoginRequiredMixin, AuthorRequiredMixin, UpdateView):
|
||||
model = Exam
|
||||
form_class = ExamAuthorForm
|
||||
|
||||
template_name = "author_form.html"
|
||||
|
||||
|
||||
|
||||
GenericViews = GenericViewBase("anatomy", AnatomyQuestion, UserAnswer, Exam)
|
||||
|
||||
Reference in New Issue
Block a user