forms.py 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. from django import forms
  2. from django.contrib.auth import get_user_model
  3. from dbsynce.models import ServiceType, Service, Orders, Resource
  4. from webservice_running.models import OrdersLocal
  5. from django.contrib.auth.forms import UserCreationForm
  6. class OrderRegForm(forms.ModelForm):
  7. class Meta:
  8. model = OrdersLocal
  9. fields = '__all__'
  10. def __init__(self, *args, **kwargs):
  11. super().__init__(*args, **kwargs)
  12. for field in self.fields.values():
  13. field.widget.attrs['class'] = 'form-control'
  14. class RegisterUserForm(UserCreationForm):
  15. password1 = forms.CharField(label="Пароль",
  16. widget=forms.PasswordInput(attrs={'class':'form-control'}))
  17. password2 = forms.CharField(label="Подтверждение пароля",
  18. widget=forms.PasswordInput(attrs={'class':'form-control'}))
  19. username = forms.CharField(label="Номер телефона",
  20. widget=forms.TextInput(attrs={'class':'form-control'}))
  21. class Meta:
  22. model = get_user_model()
  23. fields = ['username', 'password1', 'password2']
  24. SPECS = [
  25. ('0', 'Парикмахер'),
  26. ('1', 'Визажист'),
  27. ('2', 'Стилист'),
  28. ]
  29. class OrderLocalForm(forms.ModelForm):
  30. order_synced = forms.ModelChoiceField(queryset = Orders.objects.all(), label="Заказ")
  31. #resource_id = forms.ModelChoiceField(queryset = Resource.objects.all(), label="Ресурс")
  32. specialization = forms.ChoiceField(choices=SPECS, label="Специализация рабочего места")
  33. address = forms.CharField(label="Адрес коворкинга")
  34. daily_price = forms.CharField(label="Стоимость в день")
  35. date_start = forms.DateField(label="Дата начала аренды")
  36. date_end = forms.DateField(label="Дата завершения аренды")
  37. def __init__(self, *args, **kwargs):
  38. super(OrderLocalForm, self).__init__(*args, **kwargs)
  39. class Meta:
  40. model = OrdersLocal
  41. fields = [
  42. 'order_synced',
  43. #'resource_id',
  44. 'specialization',
  45. 'address',
  46. 'daily_price',
  47. 'date_start',
  48. 'date_end',
  49. ]
  50. def __init__(self, *args, **kwargs):
  51. super().__init__(*args, **kwargs)
  52. for field in self.fields.values():
  53. field.widget.attrs['class'] = 'form-control'