Пример #1
0
 def get_form_layout(self):
     if self.org_obj:
         self.form_layout = (
             Main(
                 Fieldset(
                     '用户信息',
                     'username',
                     'password',
                     'email',
                     'sex',
                     'realname',
                     #css_class='unsort no_title'
                 ),
                 Fieldset(
                     '权限和组',
                     'groups',
                     'user_permissions',
                 ),
             ),
             Side(
                 Fieldset(
                     '用户状态',
                     'is_active',
                     'is_staff',
                     'is_superuser',
                 ), Fieldset('时间', 'joined_at', 'last_login')))
     else:
         self.form_layout = (
             Main(
                 Fieldset(
                     '用户信息',
                     'username',
                     'password1',
                     'password2',
                     'email',
                     'sex',
                     'realname',
                     #css_class='unsort no_title'
                 ),
                 Fieldset(
                     '权限和组',
                     'groups',
                     'user_permissions',
                 ),
             ),
             Side(
                 Fieldset(
                     '用户状态',
                     'is_active',
                     'is_staff',
                     'is_superuser',
                 ), Fieldset('时间', 'joined_at', 'last_login')))
     return super(UserAdmin, self).get_form_layout()
Пример #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', 'notice', 'youneed_know', 'teacher_tell', 'detail',
                             Row('learn_times', 'degree'),
                             Row('category', 'tag'),
                             ),
                    ),
                Side(  # 右侧小框显示
                    Fieldset('访问信息',
                            'click_nums', 'students', 'fav_nums'
                             ),

                    Fieldset('是否选择',
                                'is_banner', 'is_classics'
                            ),
                    ),
            )
        return super(NewCourseAdmin, self).get_form_layout()
Пример #3
0
class UserProfileAdmin(object):
    list_display = ('username', 'email', 'is_staff', 'mobile', 'number',
                    'gender', 'birthday')
    search_fields = ('number', 'email', 'username', 'mobile')
    list_filter = ('is_staff', )
    model_icon = 'fa fa-user-o'
    readonly_fields = ('follow_nums', 'fan_nums', 'upload_nums', 'like_nums',
                       'collection_nums', 'download_nums', 'add_time',
                       'password')
    relfield_style = 'fk-ajax'
    form_layout = (Main(
        Fieldset('', 'username', 'password', css_class='unsort no_title'),
        Fieldset(
            '关键信息',
            Row('real_name', 'p_class'),
            Row('email', 'mobile'),
            Row('qq', 'id_card'),
        ),
        Fieldset('权限', 'groups', 'user_permissions'),
        Fieldset('日期', 'last_login', 'date_joined'),
    ),
                   Side(
                       Fieldset('状态', 'is_active', 'is_staff', 'is_superuser',
                                'if_sign'), ))

    def get_readonly_fields(self):
        if self.user.is_superuser:
            self.readonly_fields = []
        return self.readonly_fields
Пример #4
0
class RecruitmentAdmin(RichTextAdmin):
    list_display = ('title_cn', )
    form_layout = (Main(
        Fieldset('中文信息', 'title_cn', 'content_cn'),
        Fieldset('英文信息', 'title_en', 'content_en'),
        Fieldset('文件上传 (上传较大文件时需要等待一段时间)', 'file1', 'file2', 'file3', 'file4',
                 'file5')))
Пример #5
0
class PerformerAdmin(RichTextAdmin):
    list_display = ('name_cn', 'name_en', 'instrument_type')
    list_filter = ('instrument_type', )
    form_layout = (Main(
        Fieldset('头像', 'img'),
        Fieldset('中文信息', 'name_cn', 'detail_cn', 'instrument_type'),
        Fieldset('英文信息', 'name_en', 'detail_en')))
Пример #6
0
class YueTuanIntroAdmin(RichTextAdmin):
    form_layout = (
        Main(
            Fieldset('中文介绍', 'content_cn'),
            # Fieldset('中文介绍', 'content_cn', style='width:134.5%;'),
            Fieldset('英文介绍', 'content_en'),
        ), )
Пример #7
0
class MusicFestivalAdmin(RichTextAdmin):
    list_display = ('title_cn', 'title_en', 'publish_time')
    form_layout = (Main(
        Fieldset('图片与日期', 'img', 'publish_time'),
        Fieldset('中文信息', 'title_cn', 'content_cn'),
        Fieldset('英文信息', 'title_en', 'content_en'),
        Fieldset('视频简介', 'video', 'video_desc_cn', 'video_desc_en')), )
Пример #8
0
class AuthorBlogAdmin(CommonSetting):
    exclude = ('id', 'author')
    list_display = ('title', 'cat', 'is_active', 'original', 'tags', 'read',
                    'like', 'url')
    search_fields = ('title', )
    list_filter = ('add', 'mod')
    readonly_fields = ('read', 'like', 'add', 'mod', 'is_active', 'is_top',
                       'is_fine', "apply_active", "apply_top", "apply_fine")
    form_layout = (Main(
        Fieldset(_('基本信息'), Row('title', 'cat'), Row('cover', 'tags'),
                 Row('music')),
        Fieldset(_('标记信息'), Row('apply_active', ), Row('apply_top', ),
                 Row('apply_fine')),
        Fieldset(
            _('正文'),
            Row('source'),
            Row('content'),
        ),
        Fieldset(
            _('统计信息'),
            Row('read', 'like'),
            Row('add', 'mod'),
        ),
    ), Side(Fieldset(_('状态'), 'is_active', 'is_top', 'is_fine')))

    def queryset(self):
        q = super().queryset()
        return q.filter(author_id=self.request.user.id)

    def save_models(self):
        """
        01.保存数据到数据库中时提取作者为当前用户
        02.修复代码块bug
        """
        if (not hasattr(self.new_obj, 'author')) or (not self.new_obj.author):
            self.new_obj.author = self.request.user
        self.new_obj.save()

    def has_add_permission(self):
        # 写文章的权限
        if self.request.user.is_superuser:
            return True
        return self.request.user.is_active

    def has_delete_permission(self, obj=None):
        # 删除权限
        if obj is not None:
            if self.request.user.is_superuser:
                return True
            if self.request.user.id == obj.author.id:
                return True
        return False

    def has_change_permission(self, obj=None):
        if obj is not None:
            if self.request.user.is_superuser:
                return True
            if self.request.user.id == obj.author.id:
                return True
        return False
Пример #9
0
class WrokOrdersAdmin(object):
    list_display = ['org_user', 'pro_type','pro_date','is_finish']
    search_fields = []
    readonly_fields = ['creator']
    list_filter =  ['creator','is_finish','is_key_work','create_time','modified_time']
    exclude = ['org_dept']
    reversion_enable = True
    form_layout = (
        Main(
            Fieldset('',
                     Row('creator','org_user'),
                     Row('pro_type', 'pro_date'),
                     Row('pro_desc'),
                     Row('solver', 'solve_len_time'),
                     Row('solve_desc'),
                     ),
        ),
        Side(
            Fieldset(('Status'),
                     'is_finish','is_key_work',
                     ),
        )
    )
    def save_models(self):
        obj = self.new_obj
        request = self.request
        obj.creator = str(request.user.username)
        obj.save()
Пример #10
0
    def get_form_layout(self):
        if self.org_obj:
            self.form_layout = (
                Main(
                    Fieldset(_('基本信息'),
                             'company_name', 'company_type', 'url', 'city', 'keyword',
                             ),
                    Fieldset(_('联系方式'),
                             'qq', 'wechat', 'phone', 'address',
                             ),
                    Fieldset(_('意向信息'),
                             'sem_status', 'aike_status',
                             ),
                    Fieldset(_('签单信息'),
                             'depart', 'sales', 'amount', 'business',
                             ),
                    Fieldset(_('时间信息'),
                             'create_time', 'update_time',
                             ),
                ),
                Side(

                )
            )
        return super(addUpByDepartAdmin, self).get_form_layout()
Пример #11
0
class smartpipeAdmin(object):
    list_display = [
        'caliber',
        'name',
        'sn',
        'label',
        'vendor_id']
    search_fields = [
        'caliber',
        'sn',
        'label',
        'vendor_id']
    list_filter = [
        'caliber',
        'sn',
        'label',
        'vendor_id']
    model_icon = 'fa fa-map'
    form_layout = (
        Main(
            Fieldset('1、基本属性',
                     'name', Row('caliber', 'sn'), Row('label', 'vendor_id')),
            Fieldset('4、安装信息',
                     'project_id', 'depth', 'install_date', 'interface', 'pipeline', 'longitude', 'latitude'),
        )
        # Side(
        #     Fieldset('其它',
        #              'buy_date', 'expire_date', 'note', 'attachment', 'date'),
        # )
    )
Пример #12
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","tag"),

                ),
            ),
            Side(
                Fieldset("访问信息",
                    Row("students","fav_num","click_num")
                ),
                Fieldset("课程信息",
                    "youneed_know","teacher_tell","is_classics"
                )
            ),
            Side(
                Fieldset("封面信息",
                        "image", "notice", "is_banner","is_index"
                         )
            )
        )
        return super(CourseAdmin, self).get_form_layout()
Пример #13
0
class CommunityAdmin(object):
    hidden_menu = True

    list_display = ("community_name", "group", "responsibility",
                    "date_created")

    form_layout = (Main(
        Tab(
            "用户组",
            Inline(GroupInline),
            Fieldset(
                "用户权限组",
                "group",
                description="针对操作管线的用户管理组进行责任划分。",
            ),
        ), ),
                   Side(
                       Tab(
                           "责任",
                           Fieldset(
                               "责任管理",
                               "community_name",
                               "responsibility",
                               description="针对系统部件创建策略, 设置生效与否",
                           ),
                       ), ))
Пример #14
0
 def get_form_layout(self):
     if self.org_obj:
         self.form_layout = (
             Main(
                 Fieldset('',
                          'username', 'password',
                          css_class='unsort no_title'
                          ),
                 Fieldset('个人信息',
                          Row('first_name', 'last_name'),
                          'email'
                          ),
                 # Fieldset('Permissions',
                 #          'groups', 'user_permissions'
                 #          ),
                 Fieldset('时间信息',
                          'last_login', 'date_joined'
                          ),
             ),
             Side(
                 Fieldset('Status',
                          'is_active', 'is_staff', 'is_superuser',
                          ),
             )
         )
     return super(UserProfilesAdmin, self).get_form_layout()
Пример #15
0
 def get_form_layout(self):
     if self.org_obj:
         self.form_layout = (Main(
             Fieldset(
                 _('Personal info'),
                 Row('email'),
                 Row('password'),
             ),
             Fieldset(
                 '作者信息',
                 Row('username', 'header'),
                 Row('desc'),
                 Row('alipay', 'wechat'),
             ),
             Fieldset(
                 "统计信息",
                 Row('last_login', 'date_joined', "published", "to_publish",
                     "read", "like")),
         ),
                             Side(
                                 Fieldset(
                                     _('Status'),
                                     'is_active',
                                     'is_staff',
                                     'is_superuser',
                                 ), ))
     return super(UserAdmin, self).get_form_layout()
Пример #16
0
class MusicaleAdmin(RichTextAdmin):
    list_display = ('title_cn', 'title_en', 'publish_time')
    form_layout = (Main(
        Fieldset('图片与日期', 'img', 'publish_time'),
        Fieldset('中文信息', 'title_cn', 'content_cn'),
        Fieldset('英文信息', 'title_en', 'content_en'),
    ), )
Пример #17
0
class BlogAdmin(CommonSetting):
    exclude = ('id', )
    list_display = ('title', "is_active", 'author', 'cat', 'original', 'read',
                    'like', 'url')
    search_fields = ('title', 'author__username', 'author__email')
    list_filter = ('is_active', 'add', 'mod')
    readonly_fields = ('read', 'like', 'add', 'mod')
    form_layout = (Main(
        Fieldset(_('基本信息'), Row('title', 'cat', 'author'),
                 Row('cover', 'tags'), Row('music')),
        Fieldset(
            _('正文'),
            Row('source'),
            Row('content'),
        ),
        Fieldset(
            _('统计信息'),
            Row('read', 'like'),
            Row('add', 'mod'),
        ),
    ), Side(Fieldset(_('状态'), 'is_active', 'is_top', 'is_fine'), ))

    def save_models(self):
        """
        保存数据到数据库中时提取作者为当前用户
        """
        if (not hasattr(self.new_obj, 'author')) or (not self.new_obj.author):
            self.new_obj.author = self.request.user
        self.new_obj.save()
Пример #18
0
 def get_form_layout(self):
     if self.org_obj:
         self.form_layout = (Main(
             Fieldset(
                 _('Personal info'),
                 Row('email'),
                 Row('password'),
             ),
             Fieldset(
                 '作者信息',
                 Row('username', 'header'),
                 Row('desc'),
                 Row('alipay', 'wechat'),
             ),
             Fieldset(_('Permissions'), 'groups', 'user_permissions'),
             Fieldset(_('Important dates'), Row('last_login',
                                                'date_joined')),
         ),
                             Side(
                                 Fieldset(
                                     _('Status'),
                                     'is_active',
                                     'is_staff',
                                     'is_superuser',
                                 ), ))
     return super(UserAdmin, self).get_form_layout()
Пример #19
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()
Пример #20
0
class MemberAdmin(object):
    import_export_args = {'import_resource_class': MemberResource}

    fields = [field.name for field in Member._meta.fields]
    list_display = fields[1:8]
    search_fields = ['name']
    list_filter = ['name']
    model_icon = 'fa fa-info'
    list_per_page = 15
    list_editable = list_display[1:]

    phases = dict()
    phases['基本信息'] = fields[:8]
    phases['阶段1:入党考察'] = fields[8:17]
    phases['阶段2:预备党员'] = fields[17:26]
    phases['阶段3:正式党员'] = fields[26:]
    wizard_form_list = phases.items()
    form_layout = (Main(*[Fieldset(k, *v) for k, v in wizard_form_list]))

    def get_readonly_fields(self):
        if not self.request.user.has_perm('info.add_member'):  # 普通成员
            return ['branch_name', 'netid'] + self.fields[8:]
        return []

    def queryset(self):
        if not self.request.user.is_superuser:  # 判断是否是超级用户
            try:
                member = Member.objects.get(netid=self.request.user)
                if self.request.user.has_perm('info.add_member'):  # 支书
                    return self.model.objects.filter(branch=member.branch)
                return self.model.objects.filter(netid=member.netid,
                                                 branch=member.branch)  # 普通成员
            except:
                return self.model.objects.filter(netid="")
        return self.model.objects.all()
Пример #21
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()
Пример #22
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', 'describe',
                      Row('learn_time', 'degree'),
                      Row('category', 'tag'),
                      ),
         ),
         Side(
             Fieldset('情况',
                      'students', 'fav_nums', 'click_nums',
                      ),
         ),
         Side(
             Fieldset('选择',
                     'is_class', 'is_banner',
                     ),
         )
     )
     return super(NewCouseAdmin, self).get_form_layout()
Пример #23
0
    def get_form_layout(self):

        self.form_layout = (
            Main(
                Fieldset('基础信息', 'Gmodel',
                         Row('price', 'min_price')
                         # css_class='unsort no_title'
                         ),
                Fieldset(
                    '备注信息',
                    "meno",
                ),
            ),
            # Side(
            #     Fieldset(_('Status'),
            #              'is_active', 'is_staff', 'is_superuser',
            #              ),
            # )
            Side(
                '选择项目',
                'brand',
                'supplier',
                'type',
                'unit',
            ),
        )

        return super(GoodsAdmin, self).get_form_layout()
Пример #24
0
 def get_form_layout(self):
     """自定义后台字段顺序"""
     if self.org_obj:
         from xadmin.layout import Main
         from xadmin.layout import Fieldset
         from django.utils.translation import ugettext as _
         from xadmin.layout import Row
         from xadmin.layout import Side
         self.form_layout = (
             Main(
                 Fieldset('',
                          'username', 'password',
                          css_class='unsort no_title'
                          ),
                 Fieldset(_('Personal info'),
                          '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',
                          ),
             )
         )
     # 调用UserAdmin中的Mro父集方法
     return super(UserAdmin, self).get_form_layout()
Пример #25
0
 def get_form_layout(self):
     self.form_layout = (Main(
         Fieldset('讲师信息',
                  'teacher',
                  'course_org',
                  css_class='unsort no_title'),
         Fieldset(
             '基本信息',
             'name',
             'desc',
             Row('degree', 'learn_times'),
             Row('category', 'tags'),
             'notice',
             'teacher_tell',
             'detail',
         ),
     ),
                         Side(
                             Fieldset(
                                 '访问信息',
                                 'fav_nums',
                                 'click_nums',
                                 'students',
                                 'add_time',
                             ), ),
                         Side(
                             Fieldset(
                                 '选择信息',
                                 'is_banner',
                                 'is_classics',
                             ), ))
     return super(CoursesAdmin, self).get_form_layout()
Пример #26
0
    def get_form_layout(self):
        if self.org_obj:
            # 只有在修改页面才变
            self.form_layout = (
                Main(
                    # Fieldset表示一块
                    Fieldset('讲师信息',
                             'teacher', 'course_org',
                             css_class='unsort no_title'
                             ),
                    Fieldset('基本信息'),
                    'name', 'desc',
                    Row('learn_times', 'degree'),
                    Row('category', 'tag'),
                    'you_need_know', 'teacher_tell', 'detail',
                ),

                # Side(
                #     # 右侧的信息
                #     Fieldset('访问信息'),
                #     'fav_nums', 'click_nums', 'students', 'add_times'
                # ),
                Side(
                    # 右侧的信息
                    Fieldset('选择信息'),
                    'is_classics', 'is_banner', 'image'
                ),
            )
        return super(NewCourseAdmin, self).get_form_layout()
Пример #27
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('level', 'credit'),
                          Row('sex', 'email'),
                          Row('phone', ),
                          'address',
                          'signature',
                          ),
                 Fieldset(_('Important dates'),
                          'last_login', 'date_joined'
                          ),
             ),
             Side(
                 Fieldset(_('Status'),
                          'is_active', 'is_staff', 'is_superuser',
                          ),
             )
         )
     return super(UserAdmin, self).get_form_layout()
Пример #28
0
class ImageModelAdmin(object):
    list_display = ('name', 'url', 'if_active', 'cates', 'pattern', 'i_desc', 'add_time')
    search_fields = ('name', 'desc', 'pattern')
    list_filter = ('user', 'name', 'if_active', 'desc', 'pattern', 'cates', 'add_time')
    readonly_fields = ('add_time',)
    model_icon = 'fa fa-file-image-o'
    refresh_times = (5, 10)
    relfield_style = 'fk-ajax'

    form_layout = (
        Main(
            Fieldset('',
                     'name', 'image', 'user', 'pattern', 'desc', 'cates',
                     css_class='unsort no_title'
                     ),
        ),
        Side(
            Fieldset('状态',
                     'if_active'
                     ),
        )
    )

    def get_readonly_fields(self):
        if self.user.is_superuser:
            self.readonly_fields = []
        return self.readonly_fields
Пример #29
0
class NewNewsBaseClass(object):
    list_filter = ['time', 'source']
    list_editable = ['priority', 'hidden', 'source']
    # 每页显示的数量
    list_per_page = 30

    # 显示缩略图
    def img_data(self, obj):
        if obj.img and hasattr(obj.img, 'url'):
            if 'http' in obj.img.url:
                return format_html(
                    '<img src="{0}" width="150px" height="150px"/>'.format(
                        obj.img))
            else:
                return format_html(
                    '<img src="{0}" width="150px" height="150px"/>'.format(
                        obj.img.url))
        else:
            return '无'

    img_data.short_description = '新闻图片'

    # 显示的字段
    list_display = [
        'title', 'img_data', 'go_to', 'time', 'source', 'priority', 'hidden'
    ]

    list_display_links = ['title', 'source', "time"]

    # 设置空值
    empty_value_display = '无'
    # 操作选项
    actions_on_top = True
    # 还原按钮,删除的信息可以还原
    reversion_enable = True
    # 搜索器
    search_fields = ['title', 'content']
    # 设置外键位搜索格式
    relfield_style = 'fk_ajax'
    # 跳转字段
    ordering = ('-time', )

    def del_imgs(self, request, queryset):
        queryset.update(img=None)
        messages.success(request, "删除图片成功")

    del_imgs.short_description = "删除图片"
    actions = [del_imgs]
    #内部排版
    form_layout = (Main(
        Fieldset('基本信息', 'title', 'img', 'priority', 'time', 'label', 'source',
                 'author', 'hidden'),
        Fieldset(
            '新闻内容',
            'content',
        ),
    ), Side(Fieldset('其它', 'url', 'comment', 'like', 'keywords'), ))
    readonly_fields = ('comment', 'like', 'keywords')
    exclude = ['url']
Пример #30
0
class NoticeAdmin(CommonSetting):
    list_display = ('title', 'is_active', 'add', 'url')
    search_fields = ('title', )
    list_filter = ('add', 'mod', 'is_active')
    readonly_fields = ('add', 'mod')
    form_layout = (Main(
        Fieldset(_('公告信息'), Row('title'), Row('add', 'mod'),
                 Row('content')), ), Side(Fieldset(_('状态'), 'is_active')))