12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- from django import forms
- from django.contrib.auth import get_user_model
- from webservice_running.models import OrdersLocal
- from django.contrib.auth.forms import UserCreationForm
- GUIDE_TYPE = [
- ('one', '1'),
- ('two', '2'),
- ('three', '3'),
- ]
- MOVEMENT_WAY = [
- ('one', 'Автобус'),
- ('two', 'Машина'),
- ('three', 'Пешком'),
- ]
- class OrderRegForm(forms.ModelForm):
- place_start = forms.CharField(label="Точка 1")
- place_end = forms.CharField(label="Точка 2")
- guide_type = forms.ChoiceField(choices=GUIDE_TYPE, label="Тип гида")
- movement_way = forms.ChoiceField(choices=MOVEMENT_WAY, label="Вид передвижения")
- numb_of_people = forms.IntegerField(label="Количество человек")
- service_date = forms.DateField(label="Дата", help_text=datetime.date.today)
- service_time = forms.TimeField(label="Время")
- discription = forms.CharField(label="Пожелания")
- price = forms.IntegerField(label="Предварительная стоимость")
-
- class Meta:
- model = OrdersLocal
- fields = ['place_start', 'place_end', 'guide_type', 'movement_way', 'numb_of_people', 'service_date', 'service_time', 'discription', 'price']
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- for field in self.fields.values():
- field.widget.attrs['class'] = 'form-control'
- class RegisterUserForm(UserCreationForm):
- password1 = forms.CharField(label="Пароль",
- widget=forms.PasswordInput(attrs={'class':'form-control'}))
-
- password2 = forms.CharField(label="Подтверждение пароля",
- widget=forms.PasswordInput(attrs={'class':'form-control'}))
- phone_number = forms.CharField(label="Номер телефона",
- widget=forms.TextInput(attrs={'class':'form-control'}))
-
- email = forms.CharField(label="Email",
- widget=forms.TextInput(attrs={'class':'form-control'}))
-
- username = forms.CharField(label="Имя пользователя",
- widget=forms.TextInput(attrs={'class':'form-control'}))
-
- first_name = forms.CharField(label="Имя",
- widget=forms.TextInput(attrs={'class':'form-control'}))
- last_name = forms.CharField(label="Фамилия",
- widget=forms.TextInput(attrs={'class':'form-control'}))
-
- class Meta:
- model = get_user_model()
- fields = ['username', 'first_name', 'last_name', 'avatar', 'phone_number', "email", 'password1', 'password2' ]
|