Files
Aerbim/GeneralApp/forms.py
2024-01-05 14:44:12 +03:00

34 lines
1.4 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
from django.contrib.auth.forms import AuthenticationForm
from django.utils.translation import gettext_lazy as _
from django.core.exceptions import ValidationError
from django.forms import widgets
class FeedbackForm(forms.Form):
# account_type = forms.ChoiceField(choices=account_type_choices, initial='sender', required=True)
form_name = forms.CharField(label=_('Название формы'), required=True)
name = forms.CharField(label=_('Имя'), required=True)
company = forms.CharField(label=_('Компания'), required=True)
contacts = forms.CharField(label=_('Контактные данные'), required=True)
description = forms.CharField(label=_('Тематика запроса'), required=True)
agreement = forms.BooleanField(
label=_('Принимаю пользовательское соглашение и принимаю условия обработки личных данных'),
initial=False, required=True
)
def __init__(self, *args, **kwargs):
del_descr = False
if kwargs:
if ('del_descr' in kwargs and kwargs['del_descr']) or (not 'desсription' in kwargs['data']):
del_descr = True
if 'del_descr' in kwargs:
del kwargs['del_descr']
super(FeedbackForm, self).__init__(*args, **kwargs)
if del_descr:
del self.fields['description']