Add QuestionReviewForm to question review view and update template to include form

This commit is contained in:
Ross
2025-10-27 10:38:49 +00:00
parent a404a335c0
commit 27e575f772
2 changed files with 10 additions and 7 deletions
+6 -7
View File
@@ -68,6 +68,7 @@ from .forms import (
CidUserExamForm,
ExamCollectionCloneForm,
ExamCollectionForm,
QuestionReviewForm,
ExaminationForm,
CidUserGroupForm,
ExaminationMergeForm,
@@ -96,8 +97,10 @@ from .models import (
UserProfile,
UserUserGroup,
get_next_cid,
QuestionReview,
)
from rapids.models import (
Rapid as RapidQuestion,
ExamQuestionDetail as RapidsExamQuestionDetail,
@@ -2954,9 +2957,6 @@ class GenericViewBase:
GET: renders the current review block or the form (if ?edit=1)
POST: creates a new QuestionReview and returns the rendered block
"""
from django.contrib.contenttypes.models import ContentType
from generic.models import QuestionReview
from .forms import QuestionReviewForm
logger.debug("question_set_review called")
@@ -3018,8 +3018,6 @@ class GenericViewBase:
def question_reviews_list(self, request, pk):
"""Return a partial listing all QuestionReview instances for a question."""
from django.contrib.contenttypes.models import ContentType
from generic.models import QuestionReview
question = get_object_or_404(self.question_object, pk=pk)
@@ -3072,7 +3070,6 @@ class GenericViewBase:
- status: one of the status codes (AC, OD, ER, RJ, IP), or 'UNREVIEWED' or 'ANY'
"""
from django.contrib.contenttypes.models import ContentType
from generic.models import QuestionReview
# Read filters
category = request.POST.get("category") or request.GET.get("category")
@@ -3124,7 +3121,9 @@ class GenericViewBase:
match = True
if match:
return render(request, f"{self.app_name}/question_review_question.html", {"question": question})
form = QuestionReviewForm()
return render(request, f"{self.app_name}/question_review_question.html", {"question": question, "form": form, "app_name": self.app_name})
# Nothing found - render complete page
return render(request, f"{self.app_name}/question_review_complete.html", {"app_name": self.app_name})
@@ -54,6 +54,10 @@
{% endif %}
</div>
{% comment %} <span class="btn btn-sm btn-outline-success" data-bs-toggle="modal" data-bs-target="#reviewModal" hx-get="{% url 'sbas:question_set_review' question.pk %}?edit=1&new=1" hx-target="#review-form" hx-swap="innerHTML" hx-trigger="load">Add Review</button> {% endcomment %}
<form id="review-form">
{% include 'generic/partials/question_review_form.html' with app_name='sbas' question=question form=form %}
</form>
{% endblock %}