This commit is contained in:
Ross
2021-09-25 21:16:53 +01:00
parent 48af075a14
commit 85379eb128
5 changed files with 39 additions and 21 deletions
@@ -0,0 +1,10 @@
{% extends 'anatomy/base.html' %}
{% block content %}
CID: {{ciduseranswer.cid}}<br/>
{{ciduseranswer.title}}<br/>
{{ciduseranswer.question}}<br/>
Answer(s): {{ciduseranswer.answers}}<br/>
<a href="{% url 'anatomy:user_answer_delete' ciduseranswer.id %}">Delete answer</a>
{% endblock content %}
+5
View File
@@ -9,6 +9,7 @@ from django.contrib.auth.models import User
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.mixins import LoginRequiredMixin
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView, DeleteView from django.views.generic.edit import CreateView, UpdateView, DeleteView
from django.views.generic import ListView from django.views.generic import ListView
@@ -973,6 +974,10 @@ def question_save_annotation(request, pk):
AnatomyExamViews = ExamViews(Exam, AnatomyQuestion, "anatomy", "anatomy", loadJsonAnswer) AnatomyExamViews = ExamViews(Exam, AnatomyQuestion, "anatomy", "anatomy", loadJsonAnswer)
class UserAnswerView(LoginRequiredMixin, DetailView):
model = CidUserAnswer
class UserAnswerDelete(SuperuserRequiredMixin, DeleteView): class UserAnswerDelete(SuperuserRequiredMixin, DeleteView):
model = CidUserAnswer model = CidUserAnswer
success_url = reverse_lazy("anatomy:anatomy_user_answer_view") success_url = reverse_lazy("anatomy:anatomy_user_answer_view")
+20
View File
@@ -1,3 +1,4 @@
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.forms.models import model_to_dict from django.forms.models import model_to_dict
from django.shortcuts import render, get_object_or_404, redirect from django.shortcuts import render, get_object_or_404, redirect
@@ -739,3 +740,22 @@ class GenericViewBase:
f"{self.app_name}/question_user_answers.html", f"{self.app_name}/question_user_answers.html",
{"question": question, "answers": answers}, {"question": question, "answers": answers},
) )
@method_decorator(login_required)
def author_detail(self, request, pk):
# logging.debug(Author.objects.all())
# author = get_object_or_404(Author, pk=pk)
author = User.objects.get(pk=pk)
questions = self.question_object.objects.filter(author=pk)
return render(
request, f"{self.app_name}/category_detail.html", {"category": author, "questions": questions}
)
@method_decorator(login_required)
def author_list(self, request):
authors = User.objects.all()
return render(request, f"{self.app_name}/author_list.html", {"authors": authors})
+3 -3
View File
@@ -3,9 +3,9 @@
{% block content %} {% block content %}
{{category}}: {{category}}:
<ul> <ul>
{% for rapid in rapids %} {% for question in questions %}
<li><a href="{% url 'rapids:question_detail' pk=rapid.pk %}">{{rapid}} <li><a href="{% url 'rapids:question_detail' pk=question.pk %}">{{question}}
[{{rapid.get_authors}}]</a></li> [{{question.get_authors}}]</a></li>
{% endfor %} {% endfor %}
</ul> </ul>
-17
View File
@@ -156,23 +156,6 @@ def rapid_split(request, pk):
return render(request, "rapids/question_detail.html", {"question": rapid}) return render(request, "rapids/question_detail.html", {"question": rapid})
@login_required
def author_detail(request, pk):
# logging.debug(Author.objects.all())
# author = get_object_or_404(Author, pk=pk)
author = User.objects.get(pk=pk)
rapids = Rapid.objects.filter(author=pk)
return render(
request, "rapids/category_detail.html", {"category": author, "rapids": rapids}
)
def author_list(request):
authors = User.objects.all()
return render(request, "rapids/author_list.html", {"authors": authors})
class RapidCreationDefaultView(LoginRequiredMixin, UpdateView): class RapidCreationDefaultView(LoginRequiredMixin, UpdateView):