def updateStore()

in shop/views.py [0:0]


def updateStore(request, storeId):
    """ view for updating store """
    if canViewThisStore(storeId, request.user.id):
        # get the corresponding store
        store = Store.objects.get(id=storeId)
        metadata = getFBEOnboardingDetails(store.id)

        if request.method == "POST":
            # Create a form instance and populate it with data from the request (binding):
            form = UpdateStoreForm(request.POST)

            # Check if the form is valid:
            if form.is_valid():
                store.name = form.cleaned_data["business_name"]
                store.save()
                return redirect("viewStore", storeId)

        form = UpdateStoreForm(initial={"business_name": store.name})

        breadcrumbs = [(store.name, "viewStore", store.id)]

        context = {
            "form": form,
            "store": store,
            "fb_metadata": metadata,
            "page_title": "Update Shop",
            "breadcrumbs": breadcrumbs,
            "button": "Update",
        }

        return render(request, "core/update.html", context)
    else:
        return render(request, "403.html")