Beispiel #1
0
 def handle(self, *args, **options):
     topmenu = Menu.objects.get(name='top', code='top')
     self.stdout.write(
         self.style.SUCCESS('############ 初始化通知菜单 ###########'))
     noticemenu = Menu.objects.create(name='通知管理',
                                      code='notice',
                                      curl='/notice',
                                      icon='notice',
                                      sequence=5,
                                      type=1,
                                      parent_id=topmenu.id)
     menumodel = Menu.objects.create(name='mail通知',
                                     code='mail',
                                     curl='/mail',
                                     icon='mail',
                                     sequence=10,
                                     type=2,
                                     parent_id=noticemenu.id)
     init_menu(menumodel)
     menumodel = Menu.objects.create(name='telegram通知',
                                     code='telegram',
                                     curl='/telegram',
                                     icon='telegram',
                                     sequence=20,
                                     type=2,
                                     parent_id=noticemenu.id)
     init_menu(menumodel)
     self.stdout.write(self.style.SUCCESS('初始化完成'))
Beispiel #2
0
 def handle(self, *args, **options):
     topmenu = Menu.objects.get(name='top', code='top')
     self.stdout.write(
         self.style.SUCCESS('############ 初始化cmdb菜单 ###########'))
     basemenu = Menu.objects.create(name='资产管理',
                                    code='cmdb',
                                    curl='/cmdb',
                                    icon='cmdb',
                                    sequence=5,
                                    type=1,
                                    parent=topmenu)
     menumodel = Menu.objects.create(name='机房',
                                     code='idc',
                                     curl='/idc',
                                     icon='idc',
                                     sequence=10,
                                     type=2,
                                     parent=basemenu)
     init_menu(menumodel)
     menumodel = Menu.objects.create(name='主机组',
                                     code='hostgroup',
                                     curl='/hostgroup',
                                     icon='hostgroup',
                                     sequence=20,
                                     type=2,
                                     parent=basemenu)
     init_menu(menumodel)
     menumodel = Menu.objects.create(name='主机',
                                     code='host',
                                     curl='/host',
                                     icon='host',
                                     sequence=30,
                                     type=2,
                                     parent=basemenu)
     init_menu(menumodel)
     menumodel = Menu.objects.create(name='执行命令',
                                     code='shell',
                                     curl='/shell',
                                     icon='shell',
                                     sequence=40,
                                     type=2,
                                     parent=basemenu)
     init_menu(menumodel)
     self.stdout.write(self.style.SUCCESS('初始化完成'))
Beispiel #3
0
 def handle(self, *args, **options):
     topmenu = Menu.objects.get(name='top', code='top')
     self.stdout.write(self.style.SUCCESS('############ 初始化工作流菜单 ###########'))
     workflowmenu = Menu.objects.create(name='工作流', code='workflow', curl='/workflow', icon='workflow', sequence=3, type=1, parent=topmenu)
     menumodel = Menu.objects.create(name='工作流类型', code='wftype', curl='/wftype', icon='wftype', sequence=10, type=2, parent=workflowmenu)
     init_menu(menumodel)
     menumodel = Menu.objects.create(name='工作流设计', code='wfset', curl='/wfset', icon='wfset', sequence=20, type=2, parent=workflowmenu)
     init_menu(menumodel)
     menumodel = Menu.objects.create(name='工作流配置', code='wfconf', curl='/wfconf/:id', icon='wfconf', sequence=30, type=2, hidden=True, active_menu='/wfset', parent=workflowmenu)
     init_menu(menumodel)
     self.stdout.write(self.style.SUCCESS('初始化完成'))
Beispiel #4
0
 def handle(self, *args, **options):
     topmenu = Menu.objects.get(name='top', code='top')
     self.stdout.write(
         self.style.SUCCESS('############ 初始化任务菜单 ###########'))
     celerymenu = Menu.objects.create(name='任务管理',
                                      code='celery_task',
                                      curl='/celery_task',
                                      icon='celery_task',
                                      sequence=4,
                                      type=1,
                                      parent_id=topmenu.id)
     menumodel = Menu.objects.create(name='cron配置',
                                     code='crontab',
                                     curl='/crontab',
                                     icon='crontab',
                                     sequence=10,
                                     type=2,
                                     parent_id=celerymenu.id)
     init_menu(menumodel)
     menumodel = Menu.objects.create(name='任务脚本',
                                     code='taskscript',
                                     curl='/taskscript',
                                     icon='taskscript',
                                     sequence=20,
                                     type=2,
                                     parent_id=celerymenu.id)
     init_menu(menumodel)
     menumodel = Menu.objects.create(name='任务',
                                     code='task',
                                     curl='/task',
                                     icon='task',
                                     sequence=30,
                                     type=2,
                                     parent_id=celerymenu.id)
     init_menu(menumodel)
     menumodel = Menu.objects.create(name='任务结果',
                                     code='taskresult',
                                     curl='/taskresult',
                                     icon='taskresult',
                                     sequence=40,
                                     type=2,
                                     parent_id=celerymenu.id)
     init_menu(menumodel)
     self.stdout.write(self.style.SUCCESS('初始化完成'))
Beispiel #5
0
 def handle(self, *args, **options):
     topmenu = Menu.objects.get(name='top', code='top')
     self.stdout.write(
         self.style.SUCCESS('############ 初始化聊天菜单 ###########'))
     basemenu = Menu.objects.create(name='聊天管理',
                                    code='chat',
                                    curl='/chat',
                                    icon='chat',
                                    sequence=4,
                                    type=1,
                                    parent=topmenu)
     menumodel = Menu.objects.create(name='群组管理',
                                     code='chatgroup',
                                     curl='/chatgroup',
                                     icon='group',
                                     sequence=10,
                                     type=2,
                                     parent=basemenu)
     init_menu(menumodel)
     menumodel = Menu.objects.create(name='消息管理',
                                     code='chatmessage',
                                     curl='/chatmessage',
                                     icon='message',
                                     sequence=20,
                                     type=2,
                                     parent=basemenu)
     init_menu(menumodel)
     menumodel = Menu.objects.create(name='聊天室',
                                     code='chatroom',
                                     curl='/chatroom',
                                     icon='chatroom',
                                     sequence=30,
                                     type=2,
                                     parent=basemenu)
     init_menu(menumodel)
     self.stdout.write(self.style.SUCCESS('初始化完成'))
Beispiel #6
0
 def create(self, validated_data):
     obj = Menu.objects.create(**validated_data)
     if obj.type == 2:
         init_menu(obj)
     return obj
Beispiel #7
0
    def handle(self, *args, **options):
        try:
            self.stdout.write(
                self.style.SUCCESS('############ 初始化角色 ###########'))
            role = Role.objects.create(name='top',
                                       code='top',
                                       sequence=0,
                                       parent=None)
        except Exception as e:
            print(e)
            raise CommandError('初始化角色失败')

        try:
            self.stdout.write(
                self.style.SUCCESS('############ 初始化用户组 ###########'))
            group = Group.objects.create(name='top',
                                         code='top',
                                         sequence=0,
                                         parent=None)
            group.roles.add(role)
        except:
            raise CommandError('初始化用户组失败')

        try:
            self.stdout.write(
                self.style.SUCCESS('############ 初始化用户 ###########'))
            user = User.objects.create(username='******',
                                       password=make_password("123456"),
                                       group=group,
                                       is_admin=True)
            user.roles.add(role)
        except:
            raise CommandError('初始化用户失败')

        menus = Menu.objects.all()
        if len(menus) == 0:
            topmenu = Menu.objects.create(name='top',
                                          code='top',
                                          curl='/top',
                                          icon='top',
                                          sequence=0,
                                          type=1,
                                          parent=None)
            self.stdout.write(
                self.style.SUCCESS('############ 初始化系统菜单 ###########'))
            sysmenu = Menu.objects.create(name='系统管理',
                                          code='sys',
                                          curl='/sys',
                                          icon='sys',
                                          sequence=1,
                                          type=1,
                                          parent=topmenu)
            menumodel = Menu.objects.create(name='角色管理',
                                            code='role',
                                            curl='/role',
                                            icon='role',
                                            sequence=30,
                                            type=2,
                                            parent=sysmenu)
            init_menu(menumodel)
            menumodel = Menu.objects.create(name='分组管理',
                                            code='group',
                                            curl='/group',
                                            icon='group',
                                            sequence=10,
                                            type=2,
                                            parent=sysmenu)
            init_menu(menumodel)
            menumodel = Menu.objects.create(name='用户管理',
                                            code='user',
                                            curl='/user',
                                            icon='user',
                                            sequence=20,
                                            type=2,
                                            parent=sysmenu)
            init_menu(menumodel)
            menumodel = Menu.objects.create(name='菜单管理',
                                            code='menu',
                                            curl='/menu',
                                            icon='menu',
                                            sequence=40,
                                            type=2,
                                            parent=sysmenu)
            init_menu(menumodel)
            menumodel = Menu.objects.create(name='图标管理',
                                            code='icon',
                                            curl='/icon',
                                            icon='icon',
                                            sequence=50,
                                            type=2,
                                            parent=sysmenu)
            init_menu(menumodel)

            self.stdout.write(
                self.style.SUCCESS('############ 初始化工具菜单 ###########'))
            toolmenu = Menu.objects.create(name='工具管理',
                                           code='tool',
                                           curl='/tool',
                                           icon='tool',
                                           sequence=2,
                                           type=1,
                                           parent=topmenu)
            menumodel = Menu.objects.create(name='审计日志',
                                            code='audit',
                                            curl='/audit',
                                            icon='audit',
                                            sequence=10,
                                            type=2,
                                            parent=toolmenu)
            init_menu(menumodel)
            menumodel = Menu.objects.create(name='测试页面',
                                            code='test',
                                            curl='/test',
                                            icon='list',
                                            sequence=20,
                                            type=2,
                                            parent=toolmenu)
            init_menu(menumodel)

            self.stdout.write(
                self.style.SUCCESS('############ 初始化通知菜单 ###########'))
            noticemenu = Menu.objects.create(name='通知管理',
                                             code='notice',
                                             curl='/notice',
                                             icon='notice',
                                             sequence=3,
                                             type=1,
                                             parent=topmenu)
            menumodel = Menu.objects.create(name='邮箱通知',
                                            code='mail',
                                            curl='/mail',
                                            icon='mail',
                                            sequence=10,
                                            type=2,
                                            parent=noticemenu)
            init_menu(menumodel)
            menumodel = Menu.objects.create(name='telegram通知',
                                            code='telegram',
                                            curl='/telegram',
                                            icon='telegram',
                                            sequence=20,
                                            type=2,
                                            parent=noticemenu)
            init_menu(menumodel)

        self.stdout.write(self.style.SUCCESS('初始化完成'))
Beispiel #8
0
 def handle(self, *args, **options):
     topmenu = Menu.objects.get(name='top', code='top')
     self.stdout.write(
         self.style.SUCCESS('############ 初始化jenkins菜单 ###########'))
     basemenu = Menu.objects.create(name='jenkins任务',
                                    code='jenkins',
                                    curl='/jenkins',
                                    icon='jenkins',
                                    sequence=2,
                                    type=1,
                                    parent=topmenu)
     menumodel = Menu.objects.create(name='任务',
                                     code='task',
                                     curl='/task',
                                     icon='task',
                                     sequence=10,
                                     type=2,
                                     parent=basemenu)
     init_menu(menumodel)
     menumodel = Menu.objects.create(name='任务日志',
                                     code='tasklog',
                                     curl='/tasklog',
                                     icon='tasklog',
                                     sequence=20,
                                     type=2,
                                     parent=basemenu)
     init_menu(menumodel)
     Menu.objects.create(name='ping测试',
                         code='ping',
                         curl='/ping',
                         icon='ping',
                         sequence=30,
                         type=2,
                         hidden=True,
                         active_menu='/task',
                         parent=basemenu)
     Menu.objects.create(name='创建机器',
                         code='createvm',
                         curl='/createvm',
                         icon='createvm',
                         sequence=40,
                         type=2,
                         hidden=True,
                         active_menu='/task',
                         parent=basemenu)
     Menu.objects.create(name='初始化主机',
                         code='initvm',
                         curl='/initvm',
                         icon='initvm',
                         sequence=50,
                         type=2,
                         hidden=True,
                         active_menu='/task',
                         parent=basemenu)
     Menu.objects.create(name='下线主机',
                         code='destoryvm',
                         curl='/destoryvm',
                         icon='destoryvm',
                         sequence=60,
                         type=2,
                         hidden=True,
                         active_menu='/task',
                         parent=basemenu)
     self.stdout.write(self.style.SUCCESS('初始化完成'))
Beispiel #9
0
 def handle(self, *args, **options):
     topmenu = Menu.objects.get(name='top', code='top')
     self.stdout.write(self.style.SUCCESS('############ 初始化工单菜单 ###########'))
     ticketmenu = Menu.objects.create(name='工单系统', code='ticket', curl='/ticket', icon='ticket', sequence=4, type=1,
                                   parent_id=topmenu.id)
     menumodel = Menu.objects.create(name='新建工单', code='new_ticket', curl='/new_ticket', icon='new_ticket', sequence=10, type=2,
                                     parent_id=ticketmenu.id)
     init_menu(menumodel)
     menumodel = Menu.objects.create(name='编辑工单', code='u_ticket', curl='/u_ticket/:id', icon='u_ticket', sequence=10, type=2,
                                     hidden=True, active_menu='/new_ticket', parent_id=ticketmenu.id)
     init_menu(menumodel)
     menumodel = Menu.objects.create(name='处理工单', code='s_ticket', curl='/s_ticket/:id', icon='s_ticket', sequence=10, type=2,
                                     hidden=True, active_menu='/todo_ticket', parent_id=ticketmenu.id)
     init_menu(menumodel)
     menumodel = Menu.objects.create(name='我的工单', code='my_ticket', curl='/my_ticket', icon='my_ticket', sequence=30, type=2,
                                     no_cache=True, parent_id=ticketmenu.id)
     init_menu(menumodel)
     menumodel = Menu.objects.create(name='我的待办', code='todo_ticket', curl='/todo_ticket', icon='todo_ticket', sequence=40, type=2,
                                     no_cache=True, parent_id=ticketmenu.id)
     init_menu(menumodel)
     menumodel = Menu.objects.create(name='所有工单', code='all_ticket', curl='/all_ticket', icon='all_ticket', sequence=90, type=2,
                                     no_cache=True, parent_id=ticketmenu.id)
     init_menu(menumodel)
     self.stdout.write(self.style.SUCCESS('初始化完成'))