Esempio n. 1
0
    def post(self, request):
        ret = dict()
        title = request.POST.get("title")
        is_show = request.POST.get("is_show")
        is_sub = request.POST.get("is_sub", None)
        file_type = FileType()
        file_type.name = title
        id_list = []
        if is_show == "1":
            file_type.is_show = True
            file_type.is_part = False
        if is_show == "2":
            file_type.is_show = True
            file_type.is_part = True
            if 'part[]' in request.POST and request.POST['part[]']:
                id_list = request.POST.getlist('part[]', [])
        if is_sub == "1":
            file_type.is_sub = True
            file_type.parent_type_id = request.POST.get("parent")
        file_type.save()
        if len(id_list) != 0:
            for i in id_list:
                type_user = FileTypeUser()
                type_user.file_type_id = file_type.id
                type_user.user_id = i
                type_user.save()
        file_manage_menu = Menu.objects.filter(title="档案管理").first()
        menu = Menu()
        menu.title = title
        if is_sub == "1":
            menu.parent = Menu.objects.filter(
                title=file_type.parent_type.name).first()
        else:
            menu.parent = file_manage_menu
        menu.code = "FILE-LIST" + str(file_type.id)
        menu.url = "/adm/file_list/?type=" + str(file_type.id)
        menu.save()
        role = Role.objects.filter(title="能力:档案管理").first()
        role.permissions.add(menu.id)

        menu = Menu()
        file_menu = Menu.objects.filter(title="档案").first()
        menu.title = title + "-"
        if is_sub == "1":
            file_type_parent_name = file_type.parent_type.name + "-"
            menu.parent = Menu.objects.filter(
                title=file_type_parent_name).first()
        else:
            menu.parent = file_menu
        menu.code = "FILE-LIST" + str(file_type.id) + "-"
        menu.url = "/personal/file_show_list/?type=" + str(file_type.id)
        menu.save()
        role = Role.objects.filter(title="员工:基础功能").first()
        role.permissions.add(menu.id)
        ret["status"] = "success"
        return HttpResponse(json.dumps(ret, cls=DjangoJSONEncoder),
                            content_type="application/json")
Esempio n. 2
0
 from web.models import Customer, Payment   
 isname = User.objects.filter(username = '******')
 if isname:
     user = User.objects.get(username='******')
     user.set_password('admin')
     user.save()
 else:
     User.objects.create_superuser('admin', '*****@*****.**','admin')
 
 #print('===='+os.getcwd()) #当前目录
 
 # 菜单 初始化 *个菜单
 menulist = ['HOME','采购管理','财务管理','客户管理','信息管理','角色管理','用户管理','菜单管理','权限管理']
 for i in menulist:
     m = Menu()
     m.title = i
     m.save()
 
 # 权限 初始化 *个权限   
 perlistdict = [['HOME',['test','/bank/test/test/','test_test']],\
                ['HOME',['首页','/bank/index/','bank_index']],\
                ['',['帮助文档','/bank/help/(.+)','help']],\
                 ['',['上传文件','/bank/upload/','upload_word_tpl']],\
                 ['',['下载文件','/bank/download/','download_word_tpl']],\
                
                ['采购管理',['采购列表','/web/purchase/list/(.+)','purchase_list']],\
                ['',['添加采购','/web/purchase/add/','purchase_add']],\
                ['',['删除采购','/web/purchase/del/(?P<cid>\d+)/$','purchase_del']],\
                ['',['修改采购','/web/purchase/edit/(?P<cid>\d+)/$','purchase_edit']],\
                ['',['批量采购导入','/web/purchase/import/','purchase_import']],\
                ['',['下载采购模板','/web/purchase/tpl/','purchase_tpl']],\