(request, domain, app_id)
return json_response(langs)
Called with post body:
    {
        langs: ["en", "es", "hin"],
        rename: {
            "hi": "hin",
            "en": "en",
            "es": "es"
        },
        smart_lang_display: true,
        build: ["es", "hin"]
    }
Called with post body:
    {
        langs: ["en", "es", "hin"],
        rename: {
            "hi": "hin",
            "en": "en",
            "es": "es"
        },
        smart_lang_display: true,
        build: ["es", "hin"]
    }
Called with post body : { langs : [ en es hin ] rename : { hi : hin en : en es : es } smart_lang_display : true build : [ es hin ] }
def edit_app_langs(request, domain, app_id):
    """
    Called with post body:
    {
        langs: ["en", "es", "hin"],
        rename: {
            "hi": "hin",
            "en": "en",
            "es": "es"
        },
        smart_lang_display: true,
        build: ["es", "hin"]
    }
    """
    app = get_app(domain, app_id)
    try:
        langs, rename = validate_langs(request, app.langs)
    except AssertionError:
        return HttpResponse(status=400)

    # now do it
    for old, new in rename.items():
        if old != new:
            app.rename_lang(old, new)

    #remove deleted languages from build profiles
    new_langs = set(langs)
    deleted = [lang for lang in app.langs if lang not in new_langs]
    for id in app.build_profiles:
        for lang in deleted:
            try:
                app.build_profiles[id].langs.remove(lang)
            except ValueError:
                pass

    def replace_all(list1, list2):
        if list1 != list2:
            while list1:
                list1.pop()
            list1.extend(list2)
    replace_all(app.langs, langs)
    app.smart_lang_display = json.loads(request.body.decode('utf-8'))['smart_lang_display']
    app.save()
    return json_response(langs)
def edit_app_langs ( request , domain , app_id ) : app = get_app ( domain , app_id ) try : langs , rename = validate_langs ( request , app . langs ) except AssertionError : return HttpResponse ( status = 400 ) # now do it for old , new in rename . items ( ) : if old != new : app . rename_lang ( old , new ) #remove deleted languages from build profiles new_langs = set ( langs ) deleted = [ lang for lang in app . langs if lang not in new_langs ] for id in app . build_profiles : for lang in deleted : try : app . build_profiles [ id ] . langs . remove ( lang ) except ValueError : pass def replace_all ( list1 , list2 ) : if list1 != list2 : while list1 : list1 . pop ( ) list1 . extend ( list2 ) replace_all ( app . langs , langs ) app . smart_lang_display = json . loads ( request . body . decode ( 'utf-8' ) ) [ 'smart_lang_display' ] app . save ( ) return json_response ( langs )