finished conversion to tailwind
This commit is contained in:
parent
6e2843c60e
commit
d62956d465
50 changed files with 2490 additions and 1273 deletions
|
|
@ -3,17 +3,11 @@ from django.contrib.auth.forms import UserCreationForm, UserChangeForm
|
|||
from .models import CustomUser, FriendCode
|
||||
from allauth.account.forms import SignupForm
|
||||
|
||||
class CustomUserCreationForm(UserCreationForm):
|
||||
|
||||
class Meta(UserCreationForm.Meta):
|
||||
model = CustomUser
|
||||
fields = ('email',)
|
||||
|
||||
class CustomUserChangeForm(UserChangeForm):
|
||||
|
||||
class Meta:
|
||||
model = CustomUser
|
||||
fields = ('email',)
|
||||
fields = ['email']
|
||||
|
||||
class FriendCodeForm(forms.ModelForm):
|
||||
class Meta:
|
||||
|
|
@ -30,7 +24,12 @@ class FriendCodeForm(forms.ModelForm):
|
|||
friend_code_formatted = f"{friend_code_clean[:4]}-{friend_code_clean[4:8]}-{friend_code_clean[8:12]}-{friend_code_clean[12:16]}"
|
||||
return friend_code_formatted
|
||||
|
||||
class CustomSignupForm(SignupForm):
|
||||
class CustomUserCreationForm(SignupForm):
|
||||
|
||||
class Meta(UserCreationForm.Meta):
|
||||
model = CustomUser
|
||||
fields = ['email', 'username', 'friend_code']
|
||||
|
||||
friend_code = forms.CharField(
|
||||
max_length=19,
|
||||
required=True,
|
||||
|
|
@ -41,9 +40,6 @@ class CustomSignupForm(SignupForm):
|
|||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
# Remove the username field completely.
|
||||
if "username" in self.fields:
|
||||
del self.fields["username"]
|
||||
|
||||
def clean_friend_code(self):
|
||||
friend_code = self.cleaned_data.get("friend_code", "").strip().replace("-", "")
|
||||
|
|
@ -54,10 +50,12 @@ class CustomSignupForm(SignupForm):
|
|||
|
||||
def save(self, request):
|
||||
# First, complete the normal signup process.
|
||||
user = super().save(request)
|
||||
user = super(CustomUserCreationForm, self).save(request)
|
||||
# Create the associated FriendCode record.
|
||||
FriendCode.objects.create(
|
||||
friend_code_pk = FriendCode.objects.create(
|
||||
friend_code=self.cleaned_data["friend_code"],
|
||||
user=user
|
||||
)
|
||||
user.default_friend_code = friend_code_pk
|
||||
user.save()
|
||||
return user
|
||||
Loading…
Add table
Add a link
Reference in a new issue