CRUD Operations for Library models

This commit is contained in:
Juhn-Vitus Saß
2025-03-08 11:12:03 +01:00
parent a782f97f38
commit f441406a18
13 changed files with 1343 additions and 7 deletions

View File

@@ -9,7 +9,9 @@
</head>
<body>
{% include 'homepage/partials/_nav.html' %}
{% block content%}{% endblock %}
<div class="max-w-screen-lg mx-auto">
{% block content%}{% endblock %}
</div>
{% include 'homepage/partials/_footer.html' %}
</body>
</html>

View File

@@ -0,0 +1,11 @@
{% extends 'library/base.html' %}
{% block content %}
<h1>Löschen</h1>
<p>Soll das Quiz "{{ object.name }}" wirklich gelöscht werden?</p>
<form method="post">
{% csrf_token %}
<button type="submit">Löschen</button>
<a href="{% url 'library:overview_quiz' %}">Abbrechen</a>
</form>
{% endblock %}

View File

@@ -0,0 +1,19 @@
{% extends 'library/base.html' %}
{% block content %}
<h1>{{ quiz.name }}</h1>
<p>{{ quiz.description }}</p>
<a href="{% url 'library:edit_quiz' quiz.id %}">Bearbeiten</a>
<a href="{% url 'library:delete_quiz' quiz.id %}">Löschen</a>
<h2>Fragen</h2>
<ul>
<a href="{% url 'library:new_question' %}">Neue Frage erstellen</a>
{% for question in questions %}
<li>{{ question.data }}</li>
<a href="{% url 'library:edit_question' question.id %}">Bearbeiten</a>
<a href="{% url 'library:delete_question' question.id %}">Löschen</a>
{% endfor %}
</ul>
{% endblock %}

View File

@@ -0,0 +1,13 @@
{% extends 'library/base.html' %}
{% block content %}
<h1>Formular</h1>
<h2>{{ form.name.value }}</h2>
<div class="input-group">
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Speichern</button>
</form>
</div>
{% endblock %}

View File

@@ -0,0 +1,19 @@
{% extends 'library/base.html' %}
{% block content %}
<h1>Übersicht</h1>
<div class="flex justify-end">
<a href="{% url 'library:new_quiz' %}" class="bg-blue-500 text-white px-4 py-2 rounded-md">Neues Quiz erstellen</a>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
{% for quiz in quizzes %}
<div class="bg-white rounded-lg p-4 shadow-md">
<h2 class="text-lg font-bold"><a href="{% url 'library:detail_quiz' quiz.id %}">{{ quiz.name }}</a></h2>
<p class="text-sm text-gray-600">{{ quiz.description }}</p>
<a href="#">Spiel starten</a>
<a href="{% url 'library:edit_quiz' quiz.id %}">Bearbeiten</a>
<a href="{% url 'library:delete_quiz' quiz.id %}">Löschen</a>
</div>
{% endfor %}
</div>
{% endblock %}