Ejemplo n.º 1
0
 def get_form_layout(self):
     if self.org_obj:
         self.form_layout = (Main(
             Fieldset('',
                      'username',
                      'password',
                      css_class='unsort no_title'),
             Fieldset(_('Personal info'), Row('first_name', 'last_name'),
                      'email'),
             Fieldset(_('Permissions'), 'groups', 'user_permissions'),
             Fieldset(_('Important dates'), 'last_login', 'date_joined'),
         ),
                             Side(
                                 Fieldset(
                                     _('Status'),
                                     'is_active',
                                     'is_staff',
                                     'is_superuser',
                                 ), ))
     return super(UserAdmin, self).get_form_layout()
Ejemplo n.º 2
0
 def get_form_layout(self):
     if self.org_obj:
         self.form_layout = (
             Main(
                 # Fieldset("講師信息",
                 #          'teacher','course_org',
                 #          css_class='unsort no_title'
                 #          ),
                 # Fieldset("基本信息",
                 #          'name', 'desc',
                 #          Row('learn_times', 'degree'),
                 #          Row('category', 'tag'),
                 #          'youneed_know', 'teacher_tell', 'detail',
                 #          ),
             ),
             Side(
                 Fieldset("訪問信息", 'fav_nums', 'click_nums', 'students',
                          'add_time'), ),
             Side(Fieldset("選擇信息", 'is_banner', 'is_classics'), ))
     return super(NewCourseAdmin, self).get_form_layout()
Ejemplo n.º 3
0
class CategoryAdmin(object):
    list_display = [
        "title", "father", "template", "image", "isNew", "isDelete",
        "isHidden", "sort", "hash_id"
    ]
    search_fields = ["title", "hash_id"]
    list_filter = ["father", "isNew", "isDelete", "isHidden"]
    list_editable = ["isNew", "isDelete", "isHidden", "sort"]
    readonly_fields = ["hash_id"]
    model_icon = 'fa fa-folder'

    form_layout = (Main(
        Fieldset(None, 'hash_id', **{"style": "display:None"}),
        Fieldset('必填', 'title', Row('template', 'article_template')),
        Fieldset('SEO', Row('description', 'keywords')),
        Fieldset('选填', Row('father', 'redirect'), 'img'),
    ),
                   Side(
                       Fieldset('辅助', "isNew", "isDelete", "isHidden", "sort",
                                "supplement"), ))
Ejemplo n.º 4
0
class Culture_accountAdmin(object):
    list_display = [
        'id', 'limit_watch', 'watch_duration_min', 'watch_duration_max',
        'watch_times', 'date_joined'
    ]
    exclude = ['user']
    ordering = ['id']

    form_layout = (
        Main(  #中心内容
            Fieldset(
                '常规设置',
                Row('limit_watch', 'watch_duration_min',
                    'watch_duration_max')),
            Fieldset('随机时间暂停',
                     Row('watch_times', 'pause_time_min', 'pause_time_max')),
            Fieldset(
                '评论区功能',
                Row('comment_nice_probability', 'comment_nice_min_times',
                    'comment_nice_max_times')),
            Fieldset(
                '关注作者',
                Row('follow_author_probability',
                    'follow_author_pause_time_min',
                    'follow_author_pause_time_max'))),
        Side(  #侧边框
            Fieldset('点赞及评论概率', Row('nice_probability',
                                    'comment_probability')),
            Fieldset('转发概率', Row('forward_probability')),
        ))

    def queryset(self):
        qs = super(Culture_accountAdmin, self).queryset()
        if self.request.user.is_superuser:  # 超级用户可查看所有数据
            return qs
        else:
            return qs.filter(user_id=self.request.user)

    def save_models(self):
        self.new_obj.user = self.request.user
        super(Culture_accountAdmin, self).save_models()
Ejemplo n.º 5
0
 def get_form_layout(self):
     self.form_layout = (
         Main(
             Fieldset("讲师信息",
                      'teacher','course_org',
                      css_class='unsort no_title'
                      ),
             Fieldset("基本信息",
                      'name', 'desc',
                      Row('learn_times','degree'),
                      Row('category'),
                      'notice', 'detail','image'
                      ),
         ),
         Side(
             Fieldset("访问信息",
                      'fav_nums', 'click_nums', 'students', 'add_time'
                      ),
         ),
     )
     return super(NewCourseAdmin, self).get_form_layout()
Ejemplo n.º 6
0
 def get_form_layout(self):
     self.form_layout = (
         Main(
             Fieldset('机构信息',
                      'name', 'city',
                      Row('category', 'tags', 'course_nums'),
                      'image', 'address', 'desc',
                      ),
         ),
         Side(
             Fieldset('访问信息',
                      'fav_nums', 'click_nums', 'students', 'add_time',
                      ),
         ),
         Side(
             Fieldset('选择信息',
                      'is_gold', 'is_auth',
                      ),
         ),
     )
     return super(CourseOrgAdmin, self).get_form_layout()
Ejemplo n.º 7
0
 def get_form_layout(self):
     self.form_layout = (
         Main(
             Fieldset('基本信息',
                      'image',
                      Row('name', 'age'),
                      'user',
                      'points',
                      ),
             Fieldset('工作信息',
                      Row('work_company', 'work_position'),
                      Row('work_years', 'org'),
                      ),
         ),
         Side(
             Fieldset('访问信息',
                      'fav_nums', 'click_nums', 'add_time',
                      ),
         ),
     )
     return super(TeachersAdmin, self).get_form_layout()
Ejemplo n.º 8
0
class GroupClientsAdmin(object):
    """
    集团大客户
    """
    list_display = [
        'name',
        'contact_man',
        'telephone',
        'address',
        'bank_name',
        'account_name',
        'account_number',
        'tax_number',
        'legal_person',
    ]
    search_fields = ['name', 'telephone', 'account_name', 'legal_person']
    model_icon = 'fa fa-weixin'
    form_layout = (Main(
        Fieldset(
            '基本信息',
            Row('name', 'telephone'),
            Row('contact_man', 'address'),
            Row('legal_person', 'id_card'),
        ),
        Fieldset(
            '公司银行信息',
            Row('bank_name', 'account_name'),
            Row('account_number', 'tax_number'),
        ),
        Fieldset(
            '其他信息',
            Row(AppendedText('subscribe_fee', '元'),
                AppendedText('occupy_fee', '元')),
            Row(AppendedText('low_fee', '元'), 'low_restrict'),
        ),
    ),
                   Side(
                       Fieldset("优惠方案", "dicount", "is_reduction",
                                AppendedText("purchase_amount", "元"),
                                AppendedText("reduction", "元")), ))
Ejemplo n.º 9
0
    def get_form_layout(self):
        self.form_layout = (Main(
            Fieldset("讲师信息",
                     'teacher',
                     'course_org',
                     css_class='unsort no_title'),
            Fieldset(
                "基本信息",
                'name',
                'desc',
                Row('learn_time', 'degree'),
                Row('category', 'tag'),
            ),
            Fieldset('课程详情', 'you_need_know', 'teacher_says', 'notice',
                     'detail'),
            Fieldset('广告信息', 'image', 'is_banner'),
        ),
                            Side(
                                Fieldset(('访问信息'), 'students_num', 'fav_num',
                                         'click_nums', 'add_time'), ))

        return super(NewCourseAdmin, self).get_form_layout()
Ejemplo n.º 10
0
 def get_form_layout(self):
     if self.org_obj:
         self.form_layout = (Main(
             Fieldset(
                 _('基本信息'),
                 'company_name',
                 'company_type',
                 'url',
                 'city',
                 'keyword',
             ),
             Fieldset(
                 _('意向信息'),
                 'sem_status',
                 'aike_status',
             ),
             Fieldset(
                 _('签单信息'),
                 'depart',
                 'sales',
                 'amount',
                 'business',
             ),
             Fieldset(
                 _('时间信息'),
                 'create_time',
                 'update_time',
             ),
             Fieldset(
                 _('发现信息'),
                 'discover_time',
                 'discover_count',
             ),
             Fieldset(
                 _('终端信息'),
                 'source',
             ),
         ), Side())
     return super(SuccessCustomerAdmin, self).get_form_layout()
Ejemplo n.º 11
0
 def get_form_layout(self):
     if self.org_obj:
         self.form_layout = (
             Main(
                 Fieldset(_('Personal info'),
                          'username',
                          'password',
                          'phone',
                          'identity',
                          ),
                 Fieldset(_('权限信息'),
                          'groups', 'user_permissions', 'first_name', 'last_name', 'email',
                          ),
                 Fieldset(_('Important dates'),
                          'last_login', 'date_joined'
                          ),
                 Fieldset(_('用户状态'),
                          'is_active', 'is_staff', 'is_superuser',
                          )
             ),
         )
     return super(UserAdmin, self).get_form_layout()
Ejemplo n.º 12
0
class ArticleAdmin(object):
    """
    文章模型数据管理注册
    """

    model_icon = 'fa fa-book'  #: 模型菜单图标
    list_display = ('title', 'user', 'portal', 'category', 'tag',
                    'get_comment', 'date_publish')  #: 列表栏目

    list_filter = ('title', 'user', 'url', 'click_count', 'like_count',
                   'is_recommed', 'date_publish', 'category', 'tag')  #: 过滤字段

    search_fields = ('name', 'author', 'publish_house')

    list_editable = ['title']

    def get_comment(self, article):
        comment = article.comment.count()
        return comment

    get_comment.short_description = "评论数"
    get_comment.is_column = True
    get_comment.allow_tags = True
    get_comment.admin_order_field = 'comment'

    form_layout = (Main(
        Fieldset("基本信息", 'title', 'user', 'content', 'portal', 'url',
                 'date_publish', 'category', 'tag'),
        Fieldset("文章属性", 'click_count', 'like_count'),
        Fieldset("其他信息", 'desc'),
    ), Side(Fieldset("特别信息", 'is_recommed')))

    # 引入媒体文件,创建富文本
    class Media:
        js = (
            '/static/js/kindeditor-4.1.10/kindeditor-min.js',
            '/static/js/kindeditor-4.1.10/lang/zh_CN.js',
            '/static/js/kindeditor-4.1.10/config.js',
        )
Ejemplo n.º 13
0
 def get_form_layout(self):
     if self.org_obj:
         self.form_layout = (Main(
             Fieldset('',
                      'username',
                      'password',
                      css_class='unsort no_title'),
             Fieldset(
                 '个人信息',
                 Row(),
                 'name',
                 'mobile',
                 'email',
                 'card_number',
                 'card_number_attendance',
                 'wage_type',
                 'work_type',
                 'attendance_shift',
                 'position',
                 'attendance_shift',
             ),
             Fieldset('权限', 'groups', 'user_permissions'),
             Fieldset(
                 '重要日期',
                 'operator',
                 'operator_time',
                 'operator_last',
                 'operator_last_time',
                 'date_joined_company',
                 'last_login',
             ),
         ), Side(Fieldset(
             '状态',
             'is_active',
             'is_staff',
             'is_superuser',
         ), ))
     return super(MyUserAdmin, self).get_form_layout()
Ejemplo n.º 14
0
class PurchasingAssetAdmin(object):
    list_display = [
        "name", "configuration", "nums", "unit_price", "total_prices", "year",
        "applicaton_department", "applicants", "purchase_date"
    ]
    list_editable = ["is_account"]
    search_fields = ['name']
    list_filter = ['name', 'is_arrival', 'is_account', 'is_purchase']
    readonly_fields = ['total_prices']
    reversion_enable = True
    form_layout = (Main(
        Fieldset(
            "基本信息",
            Row("applicaton_department", "applicants"),
            Row("name", "apply_date"),
            Row("configuration", "nums"),
            Row("cost_types"),
            Row("description"),
        ),
        Fieldset(
            "扩展信息",
            Row("year", "total_prices"),
            Row(
                "invoice_num",
                "assets_num",
            ),
            Row("purchase_date", "unit_price"),
        ), Fieldset("", )),
                   Side(
                       Fieldset(('Status'), 'is_purchase', 'is_arrival',
                                'is_account'), ))
    actions = ['set_is_account']

    def set_is_account(modeladmin, request, queryset):
        selected = request.POST.getlist(admin.ACTION_CHECKBOX_NAME)
        PurchasingAsset.objects.filter(id__in=selected).update(is_account=True)

    set_is_account.short_description = "设置所选内容为已报销"
Ejemplo n.º 15
0
 def get_form_layout(self):
     # self.org_obj指的是,仅当修改的时候才采用本设置,新建还是老样式
     if self.org_obj:
         self.form_layout = (
             Main(
                 Fieldset(
                     '讲师信息',
                     'teacher',
                     'course_org',
                     # 不给当前区域取名
                     css_class='unsort no_title'),
                 Fieldset(
                     '基本信息',
                     'name',
                     'desc',
                     Row('learn_times', 'degree'),
                     Row('category', 'tag'),
                     'youneed_know',
                     'teacher_tell',
                     'detail',
                 ),
             ),
             Side(
                 Fieldset(
                     '访问信息',
                     # 'fav_nums', 'click_nums',
                     'students',
                     'add_time',
                 ), ),
             Side(Fieldset(
                 '选择信息',
                 'is_banner',
                 'is_classics',
             ), ),
         )
     # print(self.__class__.__mro__)
     # print(NewCoursesAdmin.mro())
     return super(NewCoursesAdmin, self).get_form_layout()
Ejemplo n.º 16
0
class OrderAdmin:
    list_display = (
        'user',
        'is_accept',
        'date_create',
        'is_done',
        'date_done',
    )

    list_filter = (
        'is_accept',
        'is_done',
        'is_abnormal',
    )

    search_fields = (
        'food',
        'user',
    )

    form_layout = (Main(
        Fieldset("基本信息", 'user', 'food', 'trank', 'prank'),
        Fieldset(
            "时间",
            'date_create',
            'date_done',
        ),
    ),
                   Side(
                       Fieldset(
                           "状态控制",
                           'is_accept',
                           'is_done',
                           'is_abnormal',
                           'is_push',
                           'is_comment',
                       )))
Ejemplo n.º 17
0
class NodeAdmin(object):
    inlines = [NodeBranchInline]
    form_layout = (Main(
        Fieldset(
            '',
            Row('modal', 'name'),
            Row('code', 'notice_type'),
            Row('handler_type'),
            Row('handler_user', 'handler_role'),
            Row('handler_department', 'handler_position'),
        ), ),
                   Side(
                       Fieldset(('Status'), 'code_branch', 'start', 'stop',
                                'can_approve', 'can_deny', 'can_transfer',
                                'can_reject', 'can_finish', 'can_not_finish',
                                'can_delete'), ))
    list_display = [
        'modal', 'code', 'name', 'start', 'stop', 'can_approve', 'can_deny',
        'can_transfer', 'can_reject', 'can_finish', 'can_not_finish',
        'can_delete'
    ]
    list_filter = ['modal']
    readonly_fields = ['modal', 'code', 'name']
    search_fields = ['modal__name']
Ejemplo n.º 18
0
class ItManagerAdmin(object):
    inlines = [ItRecordInline]
    list_display = ['name','ip','username','dep','is_active']
    search_fields = ['name','ip','remarks','dep__two_department','is_active']
    list_filter = ['name','ip','remarks','is_active']
    reversion_enable = True
    form_layout = (
        Main(
            Fieldset('',
                     Row('name', 'model'),
                     Row('ip', 'system'),
                     Row('username', 'password'),
                     Row('link'),
                     Row('tel', 'application'),
                     Row('dep'),
                     Row('remarks'),
                     ),
        ),
        Side(
            Fieldset(('Status'),
                     'is_active'
                     ),
        )
    )
Ejemplo n.º 19
0
 def get_form_layout(self):
     if self.org_obj:
         self.form_layout = (
             Main(
                 Fieldset('订单基本信息',
                          'order_date',
                          'sales','sale_source',
                          'useage', 'useage_detail',
                          'place','series_num','price'
                          ),
                 Fieldset('客户基本信息',
                          'customer',
                          'customer_source',
                          'province', 'city',
                          'wangwang'
                          ),
                 Fieldset('收件信息',
                          Row('reciever', 'phone'),
                          'address',
                          'remark'
                          ),
             ),
         )
     return super(OrderAdmin, self).get_form_layout()
Ejemplo n.º 20
0
class HostAdmin(object):
    def open_web(self, instance):
        return "<a href='http://%s' target='_blank'>Open</a>" % instance.ip

    open_web.short_description = "Acts"
    open_web.allow_tags = True
    open_web.is_column = True

    list_display = ('name', 'idc', 'guarantee_date', 'service_type', 'status',
                    'open_web', 'description')
    list_display_links = ('name', )

    raw_id_fields = ('idc', )
    style_fields = {'system': "radio-inline"}

    search_fields = ['name', 'ip', 'description']
    list_filter = [
        'idc', 'guarantee_date', 'status', 'brand', 'model', 'cpu', 'core_num',
        'hard_disk', 'memory',
        ('service_type', xadmin.filters.MultiSelectFieldListFilter)
    ]

    list_quick_filter = ['service_type', {'field': 'idc__name', 'limit': 10}]
    list_bookmarks = [{
        'title': "Need Guarantee",
        'query': {
            'status__exact': 2
        },
        'order': ('-guarantee_date', ),
        'cols': ('brand', 'guarantee_date', 'service_type')
    }]

    show_detail_fields = ('idc', )
    list_editable = ('name', 'idc', 'guarantee_date', 'service_type',
                     'description')
    save_as = True

    aggregate_fields = {"guarantee_date": "min"}
    grid_layouts = ('table', 'thumbnails')

    form_layout = (Main(
        TabHolder(
            Tab(
                'Comm Fields',
                Fieldset('Company data',
                         'name',
                         'idc',
                         description="some comm fields, required"),
                Inline(MaintainLog),
            ),
            Tab(
                'Extend Fields',
                Fieldset(
                    'Contact details', 'service_type', Row('brand', 'model'),
                    Row('cpu', 'core_num'),
                    Row(AppendedText('hard_disk', 'G'),
                        AppendedText('memory', "G")), 'guarantee_date'),
            ),
        ), ), Side(Fieldset('Status data', 'status', 'ssh_port', 'ip'), ))
    inlines = [MaintainInline]
    reversion_enable = True

    data_charts = {
        "host_service_type_counts": {
            'title': u"Host service type count",
            "x-field": "service_type",
            "y-field": ("service_type", ),
            "option": {
                "series": {
                    "bars": {
                        "align": "center",
                        "barWidth": 0.8,
                        'show': True
                    }
                },
                "xaxis": {
                    "aggregate": "count",
                    "mode": "categories"
                },
            },
        },
    }
Ejemplo n.º 21
0
class WorkspaceAdmin(object):
    def queryset(self):
        qs = super(WorkspaceAdmin, self).queryset()
        if self.request.user.username in PREVILEGED_USER_SETS:
            return qs
        else:
            return qs.filter(user=self.request.user)

    # readonly_fields = ('user', )
    def uniq_name(self, instance):
        return instance.name + "_" + instance.user.username

    uniq_name.short_description = "唯一ID"
    uniq_name.allow_tags = True
    uniq_name.is_column = True

    list_editable = ['name', 'summary']
    list_display = (
        'name',
        "user",
        'uniq_name',
        'summary',
        'date_updated',
    )

    fieldsets = [
        ("工作组名称", {
            'fields': ['name']
        }),
        ('用户', {
            'fields': ['user'],
            'classes': ['collapse']
        }),
    ]

    # form_layout = (
    #     Fieldset("名称", 'name', 'summary'),
    #     Fieldset(None, 'user', 'desc', 'id', **{"style": "display:None"}),
    # )

    inlines = [
        ScanTaskInline,
    ]

    actions = None
    # aggregate_fields = {"user_count": "sum", "view_count": "sum"}
    # refresh_times = (3, 5, 10)

    form_layout = (Main(TabHolder(Tab(
        "创建扫描任务",
        'name',
        Inline(ScanTask),
    ), ), ),
                   Side(
                       Fieldset("名称", 'summary'),
                       Fieldset(None, 'user', 'desc', 'id',
                                **{"style": "display:None"}),
                   ))

    def save_models(self):
        instance = self.new_obj
        request = self.request

        instance.user = request.user
        instance.save()
Ejemplo n.º 22
0
class ProductAdmin(object):

    list_display = ['productName', 'image', 'sellerSku', 'brand', 'status']
    list_display_links = ['productName']

    list_filter = ('brand', 'series', 'status')

    search_fields = ('productName', 'sellerSku')
    show_detail_fields = ['productName']

    style_fields = {"accessories": "checkbox-inline"}

    form_layout = (
        Main(
            TabHolder(
                Tab(
                    "Product Inf",
                    Fieldset(
                        "Basic Inf",
                        "productName",
                        'title',
                        "status",
                        'sellerSku',
                        'image',
                        # Row(
                        #     AppendedText("weight", "G"),
                        #     AppendedText("offer", "$")
                        # ),
                        AppendedText("weight", "G"),
                        AppendedText("offer", "$"),
                        'brand',
                        'series',
                        'number',
                        'target_audience',
                        'scene',
                        'designer',
                        'inf_more',
                        'slogan',
                        'features',
                        'a_description',

                        # description="产品的一些基本信息",
                    )),
                Tab(
                    "More Inf",
                    Fieldset(
                        "More Inf",
                        'accessories',
                    ),
                )), ),
        # Side(
        #     Fieldset("什么都没有"),
        # )
    )
    #设置导出的列
    list_export_fields = ("productName", 'title', "status", 'sellerSku')
    list_per_page = 15
    import_export_args = {
        'import_resource_class': PustomerResource,
        # 'export_resource_class': ProductInfoResource,
    }
Ejemplo n.º 23
0
class IDCAdmin(object):

    # 自定义显示列
    def open_web(self, instance):
        return """<a href="http://%s" target="_blank">Open</a>""" % instance.name

    open_web.short_description = "Acts"
    open_web.allow_tags = True
    open_web.is_column = True

    # 插件 list
    # 列表显示的字段 默认 ('__str__',)
    list_display = ('name', 'description', 'create_time', 'contact', 'telphone', 'address', 'customer_id', 'open_web')
    # 显示修改或查看数据详情连接的列
    list_display_links = ('name',)
    # 点击列表连接后是否转到详情页面
    list_display_links_details = False
    # 是否提前加载关联数据, 使用 ``select_related``
    list_select_related = None
    # 每页显示数据的条数
    list_per_page = 50
    # 每页最大显示数据的条数
    list_max_show_all = 200
    # 排除显示的列, 在显示列的设置中不会出现这些被排除的列
    list_exclude = ()
    # 搜索的字段, 使用模糊搜索
    search_fields = ['name', 'description', 'contact', 'telphone', 'address']
    # 是否可以自由搜索. 如果开启自由搜索, 用户可以通过 url 参数来进行特定的搜索, 例如:name__contains=我,默认为 True
    # 这个会影响到过滤,因为他也规范化了过滤查询内容
    # free_query_filter = False
    # 排序(加‘-’表示降序)
    # ordering = None

    # 添加数据时候,一步一步填写数据
    wizard_form_list = [
        ('第一步', ('name', 'description')),
        ('第二步', ('contact', 'telphone', 'address')),
        ('第三步', ('customer_id',))
    ]

    # 过滤器, 系统会自动生成搜索器
    list_filter = ['name', ]
    # list_quick_filter 必须是 list_filter 的一个子集才能工作
    list_quick_filter = [{'field': 'name', 'limit': 10}]
    # 添加过滤(这里是过滤日期)
    # date_hierarchy = ['date']
    # filter_horizontal 从‘多选框’的形式改变为‘过滤器’的方式,水平排列过滤器,
    # 必须是一个 ManyToManyField类型,且不能用于 ForeignKey字段,
    # 默认地,管理工具使用``下拉框`` 来展现`` 外键`` 字段
    # filter_horizontal = ('authors',)
    # 同上 filter_horizontal,垂直排列过滤器
    # filter_vertical = ['authors', ]

    # 开启书签功能,默认为 True
    # show_bookmarks = False
    # 设置默认书签
    # 用户可以在列表页面添加自己的书签, 我们可以设定好一些默认书签
    list_bookmarks = [{
        'title': '我是默认书签',  # 书签的名称, 显示在书签菜单中
        'query': {'name__exact': '123'},  # 过滤参数, 是标准的 queryset 过滤
        'order': ('-name',),  # 排序参数
        'cols': ('name', 'contact'),  # 显示的列
        'search': 'name'  # 搜索参数, 指定搜索的内容
    },
    ]

    # 定义数据导出功能,可以导出 Excel, CSV, XML, json 格式('xls', 'csv', 'xml', 'json')
    list_export = ('xls', 'csv', 'xml', 'json')

    # 列表定时刷新
    # 定义自动刷新列表, 用户可以选择3秒或5秒刷新一次页面
    refresh_times = (3, 5)

    # 显示数据详情 details
    # 设置哪些字段要显示详细信息的按钮
    show_detail_fields = ['name', ]
    # 自动显示所有关联字段的详细信息, 该属性默认为 True
    # show_all_rel_details = False

    # 数据即时编辑
    # 使用 Ajax , 无需提交或刷新页面即可完成数据的修改
    list_editable = ['name']

    # 将ForeignKey字段从‘下拉框’改变为‘文本框’显示
    raw_id_fields = ("groups",)

    # 当 Model 是其他 Model 的 ref model 时,其他 Model 在显示本 Model 的字段时使用的 Field Style
    # fk-ajax 涉及到外键下拉的时候使用ajax搜索的方式而不是全部列出的方式,比如在分类下拉很多的情况下,这个功能就很好用
    relfield_style = 'fk-select'

    # 图标样式
    model_icon = 'fa fa-user-secret'

    reversion_enable = True

    # 插件 edit
    # 是否显示 ``另存为`` 按钮,默认为 False
    save_as = True
    # 是否在页面上面显示按钮组,默认为 False,这个测试无效
    # save_on_top = True
    # 字段显示样式
    # style_fields = {
    #     "name": "radio-inline",
    #     "contact": "checkbox-inline",
    # }

    # 页面 Form 的 Layout 对象,是一个标准的 Crispy Form Layout 对象。
    # 使用 Layout 可以方便的定义整个 Form 页面的结构。
    form_layout = (
        # 主区域
        Main(
            TabHolder(
                Tab(
                    'TAB 名字',
                    Fieldset(
                        '名字',
                        # 单行显示字段内容
                        Row('telphone', 'address'),
                        'description',
                        # Inline(MaintainLog),  # 无效
                        description='一些说明文字',
                    ),
                ),
                Tab(
                    'TAB 名字 2',
                    Fieldset(
                        '一些名字',
                        Row('telphone', 'address'),
                        Row(
                            AppendedText('customer_id', '描述'),
                        ),
                        # 'create_time'    # 无效
                    ),
                ),
            ),
        ),
        # 侧边区域
        Side(
            Fieldset('Status data', 'telphone', 'address'),
        )
    )

    # 插件 aggregation
    # 列聚合,在list表格下面会增加一行统计的数据,可用的值: count min max avg sum
    # aggregate_fields = {'user_count': 'sum', }

    # 插件 layout
    # 列表的布局方式,是以表格一行一条的方式还是类似于缩略图的方式展示的
    # grid_layouts = ("table", "thumbnails")

    # actions 属性是一个列表, 包含启用的 Action 的类. 系统已经默认内置了删除数据的 Action,
    # 可以制作 Action 来实现特定的功能, 例如 MyAction
    actions = [BatchChangeAction, MyAction, ]
    # 批处理的字段
    batch_fields = ('contact', 'description', 'address', 'customer_id')
Ejemplo n.º 24
0
class PerformanceInfoAdmin(object):
    def update_button(self, obj):
        # 修改按钮
        button_html = '<a class="icon fa fa-edit" style="color: green" href="/admin/interface/performanceinfo/%s/update/">修改</a>' % obj.id
        return format_html(button_html)

    update_button.short_description = '<span style="color: green">修改</span>'
    update_button.allow_tags = True

    def delete_button(self, obj):
        # 删除按钮
        button_html = '<a class="icon fa fa-times" style="color: blue" href="/admin/interface/performanceinfo/%s/delete/">删除</a>' % obj.id
        return format_html(button_html)

    delete_button.short_description = '<span style="color: blue">删除</span>'
    delete_button.allow_tags = True

    def download_button(self, obj):
        # 下载按钮
        button_html = '<a class="icon fa fa-download" style="color: orange" href="/media/%s">下载</a>' % obj.jmeter_script
        return format_html(button_html)

    download_button.short_description = '<span style="color: orange">下载</span>'
    download_button.allow_tags = True

    form_layout = (
        Main(
            Fieldset('压测信息部分', 'script_introduce', 'jmeter_script',
                     'sample_number', 'duration'), ),
        # Side(
        #     Fieldset('时间部分',
        #              'create_time', 'update_time'),
        # )
    )

    list_display = [
        'id',
        'script_introduce',
        'jmeter_script',
        'sample_number',
        'duration',
        'run_sum',
        'create_time',
        'update_time',
        'download_button',
        'update_button',
        'delete_button',
    ]
    ordering = ("id", )
    search_fields = ("script_introduce", )
    list_filter = ["script_introduce", "create_time"]
    show_detail_fields = ['script_introduce']
    list_display_links = ('id', 'script_introduce')
    list_editable = ['script_introduce']
    list_per_page = 10

    batch_fields = (
        'script_introduce',
        'sample_number',
        'duration',
    )
    # 可批量修改的字段
    actions = [CopyAction, BatchChangeAction]
Ejemplo n.º 25
0
class InterfaceInfoAdmin(object):
    model = InterfaceInfo
    extra = 1
    # 提供1个足够的选项行,也可以提供N个
    style = "accordion"

    # 折叠

    def update_button(self, obj):
        # 修改按钮
        button_html = '<a class="icon fa fa-edit" style="color: green" href="/admin/interface/interfaceinfo/%s/update/">修改</a>' % obj.id
        return format_html(button_html)

    update_button.short_description = '<span style="color: green">修改</span>'
    update_button.allow_tags = True

    def delete_button(self, obj):
        # 删除按钮
        button_html = '<a class="icon fa fa-times" style="color: blue" href="/admin/interface/interfaceinfo/%s/delete/">删除</a>' % obj.id
        return format_html(button_html)

    delete_button.short_description = '<span style="color: blue">删除</span>'
    delete_button.allow_tags = True

    form_layout = (
        Main(
            Fieldset('用例信息部分', 'case_group', 'case_name'),
            Fieldset('接口信息部分', 'interface_url', 'request_mode',
                     'request_parameter', 'request_head', 'body_type',
                     'request_body', 'expected_result', 'response_assert',
                     'wait_time'),
            Fieldset('正则表达式提取器', 'regular_expression', 'regular_variable',
                     'regular_template'),
        ),
        Side(
            # Fieldset('响应信息部分',
            #          'response_code', 'actual_result', 'pass_status'),
            # Fieldset('时间部分',
            #          'create_time', 'update_time'),
        ))
    # 详情页面字段分区,请注意不是fieldsets

    list_display = [
        'id',
        'case_group',
        'case_name',
        'interface_url',
        'request_mode',
        'request_parameter',
        'request_head',
        'body_type',
        'request_body',
        'expected_result',
        'response_assert',
        'wait_time',
        'regular_expression',
        'regular_variable',
        'regular_template',
        'response_code',
        'actual_result',
        'pass_status',
        'create_time',
        'update_time',
        'update_button',
        'delete_button',
    ]

    ordering = ("id", )
    search_fields = ("case_name", )
    list_filter = ["pass_status", "create_time"]
    list_display_links = ('id', 'case_group', 'case_name')
    show_detail_fields = ['case_name']
    list_editable = ['case_name']
    readonly_fields = ['response_code', 'actual_result', 'pass_status']
    raw_id_fields = ('case_group', )
    list_per_page = 10

    batch_fields = (
        'case_name',
        'interface_url',
        'request_mode',
        'request_parameter',
        'request_head',
        'body_type',
        'request_body',
        'expected_result',
        'response_assert',
        'wait_time',
        'regular_expression',
        'regular_variable',
        'regular_template',
    )
    # 可批量修改的字段
    actions = [CopyAction, BatchChangeAction]
Ejemplo n.º 26
0
 Main(
     Fieldset(_('个人信息'),
              'mar_number',
              'mar_name',
              'mar_gender',
              'mar_id_number',
              'mar_loc',
              'mar_class',
              'mar_type',
              'mar_group'
              ),
     Fieldset(_('学历和专业'),
              'mar_deg',
              'mar_major',
              ),
     Fieldset(_('工作信息'),
              'mar_company',
              'mar_duty',
              'mar_status',
              'mar_origin',
              ),
     Fieldset(_('联系方式'),
              'mar_cellphone',
              'mar_wechat',
              'mar_email',
              ),
     Fieldset(_('报名信息'),
              'mar_signup_date',
              'mar_signup_people',
             #  'mar_teacher_level',
              )
 ),
Ejemplo n.º 27
0
 Main(
     Fieldset(_('个人信息'),
              'stu_type',
              'stu_group',
              'stu_number',
              'stu_name',
              'stu_gender',
              'stu_id_number',
              'stu_loc',
              'stu_class',
              'stu_level'
              ),
     Fieldset(_('学历和专业'),
              'stu_deg',
              'stu_major',
              ),
     Fieldset(_('工作信息'),
              'stu_company',
              'stu_duty',
              'stu_status',
              'stu_origin',
              ),
     Fieldset(_('联系方式'),
              'stu_cellphone',
              'stu_wechat',
              'stu_qq',
              ),
     Fieldset(_('报名信息'),
              'stu_signup_date',
              'stu_signup_people',
              )
 ),
Ejemplo n.º 28
0
class ProductInfoAdmin(object):
    inlines = [ModuleInfoAdmin]

    # 使用内联显示

    def update_button(self, obj):
        # 修改按钮
        button_html = '<a class="icon fa fa-edit" style="color: green" href="/admin/interface/productinfo/%s/update/">修改</a>' % obj.id
        return format_html(button_html)

    update_button.short_description = '<span style="color: green">修改</span>'
    update_button.allow_tags = True

    def delete_button(self, obj):
        # 删除按钮
        button_html = '<a class="icon fa fa-times" style="color: blue" href="/admin/interface/productinfo/%s/delete/">删除</a>' % obj.id
        return format_html(button_html)

    delete_button.short_description = '<span style="color: blue">删除</span>'
    delete_button.allow_tags = True

    form_layout = (
        Main(
            Fieldset('产品信息部分', 'product_name', 'product_describe'),
            Fieldset('人员部分', 'product_manager', 'developer', 'tester'),
        ),
        # Side(
        #     Fieldset('时间部分',
        #              'create_time', 'update_time'),
        # )
    )
    # 详情页面字段分区

    list_display = [
        'id',
        'product_name',
        'product_describe',
        'product_manager',
        'developer',
        'tester',
        'module_sum',
        'create_time',
        'update_time',
        'update_button',
        'delete_button',
    ]

    ordering = ("id", )
    search_fields = ("product_name", )
    list_filter = ["product_manager", "create_time"]
    list_display_links = ('id', 'product_name')
    show_detail_fields = ['product_name']
    list_editable = ['product_name']
    list_per_page = 10

    import_export_args = {
        'import_resource_class': ProductInfoResource,
        # 'export_resource_class': ProductInfoResource,
    }
    # 列表页面,添加导入按钮
    list_export_fields = ('id', 'product_name', 'product_describe',
                          'product_manager', 'developer', 'tester',
                          'create_time')
    # 列表页面,导出的字段

    batch_fields = ('product_name', 'product_describe', 'product_manager',
                    'developer', 'tester')
    # 可批量修改的字段
    actions = [CopyAction, BatchChangeAction]
    # 列表页面,添加复制动作与批量修改动作

    list_bookmarks = [{
        "title": "产品书签",
        # 书签的名称
        "query": {
            "name": ""
        },
        # 过滤参数
        "order": ("-id", ),
        # 排序
        "cols": ("product_name", "product_describe"),
        # 显示的列
        "search": "产品"
        # 搜索参数
    }]