(request, name, id)
return html
Return a template by name and with uid rendering
Return a template by name and with uid rendering
Return a template by name and with uid rendering
def get_part(request, name, id):
    """
    Return a template by name and with uid rendering
    """

    user = request.user

    # The recipe that needs to be edited.
    recipe = Analysis.objects.filter(id=id).annotate(
        job_count=Count("job", filter=Q(job__deleted=False))
    ).first()

    project = recipe.project

    if not auth.is_readable(obj=project, user=user):
        message = str("Recipe is not readable by current user")
        return HttpResponse(message)

    # Fills in project level counts (results, data and recipe counts).
    counts = get_counts(recipe.project)

    if name == "run":
        initial = dict(name=f"Results for: {recipe.name}")
        form = forms.RecipeInterface(request=request, analysis=recipe,
                                     json_data=recipe.json_data, initial=initial)
    else:
        # Initial form loading via a GET request.
        form = forms.RecipeForm(instance=recipe, user=request.user, project=project)


    remap = dict(
        info="parts/recipe_info.html",
        code="parts/recipe_code.html",
        interface="parts/recipe_interface.html",
        run="parts/recipe_run.html",
        results="parts/recipe_results.html",
        details='parts/recipe_details.html',
    )

    name = remap.get(name, "parts/placeholder.html")

    # Check to see if this recipe is runnable by the user.
    is_runnable = auth.authorize_run(user=user, recipe=recipe)

    # Check to see if recipe is editable
    editable = auth.writeable_recipe(user=user, source=recipe)

    # Get the list of jobs required for recipe results
    jobs = recipe.job_set.filter(deleted=False).order_by("-lastedit_date").all()
    context = dict(recipe=recipe, form=form, is_runnable=is_runnable, job_list=jobs, rerun_btn=False,
                   include_copy=False, editable=editable, user=user, project=recipe.project)
    context.update(counts)

    html = render(request, name, context=context)
    return html
def get_part ( request , name , id ) : user = request . user # The recipe that needs to be edited. recipe = Analysis . objects . filter ( id = id ) . annotate ( job_count = Count ( "job" , filter = Q ( job__deleted = False ) ) ) . first ( ) project = recipe . project if not auth . is_readable ( obj = project , user = user ) : message = str ( "Recipe is not readable by current user" ) return HttpResponse ( message ) # Fills in project level counts (results, data and recipe counts). counts = get_counts ( recipe . project ) if name == "run" : initial = dict ( name = f"Results for: {recipe.name}" ) form = forms . RecipeInterface ( request = request , analysis = recipe , json_data = recipe . json_data , initial = initial ) else : # Initial form loading via a GET request. form = forms . RecipeForm ( instance = recipe , user = request . user , project = project ) remap = dict ( info = "parts/recipe_info.html" , code = "parts/recipe_code.html" , interface = "parts/recipe_interface.html" , run = "parts/recipe_run.html" , results = "parts/recipe_results.html" , details = 'parts/recipe_details.html' , ) name = remap . get ( name , "parts/placeholder.html" ) # Check to see if this recipe is runnable by the user. is_runnable = auth . authorize_run ( user = user , recipe = recipe ) # Check to see if recipe is editable editable = auth . writeable_recipe ( user = user , source = recipe ) # Get the list of jobs required for recipe results jobs = recipe . job_set . filter ( deleted = False ) . order_by ( "-lastedit_date" ) . all ( ) context = dict ( recipe = recipe , form = form , is_runnable = is_runnable , job_list = jobs , rerun_btn = False , include_copy = False , editable = editable , user = user , project = recipe . project ) context . update ( counts ) html = render ( request , name , context = context ) return html