2024-02-04 21:40:58 +03:00
|
|
|
def reverse_url(loc: str, **kwargs) -> str:
|
|
|
|
menu_pref = '/'
|
|
|
|
submenu_pref = menu_pref + str(kwargs.get('menu_id', '')) + '/submenus/'
|
|
|
|
dish_pref = submenu_pref + str(kwargs.get('submenu_id', '')) + '/dishes/'
|
2024-02-05 23:14:23 +03:00
|
|
|
|
2024-02-04 21:40:58 +03:00
|
|
|
match loc:
|
|
|
|
case 'menus':
|
|
|
|
return menu_pref
|
2024-02-05 23:14:23 +03:00
|
|
|
|
2024-02-04 21:40:58 +03:00
|
|
|
case 'menu':
|
|
|
|
return menu_pref + str(kwargs.get('menu_id', ''))
|
2024-02-05 23:14:23 +03:00
|
|
|
|
2024-02-04 21:40:58 +03:00
|
|
|
case 'submenus':
|
|
|
|
return submenu_pref
|
2024-02-05 23:14:23 +03:00
|
|
|
|
2024-02-04 21:40:58 +03:00
|
|
|
case 'submenu':
|
|
|
|
return submenu_pref + str(kwargs.get('submenu_id', ''))
|
2024-02-05 23:14:23 +03:00
|
|
|
|
2024-02-04 21:40:58 +03:00
|
|
|
case 'dishes':
|
|
|
|
return dish_pref
|
2024-02-05 23:14:23 +03:00
|
|
|
|
2024-02-04 21:40:58 +03:00
|
|
|
case 'dish':
|
|
|
|
return dish_pref + str(kwargs.get('dish_id', ''))
|
2024-02-05 23:14:23 +03:00
|
|
|
|
2024-02-04 21:40:58 +03:00
|
|
|
return menu_pref
|