(request, name, stage, buildId)
return HttpResponse(html)
Returns a warning message if:
    1. The build has been tagged as build build
    2. a build doesn't have a successful deploy on the preceding stage.

    TODO: we would have call backend twice since the getAllDeploys call does not support filtering on multiple states;
    Also, getAllDeploys return all deploys with commits after the specific commit, it would be good if there is options
    to return the exact matched deploys.
Returns a warning message if:
    1. The build has been tagged as build build
    2. a build doesn't have a successful deploy on the preceding stage.
Returns a warning message if : 1 . The build has been tagged as build build 2 . a build doesn t have a successful deploy on the preceding stage .
def warn_for_deploy(request, name, stage, buildId):
    """ Returns a warning message if:
    1. The build has been tagged as build build
    2. a build doesn't have a successful deploy on the preceding stage.

    TODO: we would have call backend twice since the getAllDeploys call does not support filtering on multiple states;
    Also, getAllDeploys return all deploys with commits after the specific commit, it would be good if there is options
    to return the exact matched deploys.
    """
    build_info = builds_helper.get_build_and_tag(request, buildId)
    build = build_info["build"]
    tag = build_info.get("tag")

    if tag is not None and tag["value"] == tags_helper.TagValue.BAD_BUILD:
        html = render_to_string('warn_deploy_bad_build.tmpl', {
            'tag': tag,
        })
        return HttpResponse(html)

    env_promote = environs_helper.get_env_promotes_config(request, name, stage)
    pred_stage = env_promote.get('predStageName')
    if not pred_stage or pred_stage == BUILD_STAGE:
        return HttpResponse("")

    pred_env = environs_helper.get_env_by_stage(request, name, pred_stage)

    filter = {}
    filter['envId'] = [pred_env['id']]
    filter['commit'] = build['commit']
    filter['repo'] = build['repo']
    filter['oldestFirst'] = True
    filter['deployState'] = "SUCCEEDING"
    filter['pageIndex'] = 1
    filter['pageSize'] = 1
    result = deploys_helper.get_all(request, **filter)
    succeeding_deploys = result['deploys']

    if succeeding_deploys:
        return HttpResponse("")

    filter['deployState'] = "SUCCEEDED"
    result = deploys_helper.get_all(request, **filter)
    succeeded_deploys = result['deploys']

    if succeeded_deploys:
        return HttpResponse("")

    html = render_to_string('warn_no_success_deploy_in_pred.tmpl', {
        'envName': name,
        'predStageName': pred_stage,
    })

    return HttpResponse(html)
def warn_for_deploy ( request , name , stage , buildId ) : build_info = builds_helper . get_build_and_tag ( request , buildId ) build = build_info [ "build" ] tag = build_info . get ( "tag" ) if tag is not None and tag [ "value" ] == tags_helper . TagValue . BAD_BUILD : html = render_to_string ( 'warn_deploy_bad_build.tmpl' , { 'tag' : tag , } ) return HttpResponse ( html ) env_promote = environs_helper . get_env_promotes_config ( request , name , stage ) pred_stage = env_promote . get ( 'predStageName' ) if not pred_stage or pred_stage == BUILD_STAGE : return HttpResponse ( "" ) pred_env = environs_helper . get_env_by_stage ( request , name , pred_stage ) filter = { } filter [ 'envId' ] = [ pred_env [ 'id' ] ] filter [ 'commit' ] = build [ 'commit' ] filter [ 'repo' ] = build [ 'repo' ] filter [ 'oldestFirst' ] = True filter [ 'deployState' ] = "SUCCEEDING" filter [ 'pageIndex' ] = 1 filter [ 'pageSize' ] = 1 result = deploys_helper . get_all ( request , * * filter ) succeeding_deploys = result [ 'deploys' ] if succeeding_deploys : return HttpResponse ( "" ) filter [ 'deployState' ] = "SUCCEEDED" result = deploys_helper . get_all ( request , * * filter ) succeeded_deploys = result [ 'deploys' ] if succeeded_deploys : return HttpResponse ( "" ) html = render_to_string ( 'warn_no_success_deploy_in_pred.tmpl' , { 'envName' : name , 'predStageName' : pred_stage , } ) return HttpResponse ( html )