Coverage for author\forms.py: 100%
8 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-06-29 10:02 +0100
« prev ^ index » next coverage.py v7.4.4, created at 2024-06-29 10:02 +0100
1from django import forms
2from author.models import Author
5class AuthorForm(forms.ModelForm):
6 """
7 A form for creating or updating an Author instance.
8 """
9 class Meta:
10 """
11 The Meta class provides metadata for the Author form.
12 It specifies the model to be used and the fields to be included in the
13 form.
14 """
15 model = Author
16 fields = ('name',)
19class AuthorFormInput(forms.Form):
20 """
21 A form for inputting author information.
23 Attributes:
24 name (CharField): The name of the author.
25 """
26 name = forms.CharField(
27 widget=forms.TextInput(attrs={
28 'id': 'name',
29 'oninput': 'validateInput()',
30 'class': 'form-control',
31 'placeholder': 'Author name',
32 'type': 'text',
33 'pattern': '^[A-Z][a-zA-Z]*( [A-Z][a-zA-Z]*)*$',
34 'title': 'Server validation: Each word must start with a capital '
35 'letter separated by a space',
36 })
37 )