From c70deac834a0cc6fd84c89cd9543a972e2d5a4d5 Mon Sep 17 00:00:00 2001 From: Raz Date: Tue, 10 Dec 2024 17:26:10 +0100 Subject: [PATCH] login button --- tournaments/forms.py | 14 ++++++++ tournaments/static/tournaments/css/style.css | 32 +++++++++++++++++++ tournaments/templates/profile.html | 26 ++++++++++----- tournaments/templates/tournaments/base.html | 5 ++- .../tournaments/navigation_base.html | 1 - .../tournaments/navigation_tournament.html | 9 +++++- .../tournaments/tournament_info.html | 3 -- tournaments/views.py | 4 +-- 8 files changed, 78 insertions(+), 16 deletions(-) diff --git a/tournaments/forms.py b/tournaments/forms.py index db57a06..21d95f7 100644 --- a/tournaments/forms.py +++ b/tournaments/forms.py @@ -140,6 +140,11 @@ class CustomPasswordResetForm(PasswordResetForm): send_mail(subject, message, None, [user.email]) class ProfileUpdateForm(forms.ModelForm): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + # Remove autofocus from the 'username' field + self.fields['username'].widget.attrs.pop("autofocus", None) + class Meta: model = CustomUser fields = ['first_name', 'last_name', 'licence_id', 'username', 'email', 'phone'] @@ -151,3 +156,12 @@ class ProfileUpdateForm(forms.ModelForm): 'last_name': 'Nom de famille', 'licence_id': 'Numéro de licence', } + +from django.contrib.auth.forms import PasswordChangeForm + +class CustomPasswordChangeForm(PasswordChangeForm): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + # Remove autofocus from all fields in the PasswordChangeForm + for field in self.fields.values(): + field.widget.attrs.pop("autofocus", None) diff --git a/tournaments/static/tournaments/css/style.css b/tournaments/static/tournaments/css/style.css index 3998cf8..38ad109 100644 --- a/tournaments/static/tournaments/css/style.css +++ b/tournaments/static/tournaments/css/style.css @@ -725,3 +725,35 @@ h-margin { background-color: #cc0000; /* Darker red on hover */ color: white; /* White text on hover */ } + +.top-link { + display: block; + text-align: center; + margin-top: 10px; + font-style: italic; + text-decoration: underline; +} + +.login-buttons { + position: relative; + display: flex; + margin-left: 10px; + gap: 10px; + padding: 0px; +} + +.login-buttons .button { + display: block; + padding: 8px 8px; + border: none; + background: none; + border-radius: 4px; + text-align: center; + text-decoration: underline; + color: #333; + transition: background 0.2s; +} + +.login-buttons .button:hover { + background: #f39200; +} diff --git a/tournaments/templates/profile.html b/tournaments/templates/profile.html index f2ce22c..b3b68ad 100644 --- a/tournaments/templates/profile.html +++ b/tournaments/templates/profile.html @@ -5,24 +5,34 @@ {% block content %} -{% include 'tournaments/navigation_base.html' %} + {% load static %} {% load tz %} -
-
-
- +
+
+
{% csrf_token %} {{ form.as_p }}
-
-
- +
+
+
+
{% csrf_token %} {{ password_change_form.as_p }} diff --git a/tournaments/templates/tournaments/base.html b/tournaments/templates/tournaments/base.html index 14cf3de..ee1dec2 100644 --- a/tournaments/templates/tournaments/base.html +++ b/tournaments/templates/tournaments/base.html @@ -1,5 +1,7 @@ + + {% load static %} @@ -54,7 +56,8 @@
- {% block right_header %}{% endblock %} + {% block right_header %} + {% endblock %}
diff --git a/tournaments/templates/tournaments/navigation_base.html b/tournaments/templates/tournaments/navigation_base.html index d895f8a..93caba6 100644 --- a/tournaments/templates/tournaments/navigation_base.html +++ b/tournaments/templates/tournaments/navigation_base.html @@ -5,7 +5,6 @@ {% if user.is_authenticated %} Mes tournois Mon compte - Se déconnecter {% else %} Se connecter {% endif %} diff --git a/tournaments/templates/tournaments/navigation_tournament.html b/tournaments/templates/tournaments/navigation_tournament.html index b219178..b916e4f 100644 --- a/tournaments/templates/tournaments/navigation_tournament.html +++ b/tournaments/templates/tournaments/navigation_tournament.html @@ -1,3 +1,11 @@ + + diff --git a/tournaments/templates/tournaments/tournament_info.html b/tournaments/templates/tournaments/tournament_info.html index 6bea844..e887060 100644 --- a/tournaments/templates/tournaments/tournament_info.html +++ b/tournaments/templates/tournaments/tournament_info.html @@ -45,9 +45,6 @@

{% endif %} -
{{ tournament.build_tournament_details_str|linebreaksbr }}
-
{{ tournament.build_name_details_str|linebreaksbr }}
- {% if tournament.online_register_is_enabled %}

diff --git a/tournaments/views.py b/tournaments/views.py index 77ce041..8122af5 100644 --- a/tournaments/views.py +++ b/tournaments/views.py @@ -1000,7 +1000,7 @@ def my_tournaments(request): 'user_name': user.username }) -from django.contrib.auth.forms import PasswordChangeForm +from .forms import CustomPasswordChangeForm class ProfileUpdateView(UpdateView): model = CustomUser @@ -1013,5 +1013,5 @@ class ProfileUpdateView(UpdateView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - context['password_change_form'] = PasswordChangeForm(user=self.request.user) + context['password_change_form'] = CustomPasswordChangeForm(user=self.request.user) return context