From c93b6f08562eb35a3bc341ca79ea219e108db3a5 Mon Sep 17 00:00:00 2001 From: Kristofers Solo Date: Thu, 29 Jun 2023 21:46:34 +0000 Subject: [PATCH] Update forms --- src/apps/account/forms.py | 67 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/src/apps/account/forms.py b/src/apps/account/forms.py index 520379c..caf7202 100644 --- a/src/apps/account/forms.py +++ b/src/apps/account/forms.py @@ -1,8 +1,8 @@ from django import forms -from django.contrib.auth.forms import AuthenticationForm, UserCreationForm +from django.contrib.auth.forms import AuthenticationForm, UserChangeForm as BaseUserChangeForm, UserCreationForm -from .models import User +from .models import Profile, User class LoginForm(AuthenticationForm): @@ -68,3 +68,66 @@ class SignUpForm(UserCreationForm): "password1": "", "password2": "", } + + +class UserChangeForm(BaseUserChangeForm): + class Meta(BaseUserChangeForm.Meta): + model = User + fields = ( + "username", + "email", + "first_name", + "last_name", + ) + widgets = { + "username": forms.TextInput( + attrs={ + "placeholder": "Username", + "class": "form-field submit-form", + } + ), + "email": forms.EmailInput( + attrs={ + "placeholder": "Email", + "class": "form-field submit-form", + } + ), + "first_name": forms.TextInput( + attrs={ + "placeholder": "First Name", + "class": "form-field submit-form", + } + ), + "last_name": forms.TextInput( + attrs={ + "placeholder": "Last Name", + "class": "form-field submit-form", + } + ), + } + labels = { + "username": "", + "email": "", + "first_name": "", + "last_name": "", + } + + help_text = { + "username": None, + "email": None, + "first_name": None, + "last_name": None, + } + + +class ProfileForm(forms.ModelForm): + class Meta: + model = Profile + fields = ("picture",) + labels = { + "picture": "", + } + + help_text = { + "picture": None, + }