First commit

This commit is contained in:
mrtoine 2025-09-12 11:07:53 +02:00
commit 440f5a7df4
1563 changed files with 217996 additions and 0 deletions

56
users/forms.py Normal file
View file

@ -0,0 +1,56 @@
from django import forms
from django.contrib.auth.models import User
from .models import Profile
class UserRegistrationForm(forms.Form):
username = forms.CharField(
label='Username',
max_length=150,
widget=forms.TextInput(attrs={'class': 'form-group'})
)
email = forms.EmailField(
label='Email',
widget=forms.EmailInput(attrs={'class': 'form-group'})
)
password1 = forms.CharField(
label='Password',
widget=forms.PasswordInput(attrs={'class': 'form-group'})
)
password2 = forms.CharField(
label='Confirm Password',
widget=forms.PasswordInput(attrs={'class': 'form-group'})
)
def clean(self):
cleaned_data = super().clean()
password1 = cleaned_data.get("password1")
password2 = cleaned_data.get("password2")
if password1 and password2 and password1 != password2:
raise forms.ValidationError("Passwords do not match")
class UserLoginForm(forms.Form):
username = forms.CharField(
label='Username',
max_length=150,
widget=forms.TextInput(attrs={'class': 'form-group'})
)
password = forms.CharField(
label='Password',
widget=forms.PasswordInput(attrs={'class': 'form-group'})
)
class UserUpdateForm(forms.ModelForm):
class Meta:
model = User
fields = ['username', 'email']
class ProfileUpdateForm(forms.ModelForm):
class Meta:
model = Profile
fields = ['avatar', 'biography']
class CompleteProfileForm(forms.ModelForm):
class Meta:
model = Profile
fields = ['avatar', 'first_name', 'last_name', 'birth_date', 'biography']