Beispiel #1
0
def edit(request, id):
    id = int(id or request.GET.get('id', '') or 0)
    dict_key = request.REQUEST.get('key', '')
    if id:
        m = DictDefine.objects.using('read').get(id=id)
        if DictValue.objects.using("read").filter(dict_id=id):  # 目前只能写这么low的语句了,有空再改
            ea = DictValue.objects.using("read").get(dict_id=id)
            return render_to_response('log/dict_edit2.html', locals())
    elif dict_key:
        m = DictDefine.objects.using('read').get(key=dict_key)
    else:
        m = DictDefine()
        ea = DictValue()
        m.id = 0

    return render_to_response('log/dict_edit.html', locals())
Beispiel #2
0
def save(request, id=""):
    _p = lambda x, y='': request.REQUEST.get(x, y)
    id = int(id or request.REQUEST.get('id', '') or 0)
    err_msg = ''
    print _p('earn', "")
    try:
        if id:
            m = DictDefine.objects.using('read').get(id=id)
        else:
            m = DictDefine()
        m.key = _p('key', '')
        m.name = _p('name', '')
        m.group = _p('group', '')
        m.json_dict = _p('dict', '')
        m.type = _p('type', '0')
        m.remark = _p('remark', '')
        m.save(using='write')
        if _p('earn', ""):
            ea = DictValue.objects.using("read").get(dict_id=id)
            ea.json_dict = _p('earn', "")
            ea.dict_name = _p('name', '')
            ea.save(using='write')
    except Exception, e:
        err_msg = trace_msg()