Esempio n. 1
0
    class Admin(CachingModel.Admin):
        sort_fields = ["areaid"]
        visible = not get_option("ONLY_POS")  #单独消费的时候不显示
        app_menu = "iclock"
        menu_group = 'iclock'
        menu_index = 9990
        query_fields = ['areaid', 'areaname', 'remark']  #需要查找的字段
        default_widgets = {
            'parent':
            ZDeptChoiceWidget(
                attrs={
                    "async_model": "personnel__Area",
                    "async_url": "/personnel/get_children_nodes/",
                    "limit": True,
                }),
        }
        adv_fields = ['areaid', 'areaname', 'parent', 'remark']
        list_display = ['areaid', 'areaname', 'parent', 'remark']
        newadded_column = {
            'parent': 'get_parent',
        }
        cache = 3600
        opt_perm_menu = {
            "opadjustarea_area": "att.AttDeviceUserManage"
        }  #{权限操作的名字(小写):菜单的路径(app_menu.model)}
        disabled_perms = ["clear_area", "dataimport_area"]

        @staticmethod
        def initial_data():  #初始化时增加一个区域
            if Area.objects.count() == 0:
                Area(areaname=u"%s" % _(u"区域名称"), areaid="1",
                     parent=None).save()
            pass
Esempio n. 2
0
 class Admin(CachingModel.Admin):
         from depttree import ZDeptChoiceWidget
         sort_fields = ["name", "code"]
         app_menu = "personnel"
         help_text = _(u"如果新增的部门在部门列表中未能显示,请联系管理员到用户编辑中重新授权部门!")
         search_fields = ['name', 'code']
         list_display = ('code', 'name', 'parent')
         adv_fields = ['code', 'name']
         list_filter = ('type', 'parent', 'invalidate')
         newadded_column = {
            'parent':'get_parent',
         }
         
         import_fields = ['code', 'name', 'parent']
         default_widgets = {
             'parent': ZDeptChoiceWidget(attrs={
             "async_model":"personnel__Department",
             "async_url":"/personnel/get_children_nodes/",
             "limit":True,
         })}
         
         query_fields = ['code', 'name']
         disabled_perms = ["clear_department"]
         menu_index = 1
         cache = 3600
         report_fields=['code', 'name', 'parent']
         @staticmethod
         def initial_data(): #初始化时增加一个部门
                 if Department.objects.count() == 0:
                         Department(name=u"%s"%_(u"部门名称"), code="1").save()
                 pass
Esempio n. 3
0
def update_dept_widgets():
        from dbapp import widgets
        from depttree import ZDeptMultiChoiceWidget
        if DeptForeignKey not in widgets.WIDGET_FOR_DBFIELD_DEFAULTS:
                from depttree import ZDeptChoiceWidget
                widgets.WIDGET_FOR_DBFIELD_DEFAULTS[DeptForeignKey] = ZDeptChoiceWidget(attrs={
                    "async_model":"personnel__Department",
                    "async_url":"/personnel/get_children_nodes/"
                })
        if DeptManyToManyField not in widgets.WIDGET_FOR_DBFIELD_DEFAULTS:
                widgets.WIDGET_FOR_DBFIELD_DEFAULTS[DeptManyToManyField] = ZDeptMultiChoiceWidget(attrs={
                    "async_model":"personnel__Department",
                    "async_url":"/personnel/get_children_nodes/"
                })
Esempio n. 4
0
def update_area_widgets():
    from dbapp import widgets
    if AreaForeignKey not in widgets.WIDGET_FOR_DBFIELD_DEFAULTS:
        from depttree import ZDeptChoiceWidget
        widgets.WIDGET_FOR_DBFIELD_DEFAULTS[
            AreaForeignKey] = ZDeptChoiceWidget(
                attrs={
                    "async_model": "personnel__Area",
                    "async_url": "/personnel/get_children_nodes/",
                    "limit": True,
                })
    if AreaManyToManyField not in widgets.WIDGET_FOR_DBFIELD_DEFAULTS:
        from depttree import ZDeptMultiChoiceWidget
        widgets.WIDGET_FOR_DBFIELD_DEFAULTS[
            AreaManyToManyField] = ZDeptMultiChoiceWidget(
                attrs={
                    "async_model": "personnel__Area",
                    "async_url": "/personnel/get_children_nodes/",
                    "limit": True,
                })