Removed access code from registration form
This commit is contained in:
parent
c2229c4214
commit
43fd4f1cb6
|
@ -56,26 +56,11 @@ class RegistrationForm(forms.ModelForm):
|
||||||
widget=forms.PasswordInput)
|
widget=forms.PasswordInput)
|
||||||
password2 = forms.CharField(label=_('Repeat password'),
|
password2 = forms.CharField(label=_('Repeat password'),
|
||||||
widget=forms.PasswordInput)
|
widget=forms.PasswordInput)
|
||||||
access_code = forms.CharField(label=_('Invitation code'), required=True)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.User
|
model = models.User
|
||||||
fields = ('email', 'username', )
|
fields = ('email', 'username', )
|
||||||
|
|
||||||
def get_access_code(self):
|
|
||||||
try:
|
|
||||||
return models.AccessCode.objects.get(
|
|
||||||
code=self.cleaned_data['access_code'])
|
|
||||||
except models.AccessCode.DoesNotExist:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def clean_access_code(self):
|
|
||||||
code = self.get_access_code()
|
|
||||||
if not code or (code and not code.usable):
|
|
||||||
raise forms.ValidationError(_('Invitation code is not valid'))
|
|
||||||
|
|
||||||
return self.cleaned_data['access_code']
|
|
||||||
|
|
||||||
def clean_password2(self):
|
def clean_password2(self):
|
||||||
# Check that the two password entries match
|
# Check that the two password entries match
|
||||||
password1 = self.cleaned_data.get("password1")
|
password1 = self.cleaned_data.get("password1")
|
||||||
|
@ -88,9 +73,7 @@ class RegistrationForm(forms.ModelForm):
|
||||||
# Save the provided password in hashed format
|
# Save the provided password in hashed format
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
user = super(RegistrationForm, self).save(commit=False)
|
user = super(RegistrationForm, self).save(commit=False)
|
||||||
access_code = self.get_access_code()
|
|
||||||
user.access_code = access_code
|
|
||||||
user.set_password(self.cleaned_data["password1"])
|
user.set_password(self.cleaned_data["password1"])
|
||||||
if commit:
|
if commit:
|
||||||
user.save()
|
user.save()
|
||||||
return user
|
return user
|
Reference in New Issue