summaryrefslogtreecommitdiffstats
path: root/restaurant_orders/dashboard/forms.py
diff options
context:
space:
mode:
authorjdlugosz963 <jdlugosz963@gmail.com>2023-07-17 01:47:57 +0200
committerjdlugosz963 <jdlugosz963@gmail.com>2023-07-17 01:52:26 +0200
commitc21f4b3dacd597a15a5ec39d525df1dfe1b70376 (patch)
tree0dfc51d2ffeb7b5022d9ad852f2fd3620c72196a /restaurant_orders/dashboard/forms.py
parent2c6f98aeef4fa1aba5678fe17c8e762a11db7b40 (diff)
downloadrestaurant-orders-c21f4b3dacd597a15a5ec39d525df1dfe1b70376.tar.gz
restaurant-orders-c21f4b3dacd597a15a5ec39d525df1dfe1b70376.zip
Add project.main
Diffstat (limited to 'restaurant_orders/dashboard/forms.py')
-rw-r--r--restaurant_orders/dashboard/forms.py30
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 @@
1from django import forms
2
3from core.models import Order
4
5
6FORM_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
8class 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
17class 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})