Implement group management features and update templates for improved navigation

This commit is contained in:
Edgar P. Burkhart 2025-06-15 09:56:08 +02:00
parent f3e914aed8
commit 088bb52c07
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
9 changed files with 80 additions and 37 deletions

View file

@ -0,0 +1,11 @@
{% for error in form.non_field_errors %}<article class="message error">{{ error }}</article>{% endfor %}
<form method="post" {% if action %}action="{% url action %}"{% endif %}>
{% csrf_token %}
<fieldset role="group">
{% for field in form %}{{ field }}{% endfor %}
<input type="submit" {% if submit %}value="{{ submit }}"{% endif %}>
{% if field.errors %}
<small id="{{ field.errors.field_id }}_error" class="form-error">{{ field.errors|join:", " }}</small>
{% endif %}
</fieldset>
</form>

View file

@ -4,7 +4,7 @@
<i class="ri-music-ai-fill big-logo"></i>
<h1>Musik</h1>
<p>
<a href="{% url "login" %}" role="button"><i class="ri-play-fill"></i> Jouer</a>
<a href="{% url "home" %}" role="button"><i class="ri-play-fill"></i> Jouer</a>
</p>
</main>
<footer>

View file

@ -1,11 +1,4 @@
{% extends "base.html" %}
{% block content %}
{% include "game/home.html" %}
{% endblock content %}
{% block body %}
{% if user.is_authenticated %}
{{ block.super }}
{% else %}
{% include "hero.html" %}
{% endif %}
{% include "hero.html" %}
{% endblock body %}

View file

@ -4,8 +4,13 @@ register = template.Library()
@register.inclusion_tag("base/form.html")
def form(form, **kwargs):
def form(f, **kwargs):
return kwargs | {
"form": form,
"errors": form.errors,
"form": f,
"errors": f.errors,
}
@register.inclusion_tag("base/inline_form.html")
def inline_form(f, **kwargs):
return form(f, **kwargs)

View file

@ -1,5 +1,6 @@
from django.contrib.auth.models import User
from django.contrib.messages.views import SuccessMessageMixin
from django.shortcuts import redirect
from django.urls import reverse_lazy
from django.views.generic.base import TemplateView
from django.views.generic.edit import CreateView
@ -10,6 +11,11 @@ from . import forms
class HomePageView(TemplateView):
template_name = "index.html"
def dispatch(self, request, *args, **kwargs):
if request.user.is_authenticated:
return redirect("home")
return super().dispatch(request, *args, **kwargs)
class SignupView(SuccessMessageMixin, CreateView):
model = User