All checks were successful
Build and Push Docker Image / build (push) Successful in 43s
- Created `FaqQuestionForm` in `forms.py` with custom field validations - Added FAQ form to the FAQ section with CSRF protection and error handling - Integrated email notifications to administrator upon FAQ submission - Updated styles and scripts for form inputs, validation messages, and messages UI - Adjusted FAQ section layout in `faq.html` and related CSS for responsiveness - Implemented tests for FAQ form submission and email notifications
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
from django import forms
|
||
|
||
|
||
class FaqQuestionForm(forms.Form):
|
||
name = forms.CharField(
|
||
label="Имя",
|
||
max_length=150,
|
||
widget=forms.TextInput(attrs={"placeholder": "Имя", "autocomplete": "name"}),
|
||
)
|
||
phone = forms.CharField(
|
||
label="Номер телефона",
|
||
max_length=64,
|
||
widget=forms.TextInput(attrs={"placeholder": "Номер телефона", "autocomplete": "tel"}),
|
||
)
|
||
question = forms.CharField(
|
||
label="Ваш вопрос",
|
||
max_length=1000,
|
||
widget=forms.Textarea(attrs={"placeholder": "Ваш вопрос", "rows": 4, "autocomplete": "off"}),
|
||
)
|
||
accept = forms.BooleanField(
|
||
label="Я согласен с политикой обработки персональных данных",
|
||
error_messages={"required": "Необходимо согласие на обработку персональных данных."},
|
||
)
|
||
|
||
def clean_name(self):
|
||
return self.cleaned_data["name"].strip()
|
||
|
||
def clean_phone(self):
|
||
return self.cleaned_data["phone"].strip()
|
||
|
||
def clean_question(self):
|
||
return self.cleaned_data["question"].strip()
|