def edit(request, template="translations/edit.html"): params = json_request(request.GET) doc_id = params.get('doc_id') lang = params.get('lang') trans = TranslationMixin.get(doc_id) validate_trans_doc(trans) return render(request, template, { "translations_json": json.dumps(trans.translations[lang]), "doc_id": doc_id, "lang": lang })
def edit(request, template="translations/edit.html"): params = json_request(request.GET) doc_id = params.get('doc_id') lang = params.get('lang') trans = TranslationMixin.get(doc_id) validate_trans_doc(trans) return render( request, template, { "translations_json": json.dumps(trans.translations[lang]), "doc_id": doc_id, "lang": lang })
def set_translations(request): params = json_request(request.POST) doc_id = params.get('doc_id') lang = params.get('lang') translations = params.get('translations') trans = TranslationMixin.get(doc_id) trans.set_translations(lang, translations) resp = {} try: trans.save(response_json=resp) except Exception: trans.save() return json_response(resp)