|
|
@@ -9,8 +9,9 @@ from accounts.models import InvitationCode
|
|
|
class ReyMotaUserCreationForm(UserCreationForm):
|
|
|
invitation_code = forms.CharField(
|
|
|
max_length=32,
|
|
|
+ required=False,
|
|
|
label="Código de Invitación",
|
|
|
- help_text="Introduce el código que has recibido"
|
|
|
+ help_text="Introduce el código que has recibido (opcional)"
|
|
|
)
|
|
|
|
|
|
class Meta:
|
|
|
@@ -27,7 +28,7 @@ class ReyMotaUserCreationForm(UserCreationForm):
|
|
|
def clean_invitation_code(self):
|
|
|
code = self.cleaned_data.get('invitation_code')
|
|
|
if not code:
|
|
|
- raise ValidationError("El código de invitación es obligatorio.")
|
|
|
+ return code
|
|
|
|
|
|
try:
|
|
|
invitation = InvitationCode.objects.get(code=code)
|
|
|
@@ -46,8 +47,9 @@ class ReyMotaUserCreationForm(UserCreationForm):
|
|
|
if commit:
|
|
|
user.save()
|
|
|
code = self.cleaned_data.get('invitation_code')
|
|
|
- invitation = InvitationCode.objects.get(code=code)
|
|
|
- invitation.mark_as_used(user)
|
|
|
+ if code:
|
|
|
+ invitation = InvitationCode.objects.get(code=code)
|
|
|
+ invitation.mark_as_used(user)
|
|
|
return user
|
|
|
|
|
|
|