.
This commit is contained in:
@@ -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 %}
|
||||
@@ -9,6 +9,7 @@ from django.contrib.auth.models import User
|
||||
from django.core.exceptions import PermissionDenied
|
||||
|
||||
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 import ListView
|
||||
@@ -973,6 +974,10 @@ def question_save_annotation(request, pk):
|
||||
|
||||
AnatomyExamViews = ExamViews(Exam, AnatomyQuestion, "anatomy", "anatomy", loadJsonAnswer)
|
||||
|
||||
class UserAnswerView(LoginRequiredMixin, DetailView):
|
||||
model = CidUserAnswer
|
||||
|
||||
|
||||
class UserAnswerDelete(SuperuserRequiredMixin, DeleteView):
|
||||
model = CidUserAnswer
|
||||
success_url = reverse_lazy("anatomy:anatomy_user_answer_view")
|
||||
|
||||
+21
-1
@@ -1,3 +1,4 @@
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.forms.models import model_to_dict
|
||||
from django.shortcuts import render, get_object_or_404, redirect
|
||||
@@ -738,4 +739,23 @@ class GenericViewBase:
|
||||
request,
|
||||
f"{self.app_name}/question_user_answers.html",
|
||||
{"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,9 +3,9 @@
|
||||
{% block content %}
|
||||
{{category}}:
|
||||
<ul>
|
||||
{% for rapid in rapids %}
|
||||
<li><a href="{% url 'rapids:question_detail' pk=rapid.pk %}">{{rapid}}
|
||||
[{{rapid.get_authors}}]</a></li>
|
||||
{% for question in questions %}
|
||||
<li><a href="{% url 'rapids:question_detail' pk=question.pk %}">{{question}}
|
||||
[{{question.get_authors}}]</a></li>
|
||||
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
@@ -156,23 +156,6 @@ def rapid_split(request, pk):
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user