Create basic order creation form

This commit is contained in:
2022-09-28 02:34:41 +03:00
parent 8bcc88680b
commit fcf44c9bac
5 changed files with 226 additions and 67 deletions

View File

@@ -1,52 +1,29 @@
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)
class BaseOrderCreationForm(forms.ModelForm):
square = forms.DecimalField(max_digits=7, decimal_places=2, required=True, label="Площадь в м²")
type_of_room = forms.ChoiceField(choices=Order.TYPE_OF_ROOM_CHOICES, required=False, label="Тип квартиры",
widget=forms.RadioSelect(attrs={"class": "inline-input"}))
is_require_design = forms.ChoiceField(choices=Order.REQUIRED_DESIGN_CHOICES, label="Требуется дизайн проект",
required=False, widget=forms.RadioSelect(attrs={"class": "inline-input"}))
purchase_of_material = forms.ChoiceField(choices=Order.PURCHASE_OF_MATERIAL_CHOICES, widget=forms.RadioSelect,
required=False, label="Закуп материала")
type_of_executor = forms.ChoiceField(choices=Order.TYPE_OF_EXECUTOR_CHOICES, widget=forms.RadioSelect,
required=False, 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 Meta:
model = Order
fields = [
'name', 'description', 'square',
'type_of_renovation', 'type_of_house', 'type_of_room',
'is_require_design', 'purchase_of_material', 'type_of_executor',
'is_with_warranty', 'is_with_contract', 'is_with_trade', 'is_with_cleaning', 'is_with_garbage_removal',
'date_start', 'date_end',
'approximate_price', 'work_time', 'address_city', 'address_text',
]
class UnregisteredUserOrderCreationForm(BaseOrderCreationForm):