(request, domain)
Accepts same post body as corehq.apps.app_manager.views.edit_app_langs
Accepts same post body as corehq.apps.app_manager.views.edit_app_langs
Accepts same post body as corehq . apps . app_manager . views . edit_app_langs
def edit_sms_languages(request, domain):
    """
    Accepts same post body as corehq.apps.app_manager.views.edit_app_langs
    """
    with transaction.atomic():
        sms_translations = get_or_create_sms_translations(domain)
        try:
            from corehq.apps.app_manager.views.utils import validate_langs
            langs, rename = validate_langs(request, sms_translations.langs)
        except AssertionError:
            return HttpResponse(status=400)

        for old, new in rename.items():
            if old != new:
                sms_translations.translations[new] = sms_translations.translations[old]
                del sms_translations.translations[old]

        for lang in langs:
            if lang not in sms_translations.translations:
                sms_translations.translations[lang] = {}

        for lang in set(sms_translations.translations.keys()):
            if lang not in langs:
                del sms_translations.translations[lang]

        sms_translations.langs = langs
        sms_translations.save()
        return json_response(langs)
def edit_sms_languages ( request , domain ) : with transaction . atomic ( ) : sms_translations = get_or_create_sms_translations ( domain ) try : from corehq . apps . app_manager . views . utils import validate_langs langs , rename = validate_langs ( request , sms_translations . langs ) except AssertionError : return HttpResponse ( status = 400 ) for old , new in rename . items ( ) : if old != new : sms_translations . translations [ new ] = sms_translations . translations [ old ] del sms_translations . translations [ old ] for lang in langs : if lang not in sms_translations . translations : sms_translations . translations [ lang ] = { } for lang in set ( sms_translations . translations . keys ( ) ) : if lang not in langs : del sms_translations . translations [ lang ] sms_translations . langs = langs sms_translations . save ( ) return json_response ( langs )