(request, domain, app_id)
return JsonResponse({
        "saved_app": copy_json,
        "error_html": "",
    })
Saves a copy of the app to a new doc.
Saves a copy of the app to a new doc.
Saves a copy of the app to a new doc .
def save_copy(request, domain, app_id):
    """
    Saves a copy of the app to a new doc.
    """
    track_built_app_on_hubspot.delay(request.couch_user)
    comment = request.POST.get('comment')
    app = get_app(domain, app_id)
    try:
        user_id = request.couch_user.get_id
        with report_build_time(domain, app._id, 'new_release'):
            copy = make_app_build(app, comment, user_id)
        CouchUser.get(user_id).set_has_built_app()
    except AppValidationError as e:
        lang, langs = get_langs(request, app)
        return JsonResponse({
            "saved_app": None,
            "error_html": render_to_string("app_manager/partials/build_errors.html", {
                'app': get_app(domain, app_id),
                'build_errors': e.errors,
                'domain': domain,
                'langs': langs,
            }),
        })
    except BuildConflictException:
        return JsonResponse({
            'error': _("There is already a version build in progress. Please wait.")
        }, status=400)
    except XFormValidationFailed:
        return JsonResponse({
            'error': _("Unable to validate forms.")
        }, status=400)
    finally:
        # To make a RemoteApp always available for building
        if app.is_remote_app():
            app.save(increment_version=True)

    _track_build_for_app_preview(domain, request.couch_user, app_id, 'User created a build')

    copy_json = copy and SavedAppBuild.wrap(copy.to_json()).releases_list_json(
        get_timezone_for_user(request.couch_user, domain)
    )

    return JsonResponse({
        "saved_app": copy_json,
        "error_html": "",
    })
def save_copy ( request , domain , app_id ) : track_built_app_on_hubspot . delay ( request . couch_user ) comment = request . POST . get ( 'comment' ) app = get_app ( domain , app_id ) try : user_id = request . couch_user . get_id with report_build_time ( domain , app . _id , 'new_release' ) : copy = make_app_build ( app , comment , user_id ) CouchUser . get ( user_id ) . set_has_built_app ( ) except AppValidationError as e : lang , langs = get_langs ( request , app ) return JsonResponse ( { "saved_app" : None , "error_html" : render_to_string ( "app_manager/partials/build_errors.html" , { 'app' : get_app ( domain , app_id ) , 'build_errors' : e . errors , 'domain' : domain , 'langs' : langs , } ) , } ) except BuildConflictException : return JsonResponse ( { 'error' : _ ( "There is already a version build in progress. Please wait." ) } , status = 400 ) except XFormValidationFailed : return JsonResponse ( { 'error' : _ ( "Unable to validate forms." ) } , status = 400 ) finally : # To make a RemoteApp always available for building if app . is_remote_app ( ) : app . save ( increment_version = True ) _track_build_for_app_preview ( domain , request . couch_user , app_id , 'User created a build' ) copy_json = copy and SavedAppBuild . wrap ( copy . to_json ( ) ) . releases_list_json ( get_timezone_for_user ( request . couch_user , domain ) ) return JsonResponse ( { "saved_app" : copy_json , "error_html" : "" , } )