'nowedit'
This commit is contained in:
commit
136e76775a
|
@ -39,7 +39,7 @@
|
||||||
<div class="icon">
|
<div class="icon">
|
||||||
<i class="fa fa-eye"></i>
|
<i class="fa fa-eye"></i>
|
||||||
</div>
|
</div>
|
||||||
<a href="#" class="small-box-footer">更多分析 <i class="fa fa-arrow-circle-right"></i></a>
|
<a href="{% url 'groups_observe' %}" class="small-box-footer">更多分析 <i class="fa fa-arrow-circle-right"></i></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- ./col -->
|
<!-- ./col -->
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
<div class="icon">
|
<div class="icon">
|
||||||
<i class="fa fa-life-ring"></i>
|
<i class="fa fa-life-ring"></i>
|
||||||
</div>
|
</div>
|
||||||
<a href="#" class="small-box-footer">更多分析 <i class="fa fa-arrow-circle-right"></i></a>
|
<a href="{% url 'groups_miss' %}" class="small-box-footer">更多分析 <i class="fa fa-arrow-circle-right"></i></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- ./col -->
|
<!-- ./col -->
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
<div class="icon">
|
<div class="icon">
|
||||||
<i class="fa fa-graduation-cap"></i>
|
<i class="fa fa-graduation-cap"></i>
|
||||||
</div>
|
</div>
|
||||||
<a href="#" class="small-box-footer">更多分析 <i class="fa fa-arrow-circle-right"></i></a>
|
<a href="{% url 'groups_train' %}" class="small-box-footer">更多分析 <i class="fa fa-arrow-circle-right"></i></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- ./col -->
|
<!-- ./col -->
|
||||||
|
@ -84,7 +84,7 @@
|
||||||
<div class="icon">
|
<div class="icon">
|
||||||
<i class="fa fa-industry"></i>
|
<i class="fa fa-industry"></i>
|
||||||
</div>
|
</div>
|
||||||
<a href="#" class="small-box-footer">更多分析 <i class="fa fa-arrow-circle-right"></i></a>
|
<a href="{% url 'groups_company' %}" class="small-box-footer">更多分析 <i class="fa fa-arrow-circle-right"></i></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-2 col-xs-6">
|
<div class="col-lg-2 col-xs-6">
|
||||||
|
|
|
@ -21,6 +21,7 @@ def check_login(func): # 自定义登录验证装饰器
|
||||||
return redirect('/groups/login')
|
return redirect('/groups/login')
|
||||||
return warpper
|
return warpper
|
||||||
|
|
||||||
|
|
||||||
def login(request):
|
def login(request):
|
||||||
# 不允许重复登录
|
# 不允许重复登录
|
||||||
if request.session.get('is_login', None):
|
if request.session.get('is_login', None):
|
||||||
|
|
|
@ -10,7 +10,7 @@ For the full list of settings and their values, see
|
||||||
https://docs.djangoproject.com/en/1.11/ref/settings/
|
https://docs.djangoproject.com/en/1.11/ref/settings/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os,time
|
||||||
import psycopg2.extensions
|
import psycopg2.extensions
|
||||||
|
|
||||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||||
|
@ -146,5 +146,82 @@ CELERY_ENABLE_UTC=True
|
||||||
|
|
||||||
##配置session
|
##配置session
|
||||||
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
|
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
|
||||||
|
SESSION_COOKIE_AGE = 1800
|
||||||
SESSION_SAVE_EVERY_REQUEST = True
|
SESSION_SAVE_EVERY_REQUEST = True
|
||||||
|
|
||||||
|
#日志配置
|
||||||
|
# 创建日志的路径
|
||||||
|
LOG_PATH = os.path.join(BASE_DIR, 'log')
|
||||||
|
# 如果地址不存在,则自动创建log文件夹
|
||||||
|
if not os.path.join(LOG_PATH):
|
||||||
|
os.mkdir(LOG_PATH)
|
||||||
|
LOGGING = {
|
||||||
|
'version': 1,
|
||||||
|
'disable_existing_loggers': True,
|
||||||
|
'formatters': {
|
||||||
|
# 日志格式
|
||||||
|
'standard': {
|
||||||
|
'format': '[%(asctime)s] [%(filename)s:%(lineno)d] [%(module)s:%(funcName)s] '
|
||||||
|
'[%(levelname)s]- %(message)s'},
|
||||||
|
'simple': { # 简单格式
|
||||||
|
'format': '%(levelname)s %(message)s'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
# 过滤
|
||||||
|
'filters': {
|
||||||
|
},
|
||||||
|
# 定义具体处理日志的方式
|
||||||
|
'handlers': {
|
||||||
|
# 默认记录所有日志
|
||||||
|
'default': {
|
||||||
|
'level': 'INFO',
|
||||||
|
'class': 'logging.handlers.RotatingFileHandler',
|
||||||
|
'filename': os.path.join(LOG_PATH, 'all-{}.log'.format(time.strftime('%Y-%m-%d'))),
|
||||||
|
'maxBytes': 1024 * 1024 * 5, # 文件大小
|
||||||
|
'backupCount': 5, # 备份数
|
||||||
|
'formatter': 'standard', # 输出格式
|
||||||
|
'encoding': 'utf-8', # 设置默认编码,否则打印出来汉字乱码
|
||||||
|
},
|
||||||
|
# 输出错误日志
|
||||||
|
'error': {
|
||||||
|
'level': 'ERROR',
|
||||||
|
'class': 'logging.handlers.RotatingFileHandler',
|
||||||
|
'filename': os.path.join(LOG_PATH, 'error-{}.log'.format(time.strftime('%Y-%m-%d'))),
|
||||||
|
'maxBytes': 1024 * 1024 * 5, # 文件大小
|
||||||
|
'backupCount': 5, # 备份数
|
||||||
|
'formatter': 'standard', # 输出格式
|
||||||
|
'encoding': 'utf-8', # 设置默认编码
|
||||||
|
},
|
||||||
|
# 控制台输出
|
||||||
|
'console': {
|
||||||
|
'level': 'DEBUG',
|
||||||
|
'class': 'logging.StreamHandler',
|
||||||
|
'formatter': 'standard'
|
||||||
|
},
|
||||||
|
# 输出info日志
|
||||||
|
'info': {
|
||||||
|
'level': 'INFO',
|
||||||
|
'class': 'logging.handlers.RotatingFileHandler',
|
||||||
|
'filename': os.path.join(LOG_PATH, 'info-{}.log'.format(time.strftime('%Y-%m-%d'))),
|
||||||
|
'maxBytes': 1024 * 1024 * 5,
|
||||||
|
'backupCount': 5,
|
||||||
|
'formatter': 'standard',
|
||||||
|
'encoding': 'utf-8', # 设置默认编码
|
||||||
|
},
|
||||||
|
},
|
||||||
|
# 配置用哪几种 handlers 来处理日志
|
||||||
|
'loggers': {
|
||||||
|
# 类型 为 django 处理所有类型的日志, 默认调用
|
||||||
|
'django': {
|
||||||
|
'handlers': ['default', 'console'],
|
||||||
|
'level': 'INFO',
|
||||||
|
'propagate': False
|
||||||
|
},
|
||||||
|
# log 调用时需要当作参数传入
|
||||||
|
'log': {
|
||||||
|
'handlers': ['error', 'info', 'console', 'default'],
|
||||||
|
'level': 'INFO',
|
||||||
|
'propagate': True
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
|
@ -101,15 +101,15 @@ canvas{
|
||||||
}
|
}
|
||||||
|
|
||||||
.login{z-index: 2;position:absolute;width: 350px;border-radius: 5px;height: 500px;box-shadow: 0px 0px 5px #333333;background:white;top: 50%;left: 50%;margin-top: -250px;margin-left: -175px;transition: all 1s;-moz-transition: all 1s; /* Firefox 4 */-webkit-transition: all 1s; /* Safari 和 Chrome */-o-transition: all 1s; /* Opera */}
|
.login{z-index: 2;position:absolute;width: 350px;border-radius: 5px;height: 500px;box-shadow: 0px 0px 5px #333333;background:white;top: 50%;left: 50%;margin-top: -250px;margin-left: -175px;transition: all 1s;-moz-transition: all 1s; /* Firefox 4 */-webkit-transition: all 1s; /* Safari 和 Chrome */-o-transition: all 1s; /* Opera */}
|
||||||
.login-top{font-size: 24px;margin-top: 100px;padding-left: 40px;box-sizing: border-box;color: #333333;margin-bottom: 50px;font-family:"微软雅黑";font-weight:bold;color:dodgerblue}
|
.login-top{font-size: 24px;margin-top: 100px;text-align: center;;box-sizing: border-box;color: #333333;margin-bottom: 50px;font-family:"微软雅黑";font-weight:bold;color:dodgerblue}
|
||||||
.login-center{width: 100%;box-sizing: border-box;padding: 0 40px;margin-bottom: 30px;}
|
.login-center{width: 100%;box-sizing: border-box;padding: 0 40px;margin-bottom: 30px;}
|
||||||
.login-center-img{width: 20px;height: 20px;float: left;margin-top: 5px;}
|
.login-center-img{width: 20px;height: 20px;float: left;margin-top: 5px;}
|
||||||
.login-center-img>img{width: 100%;}
|
.login-center-img>img{width: 100%;}
|
||||||
.login-center-input{float: left;width: 230px;margin-left: 15px;height: 30px;position: relative;}
|
.login-center-input{float: left;width: 80%;margin-left: 15px;height: 30px;position: relative;}
|
||||||
.login-center-input input{z-index: 2;transition: all 0.5s;padding-left: 10px;color: #333333;width: 100%;height: 30px;border: 0;border-bottom: 1px solid #cccccc;border-top: 1px solid #ffffff;border-left: 1px solid #ffffff;border-right: 1px solid #ffffff;box-sizing: border-box;outline: none;position: relative;}
|
.login-center-input input{z-index: 2;transition: all 0.5s;padding-left: 10px;color: #333333;width: 100%;height: 30px;border: 0;border-bottom: 1px solid #cccccc;border-top: 1px solid #ffffff;border-left: 1px solid #ffffff;border-right: 1px solid #ffffff;box-sizing: border-box;outline: none;position: relative;}
|
||||||
.login-center-input input:focus{border: 1px solid dodgerblue;}
|
.login-center-input input:focus{border: 1px solid dodgerblue;}
|
||||||
.login-center-input-text{background: white;padding: 0 5px;position: absolute;z-index: 0;opacity: 0;height: 20px;top: 50%;margin-top: -10px;font-size: 14px;left: 5px;color: dodgerblue;line-height: 20px;transition: all 0.5s;-moz-transition: all 0.5s; /* Firefox 4 */-webkit-transition: all 0.5s; /* Safari 和 Chrome */-o-transition: all 0.5s; /* Opera */}
|
.login-center-input-text{background: white;padding: 0 5px;position: absolute;z-index: 0;opacity: 0;height: 20px;top: 50%;margin-top: -10px;font-size: 14px;left: 5px;color: dodgerblue;line-height: 20px;transition: all 0.5s;-moz-transition: all 0.5s; /* Firefox 4 */-webkit-transition: all 0.5s; /* Safari 和 Chrome */-o-transition: all 0.5s; /* Opera */}
|
||||||
.login-center-input input:focus~.login-center-input-text{top: 0;z-index: 3;opacity: 1;margin-top: -15px;}
|
.login-center-input input:focus~.login-center-input-text{top: 0;z-index: 3;opacity: 1;margin-top: -15px;}
|
||||||
.login.active{-webkit-animation: login-small 0.8s ; animation: login-small 0.8s ;animation-fill-mode:forwards;-webkit-animation-fill-mode:forwards}
|
.login.active{-webkit-animation: login-small 0.8s ; animation: login-small 0.8s ;animation-fill-mode:forwards;-webkit-animation-fill-mode:forwards}
|
||||||
.login-button{cursor: pointer;width: 250px;text-align: center;height: 40px;line-height: 40px;background-color: dodgerblue;border-radius: 5px;margin: 0 auto;margin-top: 50px;color: white;font-size: 18px}
|
.login-button{cursor: pointer;width: 80%;text-align: center;height: 40px;line-height: 40px;background-color: dodgerblue;margin: 0 auto;margin-top: 50px;color: white;font-size: 18px}
|
||||||
|
|
||||||
|
|
|
@ -526,7 +526,7 @@ function jsonSort(jsonObj) {
|
||||||
}
|
}
|
||||||
return str.substr(0, str.length - 1)
|
return str.substr(0, str.length - 1)
|
||||||
}
|
}
|
||||||
//map定时显示,每分钟请求一次
|
//map定时显示,每分钟请求一次,如果存在map
|
||||||
function update() {
|
function update() {
|
||||||
if ($('#mapshowinput').length) {
|
if ($('#mapshowinput').length) {
|
||||||
source.clear()
|
source.clear()
|
||||||
|
@ -571,4 +571,15 @@ function update() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function checksession(){
|
||||||
|
$.get('api/check_session',function(res){
|
||||||
|
if(res.code==1){
|
||||||
|
}else{
|
||||||
|
$.messager.alert('','长时间未操作,请重新登陆!','warning',function(){
|
||||||
|
window.location.reload(true)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
var t1 = window.setInterval(update, 1000 * 60)
|
var t1 = window.setInterval(update, 1000 * 60)
|
||||||
|
var t2 = window.setInterval(checksession,1000*60*31)
|
|
@ -155,6 +155,7 @@ urlpatterns = [
|
||||||
path('api/obscount',views.observepic),
|
path('api/obscount',views.observepic),
|
||||||
path('api/riskas',views.apiriskas),
|
path('api/riskas',views.apiriskas),
|
||||||
path('api/trainfg',views.trainfg),
|
path('api/trainfg',views.trainfg),
|
||||||
|
path('api/check_session',views.check_session),
|
||||||
|
|
||||||
#path('api/rights/group/<int:groupid>',views.rightsgroup),
|
#path('api/rights/group/<int:groupid>',views.rightsgroup),
|
||||||
path('api/main',views.mainapi),
|
path('api/main',views.mainapi),
|
||||||
|
|
|
@ -26,6 +26,9 @@ import jwt
|
||||||
import decimal
|
import decimal
|
||||||
from . import forms
|
from . import forms
|
||||||
from .models import CompanyInfo
|
from .models import CompanyInfo
|
||||||
|
from django.contrib.sessions.models import Session
|
||||||
|
import logging
|
||||||
|
logger = logging.getLogger('log')
|
||||||
|
|
||||||
#分页功能
|
#分页功能
|
||||||
def fenye(req):
|
def fenye(req):
|
||||||
|
@ -272,6 +275,11 @@ def check_login(func):
|
||||||
# return JsonResponse({"code": 401, "message": "please login!"})
|
# return JsonResponse({"code": 401, "message": "please login!"})
|
||||||
return warpper
|
return warpper
|
||||||
|
|
||||||
|
def check_session(req):
|
||||||
|
if req.session.get('userid',None):
|
||||||
|
return JsonResponse({"code":1})
|
||||||
|
else:
|
||||||
|
return JsonResponse({"code":0})
|
||||||
#存储文件
|
#存储文件
|
||||||
def upfile(req):
|
def upfile(req):
|
||||||
username = User.objects.get(userid=req.session['userid']).username
|
username = User.objects.get(userid=req.session['userid']).username
|
||||||
|
@ -295,13 +303,22 @@ def login(req):
|
||||||
if user:
|
if user:
|
||||||
#比较成功,跳转index
|
#比较成功,跳转index
|
||||||
req.session['userid'] = user[0].userid
|
req.session['userid'] = user[0].userid
|
||||||
# req.session.set_expiry(60*30)
|
#req.session.set_expiry(10)
|
||||||
|
#登录之后获取获取最新的session_key
|
||||||
|
# session_key = req.session.session_key
|
||||||
|
#删除非当前用户session_key的记录
|
||||||
|
# for session in Session.objects.filter(~Q(session_key=session_key), expire_date__gte=datetime.now()):
|
||||||
|
# data = session.get_decoded()
|
||||||
|
# if data.get('userid', None) == user[0].userid:
|
||||||
|
# session.delete()
|
||||||
|
logger.info('method: %s user: %s 登陆' % (req.method,user[0].userid))
|
||||||
return redirect('index')
|
return redirect('index')
|
||||||
else:
|
else:
|
||||||
return render(req,'login.html',{'msg':'用户名或密码错误!'})
|
return render(req,'login.html',{'msg':'用户名或密码错误!'})
|
||||||
else:
|
else:
|
||||||
return render(req,'login.html')
|
return render(req,'login.html')
|
||||||
|
|
||||||
|
|
||||||
def index(req):
|
def index(req):
|
||||||
if not req.session.get('userid', None):
|
if not req.session.get('userid', None):
|
||||||
return redirect('login')
|
return redirect('login')
|
||||||
|
@ -320,6 +337,7 @@ def logout(req):
|
||||||
#del req.session['username']
|
#del req.session['username']
|
||||||
# if "userid" in req.session:
|
# if "userid" in req.session:
|
||||||
# del req.session['userid']
|
# del req.session['userid']
|
||||||
|
logger.info('method: %s user: %s 登出' % (req.method,req.session['userid']))
|
||||||
req.session.flush()
|
req.session.flush()
|
||||||
#req.session.flush()
|
#req.session.flush()
|
||||||
#req.session.delete("session_key")
|
#req.session.delete("session_key")
|
||||||
|
|
Loading…
Reference in New Issue