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,001 B
Python
Raw Normal View History

2023-12-19 13:49:34 +01:00
from crispy_forms import helper, layout
2023-12-18 23:05:49 +01:00
from django.contrib.auth.forms import AuthenticationForm, 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
# from .models import User
class LoginForm(AuthenticationForm):
2023-12-19 13:49:34 +01:00
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = helper.FormHelper()
self.helper.form_action = "accounts:login"
2023-12-19 13:49:34 +01:00
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
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()
self.helper.form_action = "accounts:register"
2023-12-19 13:49:34 +01:00
self.helper.form_method = "post"
2024-01-29 21:52:57 +01:00
self.helper.add_input(layout.Submit('submit', _('Register')))