This repository has been archived on 2024-01-13. You can view files and clone it, but cannot push or open issues or pull requests.
arka-mvp/order/forms.py
2022-09-27 16:59:25 +03:00

57 lines
3.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
from django.core.validators import RegexValidator
from .models import *
class BaseOrderCreationForm(forms.Form):
name = forms.CharField(max_length=200, label="Название заказа", help_text='help text')
description = forms.CharField(widget=forms.Textarea, label="Описание", required=False)
square = forms.DecimalField(max_digits=7, decimal_places=2, required=True, label="Площадь в м²")
type_of_renovation = forms.ChoiceField(choices=Order.TYPE_OF_RENOVATION_CHOICES, required=False,
label="Тип ремонта")
type_of_house = forms.ChoiceField(choices=Order.TYPE_OF_HOUSE_CHOICES, required=False, label="Тип дома")
type_of_room = forms.ChoiceField(choices=Order.TYPE_OF_ROOM_CHOICES, required=False,
label="Тип квартиры", widget=forms.RadioSelect)
# требуется дизайн проект
is_require_design = forms.ChoiceField(choices=Order.REQUIRED_DESIGN_CHOICES, required=False,
label="", widget=forms.RadioSelect)
purchase_of_material = forms.ChoiceField(choices=Order.PURCHASE_OF_MATERIAL_CHOICES, required=False,
label="Закуп материала", widget=forms.RadioSelect)
type_of_executor = forms.ChoiceField(choices=Order.TYPE_OF_EXECUTOR_CHOICES, required=False,
label="Тип исполнителя", widget=forms.RadioSelect)
# дальше отдельные параметры
is_with_warranty = forms.BooleanField(label="С гарантией", initial=True, required=False)
is_with_contract = forms.BooleanField(label="Работа по договору", initial=False, required=False)
# is_with_warranty = models.BooleanField(default=True, verbose_name="С гарантией")
# is_with_contract = models.BooleanField(default=False, verbose_name="Работа по договору")
# is_with_trade = models.BooleanField(default=False, verbose_name="Возможен торг")
# is_with_cleaning = models.BooleanField(default=False, verbose_name="С уборкой")
# is_with_garbage_removal = models.BooleanField(default=False, verbose_name="С вывозом мусора")
# примерная цена
approximate_price = forms.DecimalField(max_digits=12, decimal_places=2)
work_time = forms.CharField(max_length=100, required=False)
address_city = forms.ChoiceField(choices=City.to_choices, label="Город",
help_text="если вашего города нет в списке, "
"значит сервис пока что там не работает")
address_text = forms.CharField(max_length=70, label="Улица, дом", help_text="квартиру можно не указывать")
class UnregisteredUserOrderCreationForm(BaseOrderCreationForm):
phone = forms.CharField(max_length=12, required=True, label="Телефон", help_text="для обратной связи", validators=[
RegexValidator(regex="^\\+7[0-9]{10}$"),
])
email = forms.EmailField(required=True)