Merge branch 'release/v23.6.4'
This commit is contained in:
@@ -1000,6 +1000,8 @@ class RegistrationFormTermsOfService(RegistrationForm):
|
||||
error_messages={'required': "You must agree to the terms to register"})
|
||||
|
||||
|
||||
DISPOSABLE_DOMAINS = ["powerscrews.com"]
|
||||
|
||||
class RegistrationFormUniqueEmail(RegistrationFormTermsOfService):
|
||||
"""
|
||||
Subclass of ``RegistrationFormTermsOfService`` which enforces uniqueness of
|
||||
@@ -1011,6 +1013,12 @@ class RegistrationFormUniqueEmail(RegistrationFormTermsOfService):
|
||||
Validate that the supplied email address is unique for the
|
||||
site.
|
||||
"""
|
||||
|
||||
email = self.cleaned_data['email']
|
||||
domain = email.split('@')[-1].lower()
|
||||
if domain in DISPOSABLE_DOMAINS:
|
||||
raise ValidationError("Registration using this domain is not allowed")
|
||||
|
||||
if User.objects.filter(email__iexact=self.cleaned_data['email']): # pragma: no cover
|
||||
raise forms.ValidationError(
|
||||
"This email address is already in use. Please supply a different email address.")
|
||||
|
||||
@@ -157,3 +157,25 @@ class NewUserRegistrationTest(TestCase):
|
||||
expected_url='/rowers/register/',
|
||||
status_code=302,target_status_code=200)
|
||||
|
||||
@patch('rowers.dataprep.workout_summary_to_df',side_effect=mock_workout_summaries)
|
||||
def test_newuser_disposable(self,mock_workout_summaries):
|
||||
form_data = {
|
||||
'first_name':'Jan',
|
||||
'last_name':'Roeiert',
|
||||
'email':'jan@powerscrews.com',
|
||||
'username':'janderoeiert',
|
||||
'password1':'Aapindewei2',
|
||||
'password2':'Aapindewei2',
|
||||
'url': '',
|
||||
'tos':True,
|
||||
'weightcategory':'hwt',
|
||||
'adaptiveclass': 'None',
|
||||
'sex':'male',
|
||||
'next':'/rowers/list-workouts',
|
||||
'birthdate':datetime.datetime(year=1970,month=4,day=2)
|
||||
}
|
||||
|
||||
form = RegistrationFormSex(form_data)
|
||||
self.assertFalse(form.is_valid())
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user