def delete(request, meal_id): try: fooddelivery_service_container.meal_management_service().delete( meal_id) return redirect("home") except Exception: raise Http404("No such order exist")
def __create_if_post_method(context, request): if request.method == "POST": try: meal = __get_edit_meal_dto_from_request(request) fooddelivery_service_container.meal_management_service().create( meal) context["saved"] = True return __get_meal_details_dto_or_raise_404(meal) except Exception as meals: print(meals) context["saved"] = False
def __edit_if_post_method(context, meal_id: int, request: HttpRequest) -> OrderDetailsDto: if request.method == "POST": try: meal = __get_edit_meal_dto_from_request(meal_id, request) fooddelivery_service_container.meal_management_service().edit( meal_id, meal) context["saved"] = True return __get_meal_details_dto_or_raise_404(meal_id) except Exception as meals: print(meals) context["saved"] = False
def __get_meal_details_dto_or_raise_404(meal_id) -> OrderDetailsDto: try: meal = fooddelivery_service_container.meal_management_service().get( meal_id=meal_id) except Order.DoesNotExist: raise Http404("The request order does not exist") return meal
def home_meal(request): meals = fooddelivery_service_container.meal_management_service().list() context = {"title": "Order", "meals": meals} return render(request, "fooddelivery/meal/home_meal.html", context)