(request, id)
Edit recipes. Uses recipe primary key as access!
Edit recipes. Uses recipe primary key as access!
Edit recipes . Uses recipe primary key as access!
def ajax_edit(request, id):
    """
    Edit recipes. Uses recipe primary key as access!
    """

    # The user performing the request.
    user = request.user

    # The recipe that needs to be edited.
    recipe = Analysis.objects.filter(id=id).first()

    if not auth.writeable_recipe(source=recipe, user=user):
        message = str("Recipe is not writable by current user")
        return ajax_error(msg=message)

    # The project of for the recipe.
    project = recipe.project
    form = RecipeForm(data=request.POST, instance=recipe, files=request.FILES, user=user,
                      project=project)

    if form.is_valid():
        form.save()
        return ajax_success(msg=f"Recipe saved.")
    else:
        message = str(form.errors)
        return ajax_error(msg=message)
def ajax_edit ( request , id ) : # The user performing the request. user = request . user # The recipe that needs to be edited. recipe = Analysis . objects . filter ( id = id ) . first ( ) if not auth . writeable_recipe ( source = recipe , user = user ) : message = str ( "Recipe is not writable by current user" ) return ajax_error ( msg = message ) # The project of for the recipe. project = recipe . project form = RecipeForm ( data = request . POST , instance = recipe , files = request . FILES , user = user , project = project ) if form . is_valid ( ) : form . save ( ) return ajax_success ( msg = f"Recipe saved." ) else : message = str ( form . errors ) return ajax_error ( msg = message )