From e65cd408eb3cb327660a5d963b6ce06b5f67e6f4 Mon Sep 17 00:00:00 2001 From: ben8 Date: Mon, 23 Jun 2025 14:54:46 +0200 Subject: [PATCH] improved_library_structure#140 --- django/library/forms.py | 13 +- django/library/urls.py | 3 + django/library/views.py | 220 +++++- django/templates/library/head.html | 145 ++++ .../templates/library/overview_quiz(old).html | 672 ++++++++++++++++++ django/templates/library/overview_quiz.html | 569 +++------------ .../library/overview_quiz_favorite.html | 285 ++++++++ .../templates/library/overview_quiz_my.html | 280 ++++++++ django/templates/partials/_nav.html | 4 +- 9 files changed, 1669 insertions(+), 522 deletions(-) create mode 100644 django/templates/library/head.html create mode 100644 django/templates/library/overview_quiz(old).html create mode 100644 django/templates/library/overview_quiz_favorite.html create mode 100644 django/templates/library/overview_quiz_my.html diff --git a/django/library/forms.py b/django/library/forms.py index f2bd3b9..b4d711c 100644 --- a/django/library/forms.py +++ b/django/library/forms.py @@ -1,5 +1,5 @@ from django import forms -from .models import QivipQuiz, QivipQuestion +from .models import QivipQuiz, QivipQuestion, QuizCategory class QuizForm(forms.ModelForm): class Meta: @@ -19,13 +19,20 @@ class QuizFilterForm(forms.Form): })) - min_amout_questions = forms.IntegerField(required=False, min_value=1, label="Minimale Anzahl an Fragen", widget=forms.NumberInput(attrs={ + min_amount_questions = forms.IntegerField(required=False, min_value=1, label="Minimale Anzahl an Fragen", widget=forms.NumberInput(attrs={ 'class': 'border-2 border-gray-300 rounded-lg p-2 w-full' })) - max_amout_questions = forms.IntegerField(required=False, min_value=1, label="Maximale Anzahl an Fragen", widget=forms.NumberInput(attrs={ + max_amount_questions = forms.IntegerField(required=False, min_value=1, label="Maximale Anzahl an Fragen", widget=forms.NumberInput(attrs={ 'class': 'border-2 border-gray-300 rounded-lg p-2 w-full' })) user = forms.CharField(required=False, label="von User", widget=forms.TextInput(attrs={ 'class': 'border-2 border-gray-300 rounded-lg p-2 w-full' })) + categories = forms.ModelChoiceField( + queryset=QuizCategory.objects.filter().distinct(), + required=False, + label="Kategorie", + widget=forms.Select(attrs={ + 'class': 'border-2 border-gray-300 rounded-lg p-2 w-full' + })) \ No newline at end of file diff --git a/django/library/urls.py b/django/library/urls.py index 6c8a275..fa19cf3 100644 --- a/django/library/urls.py +++ b/django/library/urls.py @@ -7,6 +7,9 @@ app_name = 'library' urlpatterns = [ path('', views.overview_quiz, name='overview_quiz'), + path('my/', views.overview_quiz_my, name='overview_quiz_my'), + path('favorites/', views.overview_quiz_favorites, name='overview_quiz_favorites'), + path('new/', views.new_quiz, name='new_quiz'), path('edit//', views.edit_quiz, name='edit_quiz'), path('delete//', views.delete_quiz, name='delete_quiz'), diff --git a/django/library/views.py b/django/library/views.py index c114a74..4bf4860 100644 --- a/django/library/views.py +++ b/django/library/views.py @@ -14,6 +14,7 @@ from .models import QivipQuiz from .forms import QuizFilterForm from django.db.models import Count from django.contrib.auth.models import User +from urllib.parse import urlparse, urlunparse # Übersicht aller Quizze @@ -23,13 +24,12 @@ def quiz_names_json(request): search = form.cleaned_data.get('search') - names = QivipQuiz.objects.all().annotate(max_amout_questions=Count('questions')).filter(max_amout_questions__gte=1, status='öffentlich', name__icontains=search) + names = QivipQuiz.objects.all().annotate(max_amount_questions=Count('questions')).filter(max_amount_questions__gte=1, status='öffentlich', name__icontains=search) if request.user.is_authenticated: names = names | QivipQuiz.objects.filter( user_id=request.user.id, - status='privat', name__icontains=search ) @@ -38,6 +38,167 @@ def quiz_names_json(request): return JsonResponse(names, safe=False) + +def apply_quiz_filters(queryset, form): + + if not form.is_valid(): + return queryset + queryset = queryset.annotate(question_count=Count('questions')) + search = form.cleaned_data.get('search') + username = form.cleaned_data.get('user') + min_questions = form.cleaned_data.get('min_amount_questions') + max_questions = form.cleaned_data.get('max_amount_questions') + category = form.cleaned_data.get('categories') + + filters = {} + + if search: + filters['name__icontains'] = search + + if min_questions is not None: + filters['question_count__gte'] = min_questions + + if max_questions is not None: + filters['question_count__lte'] = max_questions + + + if category is not None: + filters['category'] = category + + + if username: + try: + user = User.objects.get(username=username) + filters['user_id'] = user.id + except User.DoesNotExist: + return queryset.none() + + return queryset.filter(**filters) + + +def overview_quiz(request, connect="all"): + form = QuizFilterForm(request.GET) + + user = request.user if request.user.is_authenticated else None + + # Meine Quizzeze mit mind. 1 Frage + filter_my_quizzes = QivipQuiz.objects.none() + if user: + filter_my_quizzes = QivipQuiz.objects.annotate(max_amount_questions=Count('questions')).filter( + user_id=user.id, + max_amount_questions__gte=0 + ) + + # Öffentliche Alle mit mind. 1 Frage + filter_all_quizzes = QivipQuiz.objects.annotate(max_amount_questions=Count('questions')).filter( + status='öffentlich', + max_amount_questions__gte=1 + ) + if user: + filter_all_quizzes = filter_all_quizzes.exclude(user_id=user.id) + + # Favoriten mit mind. 1 Frage + favorite_quiz_ids = [] + favorite_quizzes = QivipQuiz.objects.none() + if user: + favorite_quiz_ids = QivipQuizFavorite.objects.filter(user=user, favorite=True).values_list('quiz', flat=True) + favorite_quizzes = QivipQuiz.objects.annotate(max_amount_questions=Count('questions')).filter( + id__in=favorite_quiz_ids, + max_amount_questions__gte=1 + ) + + # Suche anwenden, falls vorhanden + + + filter_my_quizzes = apply_quiz_filters(filter_my_quizzes, form) + filter_all_quizzes = apply_quiz_filters(filter_all_quizzes, form) + favorite_quizzes = apply_quiz_filters(favorite_quizzes, form) + if request.user.is_authenticated: + filter_all_quizzes = apply_quiz_filters(filter_all_quizzes, form) | filter_my_quizzes + + # Treffer zählen + total_my = filter_my_quizzes.count() + total_all = filter_all_quizzes.count() + total_favorite = favorite_quizzes.count() + + total_all_found=total_my + total_all + total_favorite + + # Paginierung + paginator_my = Paginator(filter_my_quizzes.order_by('-creation_date'), 8) + paginator_all = Paginator(filter_all_quizzes.order_by('-creation_date'), 8) + paginator_fav = Paginator(favorite_quizzes.order_by('-creation_date'), 8) + + my_page = request.GET.get('my_page', 1) + all_page = request.GET.get('all_page', 1) + fav_page = request.GET.get('favorite_page', 1) + + try: + my_quizzes = paginator_my.page(my_page) + except: + my_quizzes = paginator_my.page(1) + + try: + all_quizzes = paginator_all.page(all_page) + except: + all_quizzes = paginator_all.page(1) + + try: + favorite_quizzes = paginator_fav.page(fav_page) + except: + favorite_quizzes = paginator_fav.page(1) + + context = { + 'form': form, + 'my_quizzes': my_quizzes, + 'all_quizzes': all_quizzes, + 'favorite_quizzes': favorite_quizzes, + 'total_my': total_my, + 'total_all': total_all, + 'total_favorite': total_favorite, + 'total_all_found':total_all_found, + 'show_search': True, + 'favorite_quiz_ids': list(favorite_quiz_ids), + 'url_my': '/library/my/', + 'url_all': '/library/', + 'url_favorite': '/library/favorites/', + } + + query_params = request.GET.copy() + + querydict_my = query_params.copy() + querydict_all = query_params.copy() + querydict_fav = query_params.copy() + + # Entferne die jeweiligen Seiten-Parameter, damit wir sie neu setzen können + querydict_my.pop('my_page', None) + querydict_all.pop('all_page', None) + querydict_fav.pop('favorite_page', None) + + # Füge die "bereinigten" Querystrings dem context hinzu + context.update({ + 'querystring_my': querydict_my.urlencode(), + 'querystring_all': querydict_all.urlencode(), + 'querystring_favorite': querydict_fav.urlencode(), + }) + + if connect=="all": + context.update({"link":"library:overview_quiz"}) + return render(request, 'library/overview_quiz.html', context) + elif connect=="my": + context.update({"link":"library:overview_quiz_my"}) + return render(request, 'library/overview_quiz_my.html', context) + elif connect=="favorite": + context.update({"link":"library:overview_quiz_favorites"}) + return render(request, 'library/overview_quiz_favorite.html', context) + + +def overview_quiz_my(request): + return overview_quiz(request, connect="my") + + +def overview_quiz_favorites(request): + return overview_quiz(request, connect="favorite") +""" def overview_quiz(request): # Filter form = QuizFilterForm(request.GET) @@ -53,28 +214,24 @@ def overview_quiz(request): # Initialize querysets if request.user.is_authenticated: - filter_my_quizzes = QivipQuiz.objects.filter(user_id=request.user).annotate(max_amout_questions=Count('questions')) - favorite_quizzes = favorite_quizzes.filter(id__in=favorite_quiz_ids).annotate(max_amout_questions=Count('questions')) - filter_other_quizzes = QivipQuiz.objects.exclude(user_id=request.user) + filter_my_quizzes = QivipQuiz.objects.filter(user_id=request.user).annotate(max_amount_questions=Count('questions')) + favorite_quizzes = favorite_quizzes.filter(id__in=favorite_quiz_ids).annotate(max_amount_questions=Count('questions')) + filter_all_quizzes = QivipQuiz.objects.exclude(user_id=request.user) else: favorite_quizzes = QivipQuiz.objects.none() filter_my_quizzes = QivipQuiz.objects.none() - filter_other_quizzes = QivipQuiz.objects.all() + filter_all_quizzes = QivipQuiz.objects.all() - # Apply common filters to other quizzes - filter_other_quizzes = filter_other_quizzes.annotate(max_amout_questions=Count('questions')) - filter_other_quizzes = filter_other_quizzes.filter(max_amout_questions__gte=1, status='öffentlich') - - - - + # Apply common filters to all quizzes + filter_all_quizzes = filter_all_quizzes.annotate(max_amount_questions=Count('questions')) + filter_all_quizzes = filter_all_quizzes.filter(max_amount_questions__gte=1, status='öffentlich') if form.is_valid(): search = form.cleaned_data.get('search') username= form.cleaned_data.get('user') - max_amout_questions= form.cleaned_data.get('max_amout_questions') - min_amout_questions= form.cleaned_data.get('min_amout_questions') + max_amount_questions= form.cleaned_data.get('max_amount_questions') + min_amount_questions= form.cleaned_data.get('min_amount_questions') filters = {} if username: @@ -84,19 +241,19 @@ def overview_quiz(request): except User.DoesNotExist: favorite_quizzes = QivipQuiz.objects.none() filter_my_quizzes = QivipQuiz.objects.none() - filter_other_quizzes=QivipQuiz.objects.none() + filter_all_quizzes=QivipQuiz.objects.none() if search: filters['name__icontains'] = search - if min_amout_questions: - filters['max_amout_questions__gte'] = min_amout_questions - if max_amout_questions: - filters['max_amout_questions__lte'] = max_amout_questions + if min_amount_questions: + filters['max_amount_questions__gte'] = min_amount_questions + if max_amount_questions: + filters['max_amount_questions__lte'] = max_amount_questions try: - filter_other_quizzes = filter_other_quizzes.filter(**filters) + filter_all_quizzes = filter_all_quizzes.filter(**filters) except: - filter_other_quizzes=QivipQuiz.objects.none() + filter_all_quizzes=QivipQuiz.objects.none() try: filter_my_quizzes = filter_my_quizzes.filter(**filters) except: @@ -116,12 +273,12 @@ def overview_quiz(request): except: my_quizzes = my_quizzes_paginator.page(1) - # Pagination for other quizzes - other_quizzes_paginator = Paginator(filter_other_quizzes.order_by('-creation_date'), 8) # 8 quizzes per page + # Pagination for all quizzes + all_quizzes_paginator = Paginator(filter_all_quizzes.order_by('-creation_date'), 8) # 8 quizzes per page try: - other_quizzes = other_quizzes_paginator.page(request.GET.get('other_page', 1)) + all_quizzes = all_quizzes_paginator.page(request.GET.get('all_page', 1)) except: - other_quizzes = other_quizzes_paginator.page(1) + all_quizzes = all_quizzes_paginator.page(1) @@ -135,9 +292,9 @@ def overview_quiz(request): # Pagination for favorite_quizzes - favorite_quizzes_paginator = Paginator(favorite_quizzes, 8) # 8 quizzes per page + favorite_quizzes_paginator = Paginator(favorite_quizzes, 8) # 9 quizzes per page try: - favorite_quizzes = favorite_quizzes_paginator.page(request.GET.get('my_page', 1)) + favorite_quizzes = favorite_quizzes_paginator.page(request.GET.get('favorite_page', 1)) except: favorite_quizzes = favorite_quizzes_paginator.page(1) @@ -146,13 +303,13 @@ def overview_quiz(request): 'favorite_quiz_ids': favorite_quiz_ids, 'favorite_quizzes':favorite_quizzes, 'my_quizzes': my_quizzes, - 'other_quizzes': other_quizzes, + 'all_quizzes': all_quizzes, 'form': form, } return render(request, 'library/overview_quiz.html', context) - -# Neues Quiz erstellen + """ + @login_required def favorite_quiz(request, pk): quiz= get_object_or_404(QivipQuiz, pk=pk) @@ -177,6 +334,7 @@ def favorite_quiz(request, pk): favorite=QivipQuizFavorite.objects.create(user=request.user, quiz=quiz, favorite=True, favorite_date=timezone.now()) statement="Das Quiz '"+ favorite.quiz.name+ "' wurde erfolgreich zu den Favoriten hinzugefügt!" messages.success(request,statement ) + return redirect(request.META.get('HTTP_REFERER', 'library:overview_quiz')) diff --git a/django/templates/library/head.html b/django/templates/library/head.html new file mode 100644 index 0000000..2270786 --- /dev/null +++ b/django/templates/library/head.html @@ -0,0 +1,145 @@ +{% load static %} + +{% block extra_css %} + +{% endblock %} + +{% block head %} + + +
+
+
+ +
+
+ + +
+ + + + {{ form.min_amount_questions.value|default_if_none:0 }} Frage(n) + +
+ Quizze anderer User werden erst ab min. 1 Frage angezeigt. +
+ +
+
+ + +
+ + + + {{ form.max_amount_questions.value|default_if_none:100 }} Frage(n) + +
+ +
+ + +
+
+ + {{ form.categories }} + +
+
+ + {{ form.search }} + +
+ + +
+ +
+
+
+
+ + +{% endblock %} + + diff --git a/django/templates/library/overview_quiz(old).html b/django/templates/library/overview_quiz(old).html new file mode 100644 index 0000000..abdc8f2 --- /dev/null +++ b/django/templates/library/overview_quiz(old).html @@ -0,0 +1,672 @@ +{% extends 'base.html' %} +{% load static %} + +{% block extra_css %} + +{% endblock %} + + +{% block content %} + + + +
+
+
+ +
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+
+ + + +{% if user.is_authenticated %} +
+
+

Meine Quizze

+
+
+
+ +
+
+ {% for quiz in my_quizzes %} +
+ +
+ {% if quiz.image %} +
+ +
+
+
+ + + {% else %} +
{{ quiz.name }}
+ {% endif %} + {% if user.is_authenticated %} + {% if quiz.id not in favorite_quiz_ids %} +
+ + + + + + +
+ + {% else %} + + {% endif %} + {% endif %} +
+ + + + +
+ +

+ {{ quiz.name }} +

+ +

{{ quiz.description }}

+ + +
+ +
+ + + + {{ quiz.difficulty }} +
+ + +
+ + + + {{ quiz.questions.count }} Fragen +
+ + +
+ + + + {{ quiz.status }} +
+ + +
+ {% if quiz.rating_count > 0 %} + {% for i in '12345'|make_list %} + {% if forloop.counter <= quiz.average_rating|floatformat:0|add:0 %} + + {% else %} + + {% endif %} + {% endfor %} + ({{ quiz.rating_count }}) + {% else %} + Noch keine Bewertungen + {% endif %} +
+
+ + + {% if quiz.authors.all %} +
+ + + + + {% for author in quiz.authors.all %} + {{ author.username }}{% if not forloop.last %}, {% endif %} + {% endfor %} + +
+ {% endif %} + + +
+ {% if quiz.questions.count != 0 %} + + + + + + Spielen + + {% else %} + Fürs Spielen ist min. 1 Frage nötig! + {% endif %} +
+ + + + + + + {% if quiz.user_id == request.user %} + + + + + + + + + + + {% endif %} +
+
+
+
+ {% endfor %} + +
+ + + {% if my_quizzes.paginator.num_pages > 1 %} +
+ {% if my_quizzes.has_previous %} + + + + + + {% endif %} + + Seite {{ my_quizzes.number }} von {{ my_quizzes.paginator.num_pages }} + + {% if my_quizzes.has_next %} + + + + + + {% endif %} +
+ {% endif %} +
+{% endif %} + + + + +{% if user.is_authenticated %} +
+
+

Meine Favoriten

+
+
+
+ +
+
+ {% for quiz in favorite_quizzes %} +
+ +
+ {% if quiz.image %} +
+ +
+
+
+ + + {% else %} +
{{ quiz.name }}
+ {% endif %} + {% if user.is_authenticated %} + {% if quiz.favorite == False %} + +
+ + + + + + +
+ + {% else %} + + {% endif %} + {% endif %} +
+ + + + +
+ +

+ {{ quiz.name }} +

+ +

{{ quiz.description }}

+ + +
+ +
+ + + + {{ quiz.difficulty }} +
+ + +
+ + + + {{ quiz.questions.count }} Fragen +
+ + +
+ + + + {{ quiz.status }} +
+ + +
+ {% if quiz.rating_count > 0 %} + {% for i in '12345'|make_list %} + {% if forloop.counter <= quiz.average_rating|floatformat:0|add:0 %} + + {% else %} + + {% endif %} + {% endfor %} + ({{ quiz.rating_count }}) + {% else %} + Noch keine Bewertungen + {% endif %} +
+
+ + + {% if quiz.authors.all %} +
+ + + + + {% for author in quiz.authors.all %} + {{ author.username }}{% if not forloop.last %}, {% endif %} + {% endfor %} + +
+ {% endif %} + + +
+ {% if quiz.questions.count != 0 %} + + + + + + Spielen + + {% else %} + Fürs Spielen ist min. 1 Frage nötig! + {% endif %} + +
+ + + + + + + {% if quiz.user_id == request.user %} + + + + + + + + + + + {% endif %} +
+
+
+
+ {% endfor %} + +
+ + + {% if favorite_quizzes.paginator.num_pages > 1 %} +
+ {% if favorite_quizzes.has_previous %} + + + + + + {% endif %} + + Seite {{ favorite_quizzes.number }} von {{ favorite_quizzes.paginator.num_pages }} + + {% if favorite_quizzes.has_next %} + + + + + + {% endif %} +
+ {% endif %} +
+{% endif %} + + + + + + + + + + +
+
+

Alle

+
+
+
+ +{% if all_quizzes %} +
+
+ {% for quiz in all_quizzes %} +
+ +
+ {% if quiz.image %} +
+ +
+
+
+ + + + {% else %} +
{{ quiz.name }}
+ {% endif %} + {% if user.is_authenticated %} + {% if quiz.id not in favorite_quiz_ids %} +
+ + + + + + +
+ + {% else %} + + {% endif %} + {% endif %} +
+ + +
+ +

+ {{ quiz.name }} +

+ +

{{ quiz.description }}

+ + +
+ +
+ + + + {{ quiz.difficulty }} +
+ + +
+ + + + {{ quiz.questions.count }} Fragen +
+ + +
+ + + + {{ quiz.status }} +
+ + +
+ {% if quiz.rating_count > 0 %} + {% for i in '12345'|make_list %} + {% if forloop.counter <= quiz.average_rating|floatformat:0|add:0 %} + + {% else %} + + {% endif %} + {% endfor %} + ({{ quiz.rating_count }}) + {% else %} + Noch keine Bewertungen + {% endif %} +
+
+ + + {% if quiz.authors.all %} +
+ + + + + {% for author in quiz.authors.all %} + {{ author.username }}{% if not forloop.last %}, {% endif %} + {% endfor %} + +
+ {% endif %} + + +
+ {% if quiz.questions.count != 0 %} + + + + + + Spielen + + {% else %} + Fürs Spielen ist min. 1 Frage nötig! + {% endif %} + +
+
+
+ {% endfor %} +
+ + + {% if all_quizzes.paginator.num_pages > 1 %} +
+ {% if all_quizzes.has_previous %} + + + + + + {% endif %} + + Seite {{ all_quizzes.number }} von {{ all_quizzes.paginator.num_pages }} + + {% if all_quizzes.has_next %} + + + + + + {% endif %} +
+ {% endif %} +
+{% else %} +
+

Keine öffentlichen Quiz gefunden.

+
+{% endif %} + +{% endblock content %} diff --git a/django/templates/library/overview_quiz.html b/django/templates/library/overview_quiz.html index fdccf30..77eeccc 100644 --- a/django/templates/library/overview_quiz.html +++ b/django/templates/library/overview_quiz.html @@ -13,70 +13,45 @@ {% block content %} - +{% block head %} +{% include 'library/head.html' %} +{% endblock %} -
-
-
- -
- - -
-
- - -
-
- - -
-
- -
-
-
-
- - - -{% if user.is_authenticated %} +
-
-

Eigene Quiz

+ {% if user.is_authenticated %} + +
+ + + +
+ Anzahl aller Ergebnisse: + {{ total_all_found }} +
+ (verschiedene: + {{ total_all }})
+ + + + {% endif %} +
+

Alle

+
+ + +{% if all_quizzes %}
- {% for quiz in my_quizzes %} + {% for quiz in all_quizzes %}
@@ -87,16 +62,17 @@ style="background-image: url({{ quiz.image.image.url }});">
- + + {% else %} -
{{ quiz.name }}
+
{{ quiz.name }}
{% endif %} {% if user.is_authenticated %} {% if quiz.id not in favorite_quiz_ids %} - - - - -
- -

- {{ quiz.name }} -

- -

{{ quiz.description }}

- - -
- -
- - - - {{ quiz.difficulty }} -
- - -
- - - - {{ quiz.questions.count }} Fragen -
- - -
- - - - {{ quiz.status }} -
- - -
- {% if quiz.rating_count > 0 %} - {% for i in '12345'|make_list %} - {% if forloop.counter <= quiz.average_rating|floatformat:0|add:0 %} - - {% else %} - - {% endif %} - {% endfor %} - ({{ quiz.rating_count }}) - {% else %} - Noch keine Bewertungen - {% endif %} -
-
- - - {% if quiz.authors.all %} -
- - - - - {% for author in quiz.authors.all %} - {{ author.username }}{% if not forloop.last %}, {% endif %} - {% endfor %} - -
- {% endif %} - - -
- {% if quiz.questions.count != 0 %} - - - - - - Spielen - - {% else %} - Fürs Spielen ist min. 1 Frage nötig! - {% endif %} -
- - - - - - - {% if quiz.user_id == request.user %} - - - - - - - - - - - {% endif %} -
-
-
- - {% endfor %} - -
- - - {% if my_quizzes.paginator.num_pages > 1 %} -
- {% if my_quizzes.has_previous %} - - - - - - {% endif %} - - Seite {{ my_quizzes.number }} von {{ my_quizzes.paginator.num_pages }} - - {% if my_quizzes.has_next %} - - - - - - {% endif %} -
- {% endif %} -
-{% endif %} - - - - -{% if user.is_authenticated %} -
-
-

Meine Favoriten

-
-
-
- -
-
- {% for quiz in favorite_quizzes %} -
- -
- {% if quiz.image %} -
- -
-
-
- - - {% else %} -
{{ quiz.name }}
- {% endif %} - {% if user.is_authenticated %} - {% if quiz.favorite == False %} - -
- - - - - - -
- - {% else %} - - {% endif %} - {% endif %} -
- - - - -
- -

- {{ quiz.name }} -

- -

{{ quiz.description }}

- - -
- -
- - - - {{ quiz.difficulty }} -
- - -
- - - - {{ quiz.questions.count }} Fragen -
- - -
- - - - {{ quiz.status }} -
- - -
- {% if quiz.rating_count > 0 %} - {% for i in '12345'|make_list %} - {% if forloop.counter <= quiz.average_rating|floatformat:0|add:0 %} - - {% else %} - - {% endif %} - {% endfor %} - ({{ quiz.rating_count }}) - {% else %} - Noch keine Bewertungen - {% endif %} -
-
- - - {% if quiz.authors.all %} -
- - - - - {% for author in quiz.authors.all %} - {{ author.username }}{% if not forloop.last %}, {% endif %} - {% endfor %} - -
- {% endif %} - - -
- {% if quiz.questions.count != 0 %} - - - - - - Spielen - - {% else %} - Fürs Spielen ist min. 1 Frage nötig! - {% endif %} - -
- - - - - - - {% if quiz.user_id == request.user %} - - - - - - - - - - - {% endif %} -
-
-
-
- {% endfor %} - -
- - - {% if favorite_quizzes.paginator.num_pages > 1 %} -
- {% if favorite_quizzes.has_previous %} - - - - - - {% endif %} - - Seite {{ favorite_quizzes.number }} von {{ favorite_quizzes.paginator.num_pages }} - - {% if my_quizzes.has_next %} - - - - - - {% endif %} -
- {% endif %} -
-{% endif %} - - - - - - - - - - -
-
-

Quiz von anderen Nutzern

-
-
-
- -{% if other_quizzes %} -
-
- {% for quiz in other_quizzes %} -
- -
- {% if quiz.image %} -
- -
-
-
- - - - {% else %} -
{{ quiz.name }}
- {% endif %} - {% if user.is_authenticated %} - {% if quiz.id not in favorite_quiz_ids %} -
- - - - - - -
- - {% else %} - - {% if other_quizzes.paginator.num_pages > 1 %} + {% if all_quizzes.paginator.num_pages > 1 %}
- {% if other_quizzes.has_previous %} - @@ -613,10 +198,10 @@ {% endif %} - Seite {{ other_quizzes.number }} von {{ other_quizzes.paginator.num_pages }} + Seite {{ all_quizzes.number }} von {{ all_quizzes.paginator.num_pages }} - {% if other_quizzes.has_next %} - @@ -630,42 +215,54 @@

Keine öffentlichen Quiz gefunden.

-{% endif %} - + + {% endblock content %} diff --git a/django/templates/library/overview_quiz_favorite.html b/django/templates/library/overview_quiz_favorite.html new file mode 100644 index 0000000..990b917 --- /dev/null +++ b/django/templates/library/overview_quiz_favorite.html @@ -0,0 +1,285 @@ +{% extends 'base.html' %} +{% load static %} + +{% block extra_css %} + +{% endblock %} + +{% block content %} + + +{% block head %} +{% include 'library/head.html' %} +{% endblock %} + + + +{% if user.is_authenticated %} + +
+{% if request.user.is_authenticated and favorite_quizzes %} +
+
+ {% for quiz in favorite_quizzes %} +
+ +
+ {% if quiz.image %} +
+ +
+
+
+ + + {% else %} +
{{ quiz.name }}
+ {% endif %} + {% if user.is_authenticated %} + {% if quiz.favorite == False %} + +
+ + + + + + +
+ + {% else %} + + {% endif %} + {% endif %} +
+ + + + +
+ +

+ {{ quiz.name }} +

+ +

{{ quiz.description }}

+ + +
+ +
+ + + + {{ quiz.difficulty }} +
+ + +
+ + + + {{ quiz.questions.count }} Fragen +
+ + +
+ + + + {{ quiz.status }} +
+ + +
+ {% if quiz.rating_count > 0 %} + {% for i in '12345'|make_list %} + {% if forloop.counter <= quiz.average_rating|floatformat:0|add:0 %} + + {% else %} + + {% endif %} + {% endfor %} + ({{ quiz.rating_count }}) + {% else %} + Noch keine Bewertungen + {% endif %} +
+
+ + + {% if quiz.authors.all %} +
+ + + + + {% for author in quiz.authors.all %} + {{ author.username }}{% if not forloop.last %}, {% endif %} + {% endfor %} + +
+ {% endif %} + + +
+ {% if quiz.questions.count != 0 %} + + + + + + Spielen + + {% else %} + Fürs Spielen ist min. 1 Frage nötig! + {% endif %} + +
+ + + + + + + {% if quiz.user_id == request.user %} + + + + + + + + + + + {% endif %} +
+
+
+
+ {% endfor %} + +
+ + + {% if favorite_quizzes.paginator.num_pages > 1 %} +
+ {% if favorite_quizzes.has_previous %} + + + + + + {% endif %} + + Seite {{ favorite_quizzes.number }} von {{ favorite_quizzes.paginator.num_pages }} + + {% if favorite_quizzes.has_next %} + + + + + + {% endif %} +
+ {% endif %} +
+{% else %} +
+

Keine favorisierten Quiz gefunden.

+
+{% endif %} + +{% endblock content %} diff --git a/django/templates/library/overview_quiz_my.html b/django/templates/library/overview_quiz_my.html new file mode 100644 index 0000000..d0e231b --- /dev/null +++ b/django/templates/library/overview_quiz_my.html @@ -0,0 +1,280 @@ +{% extends 'base.html' %} +{% load static %} + +{% block extra_css %} + +{% endblock %} + +{% block content %} + +{% block head %} +{% include 'library/head.html' %} +{% endblock %} + + + +{% if user.is_authenticated %} +
+ +
+ + + +
+ Anzahl aller Ergebnisse: + {{ total_all_found }} +
+ (verschiedene: + {{ total_all }})
+ + + +
+ Alle ({{ total_all }}) +

Meine Quizze ({{ total_my }})

+ Meine Favoriten ({{ total_favorite }}) +
+
+

Meine Quizze

+
+
+
+{% endif %} + +{% if request.user.is_authenticated and my_quizzes %} + +
+
+ {% for quiz in my_quizzes %} +
+ +
+ {% if quiz.image %} +
+ +
+
+
+ + + {% else %} +
{{ quiz.name }}
+ {% endif %} + {% if user.is_authenticated %} + {% if quiz.id not in favorite_quiz_ids %} +
+ + + + + + +
+ + {% else %} + + {% endif %} + {% endif %} +
+ + + + +
+ +

+ {{ quiz.name }} +

+ +

{{ quiz.description }}

+ + +
+ +
+ + + + {{ quiz.difficulty }} +
+ + +
+ + + + {{ quiz.questions.count }} Fragen +
+ + +
+ + + + {{ quiz.status }} +
+ + +
+ {% if quiz.rating_count > 0 %} + {% for i in '12345'|make_list %} + {% if forloop.counter <= quiz.average_rating|floatformat:0|add:0 %} + + {% else %} + + {% endif %} + {% endfor %} + ({{ quiz.rating_count }}) + {% else %} + Noch keine Bewertungen + {% endif %} +
+
+ + + {% if quiz.authors.all %} +
+ + + + + {% for author in quiz.authors.all %} + {{ author.username }}{% if not forloop.last %}, {% endif %} + {% endfor %} + +
+ {% endif %} + + +
+ {% if quiz.questions.count != 0 %} + + + + + + Spielen + + {% else %} + Fürs Spielen ist min. 1 Frage nötig! + {% endif %} +
+ + + + + + + {% if quiz.user_id == request.user %} + + + + + + + + + + + {% endif %} +
+
+
+
+ {% endfor %} + +
+ + + {% if my_quizzes.paginator.num_pages > 1 %} +
+ {% if my_quizzes.has_previous %} + + + + + + {% endif %} + + Seite {{ my_quizzes.number }} von {{ my_quizzes.paginator.num_pages }} + + {% if my_quizzes.has_next %} + + + + + + {% endif %} +
+ {% endif %} +
+{% else %} +
+

Keine eigenen Quiz gefunden.

+
+{% endif %} + + +{% endblock content %} diff --git a/django/templates/partials/_nav.html b/django/templates/partials/_nav.html index beec646..500ee02 100644 --- a/django/templates/partials/_nav.html +++ b/django/templates/partials/_nav.html @@ -10,7 +10,7 @@