def delete_menu(request, menu_id: int): try: fooddelivery_service_container.menu_management_service().delete( menu_id) return redirect("home_menu") except Exception: raise Http404("Menu does not exist")
def __create_if_post_method(context, request): if request.method == "POST": try: menu = __get_create_menu_dto_from_request(request) fooddelivery_service_container.menu_management_service().create( menu) context["saved"] = True except Exception as m: print(m) context["saved"] = False
def __edit_if_post_method(context, menu_id: int, request: HttpRequest): if request.method == "POST": try: menu = __get_edit_menu_dto_from_request(menu_id, request) fooddelivery_service_container.menu_management_service().edit( menu_id, menu) context["saved"] = True return __get_menu_details_dto_or_raise_404(menu_id) except Exception as m: print(m) context["saved"] = False
def __get_menu_details_dto_or_raise_404(menu_id) -> MenuDetailsDto: try: menu = fooddelivery_service_container.menu_management_service().get( menu_id) except Menu.DoesNotExist: raise Http404("The requested menu does not exist") return menu
def home_page(request): menu = fooddelivery_service_container.menu_management_service().list() context = { "title": "Home", 'menu': menu, 'logged_in': request.user.is_authenticated } return render(request, "fooddelivery/Home/home.html", context)
def delete_customer(request, customer_id: int): try: fooddelivery_service_container.menu_management_service().delete(customer_id) return redirect("home_customer") except Exception: raise Http404("Customer does not exist")
def get_menu_for_select(request): menu = fooddelivery_service_container.menu_management_service( ).get_all_for_select_list() context = {"menu": menu} return JsonResponse(context)
def home_menu(request): menu = fooddelivery_service_container.menu_management_service().list() context = {"title": "Menu", "menus": menu} return render(request, "fooddelivery/menu/home_menu.html", context)