aboutsummaryrefslogtreecommitdiffstats
path: root/pyblackbird_cc/users/forms.py
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-05-13 17:26:25 +0100
committerMatthew Lemon <y@yulqen.org>2024-05-13 17:26:25 +0100
commitefbbd480ddc62e695123d31c31d233b0df5155bd (patch)
treebc2fb465edd5050d83c97f280b1aac8e023fe3e5 /pyblackbird_cc/users/forms.py
After first pre-commit processing
Diffstat (limited to 'pyblackbird_cc/users/forms.py')
-rw-r--r--pyblackbird_cc/users/forms.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/pyblackbird_cc/users/forms.py b/pyblackbird_cc/users/forms.py
new file mode 100644
index 0000000..fe8a886
--- /dev/null
+++ b/pyblackbird_cc/users/forms.py
@@ -0,0 +1,44 @@
+from allauth.account.forms import SignupForm
+from allauth.socialaccount.forms import SignupForm as SocialSignupForm
+from django.contrib.auth import forms as admin_forms
+from django.forms import EmailField
+from django.utils.translation import gettext_lazy as _
+
+from .models import User
+
+
+class UserAdminChangeForm(admin_forms.UserChangeForm):
+ class Meta(admin_forms.UserChangeForm.Meta):
+ model = User
+ field_classes = {"email": EmailField}
+
+
+class UserAdminCreationForm(admin_forms.UserCreationForm):
+ """
+ Form for User Creation in the Admin Area.
+ To change user signup, see UserSignupForm and UserSocialSignupForm.
+ """
+
+ class Meta(admin_forms.UserCreationForm.Meta):
+ model = User
+ fields = ("email",)
+ field_classes = {"email": EmailField}
+ error_messages = {
+ "email": {"unique": _("This email has already been taken.")},
+ }
+
+
+class UserSignupForm(SignupForm):
+ """
+ Form that will be rendered on a user sign up section/screen.
+ Default fields will be added automatically.
+ Check UserSocialSignupForm for accounts created from social.
+ """
+
+
+class UserSocialSignupForm(SocialSignupForm):
+ """
+ Renders the form when user has signed up using social accounts.
+ Default fields will be added automatically.
+ See UserSignupForm otherwise.
+ """