Пример #1
0
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
    })
Пример #2
0
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
        })
Пример #3
0
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)
Пример #4
0
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)