From c1041d6485376598301d866575897c81e09ad2c4 Mon Sep 17 00:00:00 2001 From: Ivan Kaziev Date: Mon, 22 Apr 2024 20:04:10 +0300 Subject: [PATCH] Create password change form --- CineSync/templates/users/login.html | 3 -- CineSync/templates/users/password_change.html | 12 +++++++ .../templates/users/password_change_done.html | 15 ++++++++ CineSync/templates/users/profile.html | 2 +- CineSync/users/forms.py | 12 ------- CineSync/users/urls.py | 34 ------------------- 6 files changed, 28 insertions(+), 50 deletions(-) create mode 100644 CineSync/templates/users/password_change.html create mode 100644 CineSync/templates/users/password_change_done.html diff --git a/CineSync/templates/users/login.html b/CineSync/templates/users/login.html index 9c147bc..273e487 100644 --- a/CineSync/templates/users/login.html +++ b/CineSync/templates/users/login.html @@ -28,9 +28,6 @@ {% endcomment %}
- Восстановить - пароль Создать аккаунт diff --git a/CineSync/templates/users/password_change.html b/CineSync/templates/users/password_change.html new file mode 100644 index 0000000..0b0b715 --- /dev/null +++ b/CineSync/templates/users/password_change.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} +{% load static %} +{% block title %} +Изменить пароль +{% endblock title %} +{% block content %} + +
+

Смена пароля

+ {% include "includes/form.html" with form=form %} +
+{% endblock %} diff --git a/CineSync/templates/users/password_change_done.html b/CineSync/templates/users/password_change_done.html new file mode 100644 index 0000000..fc9b0bf --- /dev/null +++ b/CineSync/templates/users/password_change_done.html @@ -0,0 +1,15 @@ +{% extends "base.html" %} +{% load static %} +{% block title %} +Смена пароля +{% endblock %} +{% block content %} + +
+
+

Пароль успешно изменен

+ + На главную +
+
+{% endblock %} \ No newline at end of file diff --git a/CineSync/templates/users/profile.html b/CineSync/templates/users/profile.html index 16b327a..0ab2c0a 100644 --- a/CineSync/templates/users/profile.html +++ b/CineSync/templates/users/profile.html @@ -46,6 +46,6 @@ Выйти - Сменить пароль + Сменить пароль {% endblock content %} \ No newline at end of file diff --git a/CineSync/users/forms.py b/CineSync/users/forms.py index f60bcdf..d4ede70 100644 --- a/CineSync/users/forms.py +++ b/CineSync/users/forms.py @@ -3,12 +3,10 @@ from django.contrib.auth import get_user_model from django.contrib.auth.forms import ( AuthenticationForm, PasswordChangeForm, - PasswordResetForm, SetPasswordForm, UserChangeForm, UserCreationForm, ) -from django.forms import DateInput from users.models import Profile @@ -45,16 +43,6 @@ class CustomSetPasswordForm(SetPasswordForm): fields = ('old_password', 'new_password', 'approve_new_password') -class CustomPasswordResetForm(PasswordResetForm): - def __init__(self, *args, **kwargs) -> None: - super().__init__(*args, **kwargs) - for field in self.visible_fields(): - field.field.widget.attrs['class'] = 'form-control' - - class Meta(forms.ModelForm): - fields = ('old_password', 'new_password', 'approve_new_password') - - class SignUpForm(UserCreationForm): def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) diff --git a/CineSync/users/urls.py b/CineSync/users/urls.py index 2ae37e0..95ac139 100644 --- a/CineSync/users/urls.py +++ b/CineSync/users/urls.py @@ -6,7 +6,6 @@ from django.urls import reverse_lazy from users.forms import ( CustomAuthenticationForm, CustomPasswordChangeForm, - CustomPasswordResetForm, CustomSetPasswordForm, ) from users.views import profile, signup @@ -48,39 +47,6 @@ urlpatterns = [ ), name='password_change_done', ), - path( - 'password_reset/', - views.PasswordResetView.as_view( - template_name='users/password_reset.html', - email_template_name='users/password_reset_email.html', - form_class=CustomPasswordResetForm, - success_url=reverse_lazy('users:password_reset_done'), - ), - name='password_reset', - ), - path( - 'password_reset/done/', - views.PasswordResetDoneView.as_view( - template_name='users/password_reset_done.html', - ), - name='password_reset_done', - ), - path( - 'password_reset_confirm///', - views.PasswordResetConfirmView.as_view( - form_class=CustomSetPasswordForm, - template_name='users/password_reset_confirm.html', - success_url=reverse_lazy('users:password_reset_confirm_complete'), - ), - name='password_reset_confirm', - ), - path( - 'password_reset_complete/done/', - views.PasswordResetCompleteView.as_view( - template_name='users/password_reset_complete.html', - ), - name='password_reset_complete', - ), path('signup/', signup, name='signup'), path('profile/', login_required(profile), name='profile'), ]