当前位置: 首页>>代码示例>>Python>>正文


Python Utility.modelToDict方法代码示例

本文整理汇总了Python中utility.Utility.modelToDict方法的典型用法代码示例。如果您正苦于以下问题:Python Utility.modelToDict方法的具体用法?Python Utility.modelToDict怎么用?Python Utility.modelToDict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utility.Utility的用法示例。


在下文中一共展示了Utility.modelToDict方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: dispatch

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import modelToDict [as 别名]
def dispatch(request):
    util = Utility(post=request.POST, get=request.GET)
    c = util.nvlGet('c');
    par = util.nvlGet('q', '')
    if c is not None:
        if 'formpartner' == c:
            return HttpResponse(json.dumps(prepareFormPartner(util.data)))
        if 'formpencarianpartner' == c:
            return render_to_response('inventory/form_partner_browse.html')
        if 'pencarianpartner' == c:
            return HttpResponse(json.dumps({'data': pencarianPartner(util.data)}))
        if 'partnersider' == c:
            return HttpResponse(json.dumps({'html': getPartnerSider(util.data)}))
        if 'caripartner' == c:
            return render_to_response('inventory/cari_kata_kunci.html')
        if 'lookuppartner' == c:
            return HttpResponse(json.dumps(
                lookupPartner(util.nvlGet('katakunci', None), util.nvlGet('id', None), util.nvlGet('max', None))));
        if 'formlistpartner' == c:
            return HttpResponse(json.dumps(dict(
                    {'html': render_to_string('inventory/list_partner.html'),
                     'data': prepareListPartnerByKataKunci(util.data)})))
        if 'partnerbyname' == c:
            par = util.nvlGet('q', '')
            namas = []
            #g=500/0
            nama = 'noname'
            if len(par) > 2:
                pas = models.Partner.objects.filter(nama__icontains=par)[:util.nvlGet('a', 8)]
                for p in pas:
                    nama = util.modelToDicts([p])
                    namas.append(nama)
                    #return HttpResponseServerError('error dari server lhoo')
            data = dict({'eventid': util.nvlGet('eventid'), 'data': namas})
            return HttpResponse(json.dumps(data))
        if 'partnerbyid' == c:
            cuss = models.Partner.objects.filter(id__exact=par)
            for cus in cuss:
                return HttpResponse(json.dumps(util.modelToDict(cus)))
            return HttpResponse({'message': 'no partner'})
        if 'partner_bynamalamat' == c:
            jresp = dict({'data': prepareListPartnerByKataKunci(util.data), 'eventid': util.nvlGet('eventid')})
            return HttpResponse(json.dumps(jresp))
        if 'hapuspartner' == c:
            custs = models.Supplier.objects.filter(id__exact=util.nvlGet('id', 0));
            dp = {}
            if custs:
                #hapus semua barang di inventory
                dp = util.modelToDict(custs[0])
                custs[0].delete()
            return HttpResponse(json.dumps(dp))
        if 'updatesupplier' == c:
        #hanya untuk mengupdate data barang, bukan barang di inventory
            return HttpResponse(json.dumps(saveUpdatePartner(util.data)))
        if 'simpanpartner' == c:
            #simpanPasien(request.POST)
            return HttpResponse(json.dumps(saveUpdatePartner(util.data)))

    return HttpResponseServerError('can''t find param')
开发者ID:tejo-ak,项目名称:warehouse,代码行数:61,代码来源:partnerMgt.py

示例2: prepareFormInventory

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import modelToDict [as 别名]
def prepareFormInventory(reqData):
    requtil = Utility(reqData=reqData)
    jresp = dict({'html': render_to_string('inventory/form_inventory.html', {})})
    data = {}
    if 'id' in reqData:
        id = requtil.nvlGet('id')
        if id > 0:
            pas = models.Inventory.objects.get(id__exact=requtil.nvlGet('id'))
            data = requtil.modelToDict(pas)
            jresp.update({'data': data})
    return jresp
开发者ID:tejo-ak,项目名称:warehouse,代码行数:13,代码来源:inventoryMgt.py

示例3: dispatch

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import modelToDict [as 别名]
def dispatch(request):
    util = Utility(post=request.POST, get=request.GET)
    c = util.nvlGet('c');
    par = util.nvlGet('q', '')
    if c is not None:
        if 'referensi' == c:
            grup = util.nvlGet('grup', 0)
            field = util.nvlGet('field')
            refs = models.Referensi.objects.filter(grup__exact=grup)
            jrefs = []
            for ref in refs:
                jrefs.append(util.modelToDict(ref))
            return HttpResponse(json.dumps({'data': jrefs}))
开发者ID:tejo-ak,项目名称:warehouse,代码行数:15,代码来源:referensi.py

示例4: dispatch

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import modelToDict [as 别名]
def dispatch(request):
    util = Utility(post=request.POST, get=request.GET)
    c = util.nvlGet('c');
    if c is not None:
        if 'cariinventory' == c:
            return render_to_response('inventory/cari_inventory.html')
        if 'forminventory' == c:
            return HttpResponse(json.dumps(prepareFormInventory(util.data)))
        if 'inventorybyname' == c:
            par = util.nvlGet('q', '')
            namas = [];
            #g=500/0
            nama = 'noname';
            if len(par) > 2:
                pas = models.Inventory.objects.filter(nama__icontains=par)[:util.nvlGet('a', 8)]
                for p in pas:
                    nama = util.modelToDict(p)
                    namas.append(nama)
                    #return HttpResponseServerError('error dari server lhoo')
            data = dict({'eventid': util.nvlGet('eventid'), 'data': namas})
            return HttpResponse(json.dumps(data))
        if 'invetorybyid' == c:
            nama = models.Inventory.objects.filter(id__exact=par)
            return HttpResponse(namas)
        if 'hapusinventory' == c:
            print 'start menghapus pasien ' + util.nvlGet('id', 'no id')
            pasien = models.Inventory.objects.filter(id__exact=util.nvlGet('id', 0));
            dp = {}
            if pasien:
                dp = util.modelToDict(pasien[0])
                print 'pasien telah dihapus'
                pasien.delete()
            return HttpResponse(json.dumps(dp))
        if 'simpaninventory' == c:
            #simpanPasien(request.POST)
            return HttpResponse(json.dumps(saveUpdateInventory(util.data)))

    return HttpResponse('can''t find param')
开发者ID:tejo-ak,项目名称:warehouse,代码行数:40,代码来源:inventoryMgt.py

示例5: prepareListSupplierByKataKunci

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import modelToDict [as 别名]
def prepareListSupplierByKataKunci((reqData)):
    requtil = Utility(reqData=reqData)
    kunci = requtil.nvlGet('kunci', None)
    jsups = []
    if kunci is not None:
        sups = models.Supplier.objects.filter(
            Q(nama__icontains=kunci) | Q(alamat__icontains=kunci))[
               :requtil.nvlGet('a', 8)]
    else:
        sups = models.Supplier.objects.all()[:requtil.nvlGet('a', 8)]
    for sup in sups:
        jsup = requtil.modelToDict(sup)
        jsups.append(jsup)
    return jsups;
开发者ID:tejo-ak,项目名称:warehouse,代码行数:16,代码来源:supplierMgt.py

示例6: prepareListPartnerByKataKunci

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import modelToDict [as 别名]
def prepareListPartnerByKataKunci((reqData)):
    requtil = Utility(reqData=reqData)
    kunci = requtil.nvlGet('kunci', None)
    if kunci is not None:
        custs = models.Partner.objects.filter(
            Q(nama__icontains=kunci) | Q(alamat__icontains=kunci))[
                :requtil.nvlGet('a', 8)]
    else:
        custs = models.Partner.objects.all()[:requtil.nvlGet('a', 8)]
    jcusts = [];
    for cust in custs:
        jcust = requtil.modelToDict(cust)
        jcusts.append(jcust)
    return jcusts;
开发者ID:tejo-ak,项目名称:warehouse,代码行数:16,代码来源:partnerMgt.py

示例7: prepareListBarangByKataKunci

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import modelToDict [as 别名]
def prepareListBarangByKataKunci((reqData)):
    requtil = Utility(reqData=reqData)
    kunci = requtil.nvlGet('kunci', None)
    barangs = []
    if kunci is not None:
        barangs = models.Barang.objects.filter(
            Q(nama__icontains=kunci) | Q(merk__icontains=kunci) | Q(tag__icontains=kunci))[
                  :requtil.nvlGet('a', 8)]
    else:
        barangs = models.Barang.objects.all()[:requtil.nvlGet('a', 8)]
    jbarangs = [];
    for barang in barangs:
        jbarang = requtil.modelToDict(barang)
        jbarangs.append(jbarang)
    return jbarangs;
开发者ID:tejo-ak,项目名称:warehouse,代码行数:17,代码来源:barangMgt.py

示例8: saveUpdateInventory

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import modelToDict [as 别名]
def saveUpdateInventory(reqData):
    requtil = Utility(reqData=reqData)
    inventory = models.Inventory()
    inventory = requtil.bindRequestModel(inventory)
    if requtil.hasKey('jnsInventory'):
        refJns = models.Referensi.objects.filter(id__exact=requtil.nvlGet('jnsInventory'))
        print refJns[0].nama
        inventory.jenis = refJns[0]

    if requtil.hasKey('jnsMetode'):
        refMet = models.Referensi.objects.filter(id__exact=requtil.nvlGet('jnsMetode'))
        inventory.metode = refMet[0]
    if requtil.nvlGet('id', None) is None:
        inventory.save()
    else: inventory.save()
    return requtil.modelToDict(inventory)
开发者ID:tejo-ak,项目名称:warehouse,代码行数:18,代码来源:inventoryMgt.py

示例9: dispatch

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import modelToDict [as 别名]
def dispatch(request):
    util = Utility(post=request.POST, get=request.GET)
    c = util.nvlGet('c');
    par = util.nvlGet('q', '')
    if c is not None:
        if 'formbarang' == c:
            return HttpResponse(json.dumps(prepareFormBarang(util.data)))
        if 'formpencarianbarang' == c:
            return render_to_response('inventory/form_barang_cari.html')
        if 'pencarianbarang' == c:
            return HttpResponse(json.dumps({'data': pencarianBarang(util.data)}))
        if 'barangsider' == c:
            return HttpResponse(json.dumps({'html': getBarangSider(util.data)}))
        if 'lookupbarang' == c:
            return HttpResponse(
                json.dumps(lookupBarang(util.nvlGet('katakunci', None), util.nvlGet('id'), util.nvlGet('max', None))));
        if 'lookupbdi' == c:
            return HttpResponse(
                json.dumps(lookupBdi(util.nvlGet('katakunci', None),
                    util.nvlGet('inventory_id', None), util.nvlGet('id'), util.nvlGet('max', None))));
        if 'caribarang' == c:
            return render_to_response('inventory/cari_kata_kunci.html')
        if 'formupload' == c:
            return HttpResponse(json.dumps({'html': render_to_string('inventory/form_barang_upload.html')}))
        if 'formuploadtes' == c:
            return render_to_response('inventory/form_barang_upload.html')
        if 'pdfsider' == c:
            slash = '/' if settings.ON_OPENSHIFT else '\\'
            return render_to_pdf('inventory/pdf/laporan.html', {'nama': 'tejo', 'merk': 'cocacola',
                                                                'font': '%s%s' % (
                                                                    os.path.join(settings.PROJECT_DIR, 'inventory',
                                                                        'static', 'img', 'font'), slash)})
        if 'upload' == c:
            f = request.FILES['uploadedfile']
            id = util.nvlGet('id', '-')
            url = saveGambarBarang(f, id)
            return HttpResponse('{"file":"%s","url":"%s","sukses":"true"}' % (f.name, url))
        if 'formlistbarang' == c:
            return HttpResponse(json.dumps(dict(
                    {'html': render_to_string('inventory/list_barang.html'),
                     'data': prepareListBarangByKataKunci(util.data)})))
        if 'formbahanbaku' == c:
            return HttpResponse(json.dumps(prepareFormBarang(util.data)))
        if 'barangbyname' == c:
            par = util.nvlGet('q', '')
            namas = []
            #g=500/0
            nama = 'noname'
            if len(par) > 2:
                pas = models.Barang.objects.filter(nama__icontains=par)[:util.nvlGet('a', 8)]
                for p in pas:
                    nama = util.modelToDicts([p])
                    namas.append(nama)
                    #return HttpResponseServerError('error dari server lhoo')
            data = dict({'eventid': util.nvlGet('eventid'), 'data': namas})
            return HttpResponse(json.dumps(data))
        if 'barangbyid' == c:
            brgs = models.Barang.objects.filter(id__exact=par)
            brg = models.Barang();
            if len(brgs):
                brg = brgs[0]
            return HttpResponse(json.dumps(util.modelToDicts([brg])))
        if 'baranginventorylist_bybarangid' == c:
            idBrg = util.nvlGet('id', None)
            jresp = {}
            jbdis = []
            if idBrg is not None:
                bdis = models.BarangDiInventory.objects.filter(barang__id__exact=idBrg)[:util.nvlGet('a', 8)]

                for bdi in bdis:
                    jbdi = util.modelToDicts([bdi.barang, bdi.inventory, bdi], replaces=['nama:nama_barang'])
                    jbdis.append(jbdi)
            jresp = dict({'html': render_to_string('inventory/list_saldo_barang.html'), 'data': jbdis})
            return HttpResponse(json.dumps(jresp))
        if 'barang_bynamamerktag' == c:
            jresp = dict({'data': prepareListBarangByKataKunci(util.data), 'eventid': util.nvlGet('eventid')})
            return HttpResponse(json.dumps(jresp))
        if 'hapusbarang' == c:
            barang = models.Barang.objects.filter(id__exact=util.nvlGet('id', 0));
            dp = {}
            if barang:
                #hapus semua barang di inventory
                barangs = models.BarangDiInventory.objects.filter(barang__id__exact=util.nvlGet('id', 0));
                #hapus semua harga
                hargas = models.Harga.objects.filter(barang__id__exact=util.nvlGet('id', 0));
                for brgInv in barangs:
                    brgInv.delete();
                for hrg in hargas:
                    hrg.delete();
                dp = util.modelToDict(barang[0])
                barang[0].delete()
            return HttpResponse(json.dumps(dp))
        if 'updatebarang' == c:
        #hanya untuk mengupdate data barang, bukan barang di inventory
            return HttpResponse(json.dumps(updateBarang(util.data)))
        if 'simpanbarang' == c:
            #simpanPasien(request.POST)
            return HttpResponse(json.dumps(saveUpdateBarangDiInventory(util.data)))
        if 'sidesaldo' == c:
            return HttpResponse(json.dumps({'html': prepareSideSaldo(util.data)}))
#.........这里部分代码省略.........
开发者ID:tejo-ak,项目名称:warehouse,代码行数:103,代码来源:barangMgt.py


注:本文中的utility.Utility.modelToDict方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。