from django import forms from django.contrib.auth import get_user_model from dbsynce.models import ServiceType, Service, Orders, Resource from webservice_running.models import OrdersLocal from django.contrib.auth.forms import UserCreationForm class OrderRegForm(forms.ModelForm): class Meta: model = OrdersLocal fields = '__all__' 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'})) username = forms.CharField(label="Номер телефона", widget=forms.TextInput(attrs={'class':'form-control'})) class Meta: model = get_user_model() fields = ['username', 'password1', 'password2'] class OrderLocalForm(forms.ModelForm): order_synced = forms.ModelChoiceField(queryset = Orders.objects.all(), label="Заказ") resource_id = forms.ModelChoiceField(queryset = Resource.objects.all(), label="Ресурс") specialization = forms.CharField(label="Специализация рабочего места") address = forms.CharField(label="Адрес коворкинга") daily_price = forms.CharField(label="Стоимость в день") payment_transaction_id = forms.CharField(label="Транзакция платежа") attempts = forms.CharField(label="Попытка") order_place_type = forms.CharField(label="Тип заказа") def __init__(self, *args, **kwargs): super(OrderLocalForm, self).__init__(*args, **kwargs) class Meta: model = OrdersLocal fields = [ 'order_synced', 'resource_id', 'specialization', 'address', 'daily_price', 'payment_transaction_id', 'attempts', 'order_place_type', ] #fields = '__all__' def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) for field in self.fields.values(): field.widget.attrs['class'] = 'form-control'