From 34c28ac7a7ab8561aa5e98e01b179ca19ad12e62 Mon Sep 17 00:00:00 2001 From: Raz Date: Tue, 25 Mar 2025 06:59:55 +0100 Subject: [PATCH] fix logout and signup --- tournaments/forms.py | 2 ++ tournaments/templates/profile.html | 2 +- tournaments/urls.py | 2 +- tournaments/views.py | 5 +++++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tournaments/forms.py b/tournaments/forms.py index 3cfcd21..c891afd 100644 --- a/tournaments/forms.py +++ b/tournaments/forms.py @@ -11,6 +11,7 @@ from django.contrib.sites.shortcuts import get_current_site from django.utils.encoding import force_bytes class CustomUserCreationForm(UserCreationForm): + usable_password = None class Meta: model = CustomUser @@ -30,6 +31,7 @@ class CustomUserCreationForm(UserCreationForm): fields = UserCreationForm.Meta.fields + ('umpire_code', 'clubs', 'phone', 'first_name', 'last_name', 'licence_id', 'country') class SimpleCustomUserCreationForm(UserCreationForm): + usable_password = None class Meta: model = CustomUser diff --git a/tournaments/templates/profile.html b/tournaments/templates/profile.html index 98c3fe8..89fd5f4 100644 --- a/tournaments/templates/profile.html +++ b/tournaments/templates/profile.html @@ -11,7 +11,7 @@ {% if user.is_authenticated %} Mes tournois Mon compte - Se déconnecter + Se déconnecter {% else %} Se connecter {% endif %} diff --git a/tournaments/urls.py b/tournaments/urls.py index 700c4d6..7821b39 100644 --- a/tournaments/urls.py +++ b/tournaments/urls.py @@ -62,7 +62,7 @@ urlpatterns = [ ), name='password_change' ), - path('logout/', auth_views.LogoutView.as_view(), name='logout'), + path('logout/', views.custom_logout, name='custom_logout'), path('signup/', views.signup, name='signup'), # URL pattern for signup # path('profile/', views.profile, name='profile'), # URL pattern for signup path('my-tournaments/', views.my_tournaments, name='my-tournaments'), # URL pattern for signup diff --git a/tournaments/views.py b/tournaments/views.py index 75424ab..92e62f7 100644 --- a/tournaments/views.py +++ b/tournaments/views.py @@ -1049,6 +1049,11 @@ def tournament_prog(request, tournament_id): } return render(request, 'tournaments/prog.html', context) +def custom_logout(request): + from django.contrib.auth import logout + logout(request) + return redirect('index') # or whatever URL you want to redirect to + class UserListExportView(LoginRequiredMixin, View): def get(self, request, *args, **kwargs): users = CustomUser.objects.order_by('date_joined')