Favoriten_nur_wenn_angemeldet!

This commit is contained in:
ben8
2025-04-11 20:29:55 +02:00
parent 1f3b551b94
commit d53240c710
2 changed files with 17 additions and 5 deletions

View File

@@ -180,10 +180,17 @@ def favorite_quiz(request, pk):
favorite.save() favorite.save()
else: else:
QivipQuizFavorite.objects.create(user=request.user, quiz=quiz, favorite=True, favorite_date=timezone.now()) QivipQuizFavorite.objects.create(user=request.user, quiz=quiz, favorite=True, favorite_date=timezone.now())
"""
referer = request.META.get('HTTP_REFERER')
if referer and 'library/' in referer:
return redirect(request.META.get('HTTP_REFERER', 'library:overview_quiz'))
else:
return overview_quiz(request)
"""
return redirect(request.META.get('HTTP_REFERER', 'library:overview_quiz')) return redirect(request.META.get('HTTP_REFERER', 'library:overview_quiz'))
# Neues Quiz erstellen # Neues Quiz erstellen
@login_required @login_required
def new_quiz(request): def new_quiz(request):

View File

@@ -104,6 +104,7 @@
{% else %} {% else %}
<div class="h-full bg-gradient-to-r from-blue-500 to-blue-600"></div> <div class="h-full bg-gradient-to-r from-blue-500 to-blue-600"></div>
{% endif %} {% endif %}
{% if user.is_authenticated %}
{% if quiz.id not in favorite_quiz_ids %} {% if quiz.id not in favorite_quiz_ids %}
<div class="absolute top-4 right-4 bg-white bg-opacity-60 text-white px-4 py-2 rounded-lg shadow-lg"> <div class="absolute top-4 right-4 bg-white bg-opacity-60 text-white px-4 py-2 rounded-lg shadow-lg">
@@ -123,6 +124,7 @@
</a> </a>
</div> </div>
{% endif %} {% endif %}
{% endif %}
</div> </div>
@@ -207,7 +209,7 @@
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" /> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
</svg> </svg>
</a> </a>
{% if quiz.user == request.user %} {% if quiz.user_id == request.user %}
<a href="{% url 'library:edit_quiz' quiz.id %}" <a href="{% url 'library:edit_quiz' quiz.id %}"
class="p-1.5 bg-gray-100 hover:bg-gray-200 text-gray-700 rounded-lg transition-colors duration-200"> class="p-1.5 bg-gray-100 hover:bg-gray-200 text-gray-700 rounded-lg transition-colors duration-200">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
@@ -285,7 +287,7 @@
{% else %} {% else %}
<div class="h-full bg-gradient-to-r from-blue-500 to-blue-600"></div> <div class="h-full bg-gradient-to-r from-blue-500 to-blue-600"></div>
{% endif %} {% endif %}
{% if user.is_authenticated %}
{% if quiz.favorite == False %} {% if quiz.favorite == False %}
<div class="absolute top-4 right-4 bg-white bg-opacity-60 text-white px-4 py-2 rounded-lg shadow-lg"> <div class="absolute top-4 right-4 bg-white bg-opacity-60 text-white px-4 py-2 rounded-lg shadow-lg">
@@ -306,6 +308,7 @@
</a> </a>
</div> </div>
{% endif %} {% endif %}
{% endif %}
</div> </div>
@@ -390,7 +393,7 @@
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" /> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
</svg> </svg>
</a> </a>
{% if quiz.user == request.user %} {% if quiz.user_id == request.user %}
<a href="{% url 'library:edit_quiz' quiz.id %}" <a href="{% url 'library:edit_quiz' quiz.id %}"
class="p-1.5 bg-gray-100 hover:bg-gray-200 text-gray-700 rounded-lg transition-colors duration-200"> class="p-1.5 bg-gray-100 hover:bg-gray-200 text-gray-700 rounded-lg transition-colors duration-200">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
@@ -475,6 +478,7 @@
{% else %} {% else %}
<div class="h-full bg-gradient-to-r from-blue-500 to-blue-600"></div> <div class="h-full bg-gradient-to-r from-blue-500 to-blue-600"></div>
{% endif %} {% endif %}
{% if user.is_authenticated %}
{% if quiz.id not in favorite_quiz_ids %} {% if quiz.id not in favorite_quiz_ids %}
<div class="absolute top-4 right-4 bg-white bg-opacity-60 text-white px-4 py-2 rounded-lg shadow-lg"> <div class="absolute top-4 right-4 bg-white bg-opacity-60 text-white px-4 py-2 rounded-lg shadow-lg">
@@ -494,6 +498,7 @@
</a> </a>
</div> </div>
{% endif %} {% endif %}
{% endif %}
</div> </div>
<!-- Content Section (Bottom) --> <!-- Content Section (Bottom) -->