diff options
Diffstat (limited to 'restaurant_orders/dashboard/forms.py')
-rw-r--r-- | restaurant_orders/dashboard/forms.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/restaurant_orders/dashboard/forms.py b/restaurant_orders/dashboard/forms.py new file mode 100644 index 0000000..23937ed --- /dev/null +++ b/restaurant_orders/dashboard/forms.py | |||
@@ -0,0 +1,30 @@ | |||
1 | from django import forms | ||
2 | |||
3 | from core.models import Order | ||
4 | |||
5 | |||
6 | FORM_TAILWIND_CLASSES = 'form-control block w-full px-3 py-1.5 text-base font-normal text-gray-700 bg-white bg-clip-padding border border-solid border-gray-300 rounded transition ease-in-out m-0 focus:text-gray-700 focus:bg-white focus:border-blue-600 focus:outline-none' | ||
7 | |||
8 | class OrderStatusForm(forms.ModelForm): | ||
9 | class Meta: | ||
10 | model = Order | ||
11 | fields = ('wp_status', ) | ||
12 | |||
13 | def __init__(self, *args, **kwargs): | ||
14 | super().__init__(*args, **kwargs) | ||
15 | self.fields['wp_status'].label = 'Przenies do:' | ||
16 | |||
17 | class AddToBillForm(forms.Form): | ||
18 | send_mail = forms.BooleanField(label='Wyslij maila', initial=False, required=False) | ||
19 | send_sms = forms.BooleanField(label='Wyslij sms', initial=True, required=False) | ||
20 | |||
21 | def __init__(self, pk, user, *args, **kwargs): | ||
22 | super().__init__(*args, **kwargs) | ||
23 | order = Order.get_order(pk, user) | ||
24 | |||
25 | for item in order.line_items: | ||
26 | index = item['product_id'] | ||
27 | self.fields[index] = forms.IntegerField(required=False, label=item['name']) | ||
28 | |||
29 | for index in self.fields.keys(): | ||
30 | self.fields[index].widget.attrs.update({'class': FORM_TAILWIND_CLASSES}) | ||