intrgrating suggestions after betta 1
This commit is contained in:
@@ -156,7 +156,8 @@ class OrdersOutPage:
|
||||
self.ldm_quantity = ft.TextField(
|
||||
expand=True,
|
||||
keyboard_type=ft.KeyboardType.NUMBER,
|
||||
input_filter=ft.InputFilter(allow=True, regex_string=r"^[0-9]*\.?[0-9]*$", replacement_string="")
|
||||
input_filter=ft.InputFilter(allow=True, regex_string=r"^[0-9]*\.?[0-9]*$", replacement_string=""),
|
||||
value=13.6
|
||||
)
|
||||
|
||||
self.kg_quantity = ft.TextField(
|
||||
@@ -402,10 +403,10 @@ class OrdersOutPage:
|
||||
self.loading_error_message.value = "Please select loading point!"
|
||||
self.loading_error_message.update()
|
||||
return
|
||||
if self.loading_informations.value == None or len(self.loading_informations.value) == 0:
|
||||
self.loading_error_message.value = "Add loading informations!"
|
||||
self.loading_error_message.update()
|
||||
return
|
||||
# if self.loading_informations.value == None or len(self.loading_informations.value) == 0:
|
||||
# self.loading_error_message.value = "Add loading informations!"
|
||||
# self.loading_error_message.update()
|
||||
# return
|
||||
if self.loading_date.value == None or len(str(self.loading_date.value)) == 0:
|
||||
self.loading_error_message.value = "Add loading date!"
|
||||
self.loading_error_message.update()
|
||||
@@ -520,10 +521,10 @@ class OrdersOutPage:
|
||||
self.unloading_error_message.value = "Please select unloading point!"
|
||||
self.unloading_error_message.update()
|
||||
return
|
||||
if self.unloading_informations.value == None or len(self.unloading_informations.value) == 0:
|
||||
self.unloading_error_message.value = "Add unloading informations!"
|
||||
self.unloading_error_message.update()
|
||||
return
|
||||
# if self.unloading_informations.value == None or len(self.unloading_informations.value) == 0:
|
||||
# self.unloading_error_message.value = "Add unloading informations!"
|
||||
# self.unloading_error_message.update()
|
||||
# return
|
||||
if self.unloading_date.value == None or len(str(self.unloading_date.value)) == 0:
|
||||
self.unloading_error_message.value = "Add unloading date!"
|
||||
self.unloading_error_message.update()
|
||||
@@ -867,6 +868,18 @@ class OrdersOutPage:
|
||||
except Exception as e:
|
||||
print("Error loading subscription:", e)
|
||||
return None
|
||||
|
||||
def get_client_access(self):
|
||||
token = self.page.client_storage.get("token")
|
||||
headers = {"Authorization": f"Bearer {token}"}
|
||||
response = requests.get(f"{API_BASE_URL}/profile/", headers=headers, timeout=10)
|
||||
user = response.json()
|
||||
if user['user_role'] == 'user':
|
||||
return True
|
||||
else:
|
||||
id = self.page.session.get("user_id")
|
||||
response = requests.get(f"{API_BASE_URL}/company_user/access/{id}", headers=headers)
|
||||
return True if response.json()['orders_out'] == 1 else False
|
||||
|
||||
def build(self):
|
||||
self.save_btn = ft.FilledButton(
|
||||
@@ -1050,7 +1063,7 @@ class OrdersOutPage:
|
||||
[
|
||||
self.loading_date,
|
||||
ft.ElevatedButton(
|
||||
"Pick date",
|
||||
"Select date",
|
||||
icon=ft.Icons.CALENDAR_MONTH,
|
||||
on_click=lambda e: self.page.open(
|
||||
ft.DatePicker(
|
||||
@@ -1067,7 +1080,7 @@ class OrdersOutPage:
|
||||
[
|
||||
self.loading_hour,
|
||||
ft.ElevatedButton(
|
||||
"Pick hour - Start",
|
||||
"Select hour - Start",
|
||||
icon=ft.Icons.CALENDAR_MONTH,
|
||||
on_click=lambda e: self.page.open(
|
||||
ft.TimePicker(
|
||||
@@ -1080,7 +1093,7 @@ class OrdersOutPage:
|
||||
),
|
||||
),
|
||||
ft.ElevatedButton(
|
||||
"Pick hour - End",
|
||||
"Select hour - End",
|
||||
icon=ft.Icons.CALENDAR_MONTH,
|
||||
on_click=lambda e: self.page.open(
|
||||
ft.TimePicker(
|
||||
@@ -1143,7 +1156,7 @@ class OrdersOutPage:
|
||||
[
|
||||
self.unloading_date,
|
||||
ft.ElevatedButton(
|
||||
"Pick date",
|
||||
"Select date",
|
||||
icon=ft.Icons.CALENDAR_MONTH,
|
||||
on_click=lambda e: self.page.open(
|
||||
ft.DatePicker(
|
||||
@@ -1160,7 +1173,7 @@ class OrdersOutPage:
|
||||
[
|
||||
self.unloading_hour,
|
||||
ft.ElevatedButton(
|
||||
"Pick hour - Start",
|
||||
"Select hour - Start",
|
||||
icon=ft.Icons.CALENDAR_MONTH,
|
||||
on_click=lambda e: self.page.open(
|
||||
ft.TimePicker(
|
||||
@@ -1173,7 +1186,7 @@ class OrdersOutPage:
|
||||
),
|
||||
),
|
||||
ft.ElevatedButton(
|
||||
"Pick hour - End",
|
||||
"Select hour - End",
|
||||
icon=ft.Icons.CALENDAR_MONTH,
|
||||
on_click=lambda e: self.page.open(
|
||||
ft.TimePicker(
|
||||
@@ -1225,5 +1238,31 @@ class OrdersOutPage:
|
||||
scroll=ft.ScrollMode.ADAPTIVE,
|
||||
spacing=20
|
||||
)
|
||||
) if self.get_client_access() else ft.Container(
|
||||
content=ft.Column(
|
||||
[
|
||||
ft.Row(
|
||||
[
|
||||
ft.Text("Create Order Out", size=24, weight=ft.FontWeight.BOLD),
|
||||
],
|
||||
alignment=ft.MainAxisAlignment.SPACE_BETWEEN
|
||||
),
|
||||
ft.Row(
|
||||
[
|
||||
ft.Text(
|
||||
"You do not have access to this page content",
|
||||
size=24,
|
||||
weight=ft.FontWeight.BOLD,
|
||||
color=ft.Colors.RED
|
||||
)
|
||||
],
|
||||
alignment=ft.MainAxisAlignment.CENTER
|
||||
),
|
||||
ft.Text("")
|
||||
],
|
||||
alignment=ft.MainAxisAlignment.SPACE_BETWEEN,
|
||||
expand=True
|
||||
),
|
||||
expand=True
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user