Files
santeh-ray/home/forms.py
Azimkin 4f4a1a55e5
All checks were successful
Build and Push Docker Image / build (push) Successful in 43s
feat: add FAQ question form with email notifications and validations
- 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
2026-04-19 22:51:56 +02:00

33 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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()