This repository has been archived on 2025-03-03. You can view files and clone it, but cannot push or open issues or pull requests.
facturio/accounts/forms.py

31 lines
1 KiB
Python
Raw Normal View History

2024-02-03 22:07:20 +01:00
from crispy_forms import helper
from crispy_forms import layout
from django.contrib.auth.forms import AuthenticationForm
from django.contrib.auth.forms import UserCreationForm
2024-01-29 21:52:57 +01:00
from django.utils.translation import gettext_lazy as _
2023-12-18 23:05:49 +01:00
2023-12-19 13:49:34 +01:00
from .models import User
2023-12-18 23:05:49 +01:00
class LoginForm(AuthenticationForm):
2023-12-19 13:49:34 +01:00
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = helper.FormHelper()
2024-02-03 22:07:20 +01:00
self.helper.form_action = 'accounts:login'
self.helper.form_method = 'post'
2024-01-29 21:52:57 +01:00
self.helper.add_input(layout.Submit('submit', _('Login')))
2023-12-19 13:49:34 +01:00
class RegisterForm(UserCreationForm):
class Meta:
model = User
2024-08-16 22:12:49 +02:00
fields = UserCreationForm.Meta.fields + \
('first_name', 'last_name', 'email')
2023-12-18 23:05:49 +01:00
2023-12-19 13:49:34 +01:00
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = helper.FormHelper()
2024-02-03 22:07:20 +01:00
self.helper.form_action = 'accounts:register'
self.helper.form_method = 'post'
2024-01-29 21:52:57 +01:00
self.helper.add_input(layout.Submit('submit', _('Register')))