Coverage for website/forms/RegistrationForm.py: 100%

22 statements  

« prev     ^ index     » next       coverage.py v7.5.0, created at 2025-09-13 15:29 -0300

1from django.contrib.auth.forms import UserCreationForm as BaseUserCreationForm 

2from phonenumber_field.formfields import PhoneNumberField 

3 

4from website.forms import * 

5from website.models import Author, Reader, User 

6 

7 

8class RegistrationAuthorForm(forms.ModelForm): 

9 author_name = forms.TextInput() 

10 

11 class Meta: 

12 model = Author 

13 fields = ("author_name",) 

14 

15 

16class RegistrationReaderForm(forms.ModelForm): 

17 reader_name = forms.TextInput() 

18 

19 class Meta: 

20 model = Reader 

21 fields = ("reader_name",) 

22 

23 

24class UserCreationForm(BaseUserCreationForm): 

25 phone = PhoneNumberField( 

26 label="Celular", 

27 region="BR", 

28 ) 

29 

30 class Meta: 

31 model = User 

32 fields = ( 

33 "email", 

34 "phone_number", 

35 ) 

36 

37 password1 = forms.CharField( 

38 label="Senha:", widget=forms.PasswordInput, required=True 

39 ) 

40 password2 = forms.CharField( 

41 label="Confirme a senha:", widget=forms.PasswordInput, required=True 

42 ) 

43 

44 """def clean_password2(self): 

45 password1 = self.cleaned_data.get('password1') 

46 password2 = self.cleaned_data.get('password2') 

47 if password1 and password2 and password1 != password2: 

48 raise forms.ValidationError('Passwords do not match.') 

49 return password2"""