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


Python Group.is_active方法代码示例

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


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

示例1: initData

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import is_active [as 别名]
def initData(request):
    if not request:
        xls = '../static/data.xls'
    else:
        from FTknowledge.settings import STATIC_ROOT
        from models import Group, TaxKind, TaxTicket, BBField, BBFieldValue, KJKM, KJKMTicket
        xls = '%s/data.xls'%STATIC_ROOT
        bbdict = {}
        s=u'关联增值税报表主表 关联增值税报表主表一 关联增值税报表主表二 固定资产抵扣 关联企业所得税主表 关联税收优惠明细表 关联所得税与流转税对比表 关联财务报表利润表'
        for ss in s.split(' '):
            if not bbdict.has_key(ss):
                bbdict[ss]=BBField.objects.get(fieldname=ss)

    bk = xlrd.open_workbook(xls)



    for sheetname in bk.sheet_names():
        if 'Sheet3' == sheetname:
            continue
        if request:
            if Group.objects.filter(name=sheetname).count()==0:
                group = Group()
                group.name = sheetname
                group.is_active = True
                group.save()
            else:
                group = Group.objects.get(name=sheetname)

        startrow = 2
        # if u'商业类' != sheetname:
        #     continue
        print sheetname
        sh = bk.sheet_by_name(sheetname)

        nrows = sh.nrows
        nclos = sh.ncols
        l = countRows(2,nrows,0,sh)
        for s,e in l:
            print '(%s,%s):%s'%(s,0,sh.cell_value(s,0))

            if request:
                sname=sh.cell_value(s,0)
                if TaxKind.objects.filter(name=sname).count()==0:
                    tax = TaxKind()
                    tax.name = sname
                    tax.fatherKind = None
                    tax.is_active = True
                    tax.save()
                else:
                    tax = TaxKind.objects.get(name=sname)
            zl = countRows(s,e+1,1,sh)
            for ss,ee in zl:
                print '(%s,%s):%s'%(ss,1,sh.cell_value(ss,1))

                if request:
                    ssname = sh.cell_value(ss,1)
                    if TaxKind.objects.filter(name=ssname,fatherKind=tax).count()==0:
                        sstax = TaxKind()
                        sstax.name = ssname
                        sstax.fatherKind = tax
                        sstax.is_active = True
                        sstax.save()
                    else:
                        sstax = TaxKind.objects.get(name =ssname,fatherKind=tax)

                pl = countRows(ss,ee+1,2,sh)
                for ps,pe in pl:
                    print '(%s,%s):%s'%(ps,2,sh.cell_value(ps,2))
                    if request:
                        psname = sh.cell_value(ps,2)
                        if TaxTicket.objects.filter(name=psname,group=group,taxkind=sstax).count()==0:
                            ticket = TaxTicket()
                            ticket.name = psname
                            ticket.group = group
                            ticket.taxkind = sstax
                            ticket.save()
                        else:
                            ticket = TaxTicket.objects.get(name=psname,group=group,taxkind=sstax)

                        try:
                            t = Ticket()
                            t.name = psname
                            t.save()
                        except:
                            pass


                    print '(%s,%s):%s'%(ps,3,sh.cell_value(ps,3))
                    if request:
                        kjkmname = sh.cell_value(ps,3)
                        if KJKM.objects.filter(name = kjkmname).count()==0:
                            kjkm = KJKM()
                            kjkm.name = kjkmname
                            kjkm.save()
                        else:
                            kjkm = KJKM.objects.get(name=kjkmname)

                        if KJKMTicket.objects.filter(kjkm=kjkm,tickets=ticket).count()==0:
                            kjkmticket = KJKMTicket()
#.........这里部分代码省略.........
开发者ID:wangjian2254,项目名称:FTknowledge,代码行数:103,代码来源:importExcel.py


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