forked from jly8866/archer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
提交工单支持上传sql文件 优化工单检测结果展示,提交时做二次确认 调整js加载,每个页面只加载所需的js文件
- Loading branch information
Showing
25 changed files
with
1,195 additions
and
579 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# -*- coding: UTF-8 -*- | ||
import json | ||
from django.shortcuts import render | ||
from django.http import HttpResponse | ||
from .models import users | ||
|
||
|
||
# 管理员操作权限验证 | ||
def superuser_required(func): | ||
def wrapper(request, *args, **kw): | ||
# 获取用户信息,权限验证 | ||
loginUser = request.session.get('login_username', False) | ||
loginUserOb = users.objects.get(username=loginUser) | ||
|
||
if loginUserOb.is_superuser is False: | ||
if request.is_ajax(): | ||
finalResult = {'status': 1, 'msg': '您无权操作,请联系管理员', 'data': []} | ||
return HttpResponse(json.dumps(finalResult), content_type='application/json') | ||
else: | ||
context = {'errMsg': "您无权操作,请联系管理员"} | ||
return render(request, "error.html", context) | ||
|
||
return func(request, *args, **kw) | ||
|
||
return wrapper | ||
|
||
|
||
# 角色操作权限验证 | ||
def role_required(roles=()): | ||
def _deco(func): | ||
def wrapper(request, *args, **kw): | ||
# 获取用户信息,权限验证 | ||
loginUser = request.session.get('login_username', False) | ||
loginUserOb = users.objects.get(username=loginUser) | ||
loginrole = loginUserOb.role | ||
|
||
if loginrole not in roles and loginUserOb.is_superuser is False: | ||
if request.is_ajax(): | ||
finalResult = {'status': 1, 'msg': '您无权操作,请联系管理员', 'data': []} | ||
return HttpResponse(json.dumps(finalResult), content_type='application/json') | ||
else: | ||
context = {'errMsg': "您无权操作,请联系管理员"} | ||
return render(request, "error.html", context) | ||
|
||
return func(request, *args, **kw) | ||
|
||
return wrapper | ||
|
||
return _deco |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.