This commit is contained in:
commit
67d1e36e3b
|
|
@ -8,7 +8,9 @@ safesite/datashow/__pycache__/
|
|||
duibiao/__pycache__/
|
||||
mysite/__pycache__/
|
||||
media/
|
||||
|
||||
aspnet_client/
|
||||
static/
|
||||
mysite/settings.py
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
'utc_enabled', (1024, 4)
|
||||
'tz', (1536, 23)
|
||||
'entries', (2048, 556)
|
||||
'entries', (2048, 587)
|
||||
'__version__', (512, 15)
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,4 +1,4 @@
|
|||
'utc_enabled', (1024, 4)
|
||||
'tz', (1536, 23)
|
||||
'entries', (2048, 556)
|
||||
'entries', (2048, 587)
|
||||
'__version__', (512, 15)
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
8252
|
||||
1640
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -26,7 +26,7 @@ SECRET_KEY = '^2_d@h7#j5zx4=g+!=r&tdmm&)akpd_hf!7@-85#qs(+*(#o!i'
|
|||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = ['10.7.100.160','10.7.100.250','192.168.0.100','127.0.0.1','114.115.210.98','safeyun.ctcshe.com','ctcshe.com','localhost','192.168.0.102','10.7.100.209']
|
||||
ALLOWED_HOSTS = ['*']
|
||||
|
||||
# Application definition
|
||||
|
||||
|
|
@ -85,8 +85,8 @@ DATABASES = {
|
|||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'safedb',
|
||||
'USER':'postgres',
|
||||
'PASSWORD':'0000',
|
||||
'HOST':'114.115.210.98',
|
||||
'PASSWORD':'cTc1111Qa',
|
||||
'HOST':'121.36.23.77',
|
||||
'PORT':'5432',
|
||||
'CONN_MAX_AGE': 600,
|
||||
},
|
||||
|
|
@ -145,8 +145,8 @@ CELERY_TIMEZONE='Asia/Shanghai'
|
|||
CELERY_ENABLE_UTC=True
|
||||
|
||||
##配置session
|
||||
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
|
||||
SESSION_COOKIE_AGE = 1800
|
||||
#SESSION_EXPIRE_AT_BROWSER_CLOSE = True
|
||||
SESSION_COOKIE_AGE = 2400
|
||||
SESSION_SAVE_EVERY_REQUEST = True
|
||||
|
||||
#日志配置
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
amqp==2.5.2
|
||||
billiard==3.6.1.0
|
||||
boto==2.49.0
|
||||
boto3==1.10.17
|
||||
botocore==1.13.17
|
||||
celery==4.3.0
|
||||
certifi==2019.9.11
|
||||
chardet==3.0.4
|
||||
colorama==0.4.1
|
||||
Django==2.2.7
|
||||
django-ranged-response==0.2.0
|
||||
django-simple-captcha==0.5.12
|
||||
dnspython==1.16.0
|
||||
docutils==0.15.2
|
||||
docxtpl==0.6.3
|
||||
et-xmlfile==1.0.1
|
||||
eventlet==0.25.1
|
||||
gensim==3.4.0
|
||||
greenlet==0.4.15
|
||||
idna==2.8
|
||||
importlib-metadata==0.23
|
||||
jdcal==1.4.1
|
||||
jieba==0.39
|
||||
Jinja2==2.10.3
|
||||
jmespath==0.9.4
|
||||
joblib==0.14.0
|
||||
kombu==4.6.6
|
||||
lxml==4.4.1
|
||||
MarkupSafe==1.1.1
|
||||
monotonic==1.5
|
||||
more-itertools==7.2.0
|
||||
numpy==1.17.4
|
||||
openpyxl==3.0.0
|
||||
pandas==0.25.3
|
||||
Pillow==6.2.1
|
||||
psycopg2==2.8.4
|
||||
PyJWT==1.7.1
|
||||
python-dateutil==2.8.0
|
||||
python-docx==0.8.7
|
||||
pytz==2019.3
|
||||
qrcode==6.1
|
||||
redis==3.3.11
|
||||
requests==2.22.0
|
||||
s3transfer==0.2.1
|
||||
scikit-learn==0.21.3
|
||||
scipy==1.3.2
|
||||
six==1.13.0
|
||||
sklearn==0.0
|
||||
smart-open==1.9.0
|
||||
sqlparse==0.3.0
|
||||
urllib3==1.25.7
|
||||
vine==1.3.0
|
||||
wfastcgi==3.0.0
|
||||
XlsxWriter==1.2.5
|
||||
zipp==0.6.0
|
||||
|
|
@ -8,6 +8,7 @@ import base64
|
|||
from django.conf import settings
|
||||
import qrcode
|
||||
import os
|
||||
from django.contrib.auth.hashers import make_password
|
||||
|
||||
def makeqr(data):
|
||||
upload_folder = 'media/qr_equipment'
|
||||
|
|
@ -311,6 +312,7 @@ def drusers(companyid,path):
|
|||
a.empid = empid
|
||||
a.username = username
|
||||
a.password = '0000'
|
||||
a.epassword = make_password('0000')
|
||||
a.ubelongpart = Partment.objects.get(partid=partdict[partname])
|
||||
a.usecomp = Partment.objects.get(partid=companyid)
|
||||
a.save()
|
||||
|
|
|
|||
|
|
@ -609,7 +609,7 @@ def exportxlsx(a,objs):
|
|||
res['Content-Disposition'] = 'attachment;filename='+filename+'.xlsx'
|
||||
res.write(output.getvalue())
|
||||
return res
|
||||
elif a == 'xj':
|
||||
elif a == 'xj':#巡检记录
|
||||
#查询数据
|
||||
xjlist = objs.values('id','state','content','creattime','equipment__num','equipment__name','equipment__area__name','user__name','user__ubelongpart__partname','trouble__yhzt','trouble__yhnum','trouble__yhms')
|
||||
wb = load_workbook(dirname + 'safesite/exportemp/xj.xlsx')
|
||||
|
|
@ -637,6 +637,29 @@ def exportxlsx(a,objs):
|
|||
res['Content-Disposition'] = 'attachment;filename='+filename+'.xlsx'
|
||||
res.write(output.getvalue())
|
||||
return res
|
||||
elif a == 'equipment':#设备
|
||||
#查询数据
|
||||
wb = load_workbook(dirname + 'safesite/exportemp/equipment.xlsx')
|
||||
sheet = wb.active
|
||||
for i, x in enumerate(objs):
|
||||
num = str(i+3)
|
||||
sheet['a'+num] = x.num
|
||||
sheet['b'+num] = x.name
|
||||
sheet['c'+num] = x.cate.dickeyname
|
||||
sheet['d'+num] = x.type
|
||||
sheet['e'+num] = x.area.name
|
||||
sheet['f'+num] = '正常' if x.state==1 else '异常'
|
||||
sheet['g'+num] = 'https://safeyun.ctcshe.com/miniprogram/equipment?id='+str(x.id)
|
||||
nowtime = datetime.now().strftime('%Y%m%d%H%M%S')
|
||||
sheet['b1'] = nowtime
|
||||
filename = 'SBS' + nowtime
|
||||
output = BytesIO()
|
||||
wb.save(output)
|
||||
output.seek(0)
|
||||
res = HttpResponse(content_type='application/vnd.ms-excel')
|
||||
res['Content-Disposition'] = 'attachment;filename='+filename+'.xlsx'
|
||||
res.write(output.getvalue())
|
||||
return res
|
||||
|
||||
def exportyjdoc(vl):
|
||||
doc = DocxTemplate(dirname + "safesite/exportemp/fxbg.docx")
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 2.1.5 on 2019-11-18 22:52
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('safesite', '0286_auto_20191030_1632'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# migrations.RemoveField(
|
||||
# model_name='companyinfo',
|
||||
# name='liaison_fax',
|
||||
# ),
|
||||
migrations.AddField(
|
||||
model_name='user',
|
||||
name='epassword',
|
||||
field=models.CharField(default=None, max_length=60),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
# Generated by Django 2.1.5 on 2019-11-18 22:53
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('safesite', '0287_auto_20191118_2252'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# migrations.RemoveField(
|
||||
# model_name='companyinfo',
|
||||
# name='liaison_fax',
|
||||
# ),
|
||||
migrations.AlterField(
|
||||
model_name='user',
|
||||
name='epassword',
|
||||
field=models.CharField(default='', max_length=60),
|
||||
),
|
||||
]
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
# Generated by Django 2.1.5 on 2019-11-18 22:56
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('safesite', '0288_auto_20191118_2253'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# migrations.RemoveField(
|
||||
# model_name='companyinfo',
|
||||
# name='liaison_fax',
|
||||
# ),
|
||||
migrations.AlterField(
|
||||
model_name='user',
|
||||
name='epassword',
|
||||
field=models.CharField(blank=True, max_length=60, null=True),
|
||||
),
|
||||
]
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
# Generated by Django 2.1.5 on 2019-11-18 22:56
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('safesite', '0289_auto_20191118_2256'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# migrations.RemoveField(
|
||||
# model_name='companyinfo',
|
||||
# name='liaison_fax',
|
||||
# ),
|
||||
migrations.RemoveField(
|
||||
model_name='user',
|
||||
name='epassword',
|
||||
),
|
||||
]
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
# Generated by Django 2.1.5 on 2019-11-18 23:09
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('safesite', '0290_auto_20191118_2256'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# migrations.RemoveField(
|
||||
# model_name='companyinfo',
|
||||
# name='liaison_fax',
|
||||
# ),
|
||||
migrations.AddField(
|
||||
model_name='user',
|
||||
name='epassword',
|
||||
field=models.CharField(blank=True, max_length=60, null=True),
|
||||
),
|
||||
]
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
# Generated by Django 2.1.5 on 2019-11-19 18:05
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('safesite', '0291_auto_20191118_2309'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# migrations.RemoveField(
|
||||
# model_name='companyinfo',
|
||||
# name='liaison_fax',
|
||||
# ),
|
||||
migrations.AlterField(
|
||||
model_name='user',
|
||||
name='password',
|
||||
field=models.CharField(max_length=100),
|
||||
),
|
||||
]
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
# Generated by Django 2.1.5 on 2019-11-19 18:11
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('safesite', '0292_auto_20191119_1805'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# migrations.RemoveField(
|
||||
# model_name='companyinfo',
|
||||
# name='liaison_fax',
|
||||
# ),
|
||||
migrations.AlterField(
|
||||
model_name='user',
|
||||
name='epassword',
|
||||
field=models.CharField(blank=True, max_length=200, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='user',
|
||||
name='password',
|
||||
field=models.CharField(max_length=30),
|
||||
),
|
||||
]
|
||||
|
|
@ -51,6 +51,7 @@ class User(models.Model):
|
|||
username = models.CharField(max_length=30,unique=True)#账号
|
||||
name = models.CharField(max_length=20)
|
||||
password = models.CharField(max_length=30)
|
||||
epassword = models.CharField(max_length=200,blank=True,null=True)
|
||||
ubelongpart = models.ForeignKey(Partment,related_name='upart', on_delete=models.CASCADE)
|
||||
openid=models.CharField(max_length=200,null=True,blank=True)#公众号openid
|
||||
nickname=models.CharField(max_length=200,null=True,blank=True)#昵称
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -90,7 +90,7 @@
|
|||
required=true>
|
||||
</div>
|
||||
<div id="filediv" style="margin-bottom:5px;display:none">
|
||||
<label>相关资料: </label><input type="file" id="file" name="" accept="*" style="margin-left: 20px" />
|
||||
<label>相关资料: </label><input type="file" id="file" name="" accept="image/*,.doc,.docx,.ppt,.pptx,.xls,.xlsx,.zip" style="margin-left: 20px" />
|
||||
<span id='ps' style="display:none">
|
||||
<input type="button" onclick="cancleUploadFile()" value="取消" />
|
||||
<progress id="progressBar" value="0" max="100" style="width: 100px;"></progress>
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@
|
|||
<input id="examtest" name="examtest" class="easyui-combobox" style="width:480px;" editable=false data-options="label:'关联考试',url:'api/examtest?a=listtrain'">
|
||||
</div>
|
||||
<div id='filediv' style="margin-bottom:5px;">
|
||||
<label>相关资料 </label><input type="file" id="file" name="" accept="*" style="margin-left: 20px" />
|
||||
<label>相关资料 </label><input type="file" id="file" name="" accept="image/*,.doc,.docx,.ppt,.pptx,.xls,.xlsx,.zip" style="margin-left: 20px" />
|
||||
<span id='ps' style="display:none">
|
||||
<input type="button" onclick="cancleUploadFile()" value="取消" />
|
||||
<progress id="progressBar" value="0" max="100" style="width: 100px;"></progress>
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
<label>设备名称</label><input name='name' id='sname'
|
||||
class="easyui-textbox" >
|
||||
<a id="sbsearch" onclick="sbsearch()" class="easyui-linkbutton" data-options="iconCls: 'fa-search',plain:true">查询</a>
|
||||
<a id="exportsbexcel" onclick="exportsbexcel()" class="easyui-linkbutton" data-options="iconCls: 'fa-download',plain:true">导出Excel</a>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
|
@ -254,9 +255,6 @@
|
|||
else {
|
||||
$.messager.alert('提示', '未选择数据!');
|
||||
}
|
||||
}
|
||||
function exportsbexcel(){
|
||||
|
||||
}
|
||||
function sbsearch(){
|
||||
var querydata = $('#searchsbff').serializeJSON();
|
||||
|
|
@ -264,6 +262,11 @@
|
|||
$('#sbtable').datagrid('load',querydata);
|
||||
//$('<form method="post" action="' + url + '"></form>').appendTo('body').submit().remove();
|
||||
}
|
||||
function exportsbexcel() {
|
||||
var querydata = $('#searchsbff').serializeJSON();
|
||||
let url = 'api/equipment?a=listall&b=exportexcel&'+parseParams(querydata)
|
||||
$('<form method="post" action="' + url + '"></form>').appendTo('body').submit().remove();
|
||||
}
|
||||
function addsb(){
|
||||
$('#sbff').form('clear')
|
||||
$('#sbtable').datagrid('clearSelections');
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
|
|
@ -30,6 +30,7 @@
|
|||
type: "get",
|
||||
url: "/api/examtestdetail?a=detail",
|
||||
data: { 'id': id },
|
||||
async: true,
|
||||
dateType: "json",
|
||||
success: function (data) {
|
||||
document.getElementById("examname").innerHTML = data.examtest__name;
|
||||
|
|
@ -49,7 +50,9 @@
|
|||
divHtml += '<span style="color:blue">' + "【判断题】</span></span>"+"第"+i+"题:" + data.testdetail[i].question__title +'</span>';
|
||||
divHtml += '<span style=" margin-left: 40px; color:#d5cc1d;">此题得分:' + data.testdetail[i].iscore + ' 分</span>';
|
||||
divHtml += '<br />';
|
||||
divHtml += '<div style="margin-left: 80px;margin-top: 15px;"><span>A.' + data.testdetail[i].question__answer.A + '</span></br></br><span>B.' + data.testdetail[i].question__answer.B +'</span></div>';
|
||||
for (var item in data.testdetail[i].question__answer) {
|
||||
divHtml += '<div style="margin-left: 80px;margin-top: 15px;"><span>' + item + '、' + data.testdetail[i].question__answer[item] + '</span></div>';
|
||||
}
|
||||
divHtml += '<br />';
|
||||
divHtml += '<div style="padding-left: 10px; padding-top: 10px;">';
|
||||
divHtml += '<div style="color:green;">正确答案:' + data.testdetail[i].question__right + '</div>';
|
||||
|
|
@ -62,13 +65,16 @@
|
|||
divHtml += '<div style="margin-top: 10px;color: #4f3b08;font-size:13px;">' + (data.testdetail[i].question_resolution == undefined ? '本题无解析!' : data.testdetail[i].question_resolution) +'</div>';
|
||||
}
|
||||
else if (data.testdetail[i].question__type == 2) {
|
||||
console.log(data.testdetail[i])
|
||||
var divHtml = "";
|
||||
var answrText = "";
|
||||
divHtml += '<div style="margin-left:30px;padding-bottom:13px">';
|
||||
divHtml += '<span style="color:blue">' + "【多选题】</span></span>" +"第" + i + "题:" + data.testdetail[i].question__title + '</span>';
|
||||
divHtml += '<span style=" margin-left: 40px; color:#d5cc1d;">此题得分:' + data.testdetail[i].iscore + ' 分</span>';
|
||||
divHtml += '<br />';
|
||||
divHtml += '<div style="margin-left: 80px;margin-top: 15px;"><span>A.' + data.testdetail[i].question__answer.A + '</span></br></br><span>B.' + data.testdetail[i].question__answer.B + '</span></br></br><span>C.' + data.testdetail[i].question__answer.C + '</span></br></br><span>D.' + data.testdetail[i].question__answer.D + '</span></br></br><span>E.' + (data.testdetail[i].question__answer.E == undefined ? '无该选项' : data.testdetail[i].question__answer.E) + '</span></br></br><span>F.' + (data.testdetail[i].question__answer.F == undefined ? '无该选项' : data.testdetail[i].question__answer.F) + '</span></div>';
|
||||
for (var item in data.testdetail[i].question__answer) {
|
||||
divHtml += '<div style="margin-left: 80px;margin-top: 15px;"><span>' + item + '、' + data.testdetail[i].question__answer[item] + '</span></div>';
|
||||
}
|
||||
divHtml += '<br />';
|
||||
divHtml += '<div style="padding-left: 10px; padding-top: 10px;">';
|
||||
divHtml += '<div style="color:green;">正确答案:' + data.testdetail[i].question__right + '</div>';
|
||||
|
|
@ -91,7 +97,14 @@
|
|||
divHtml += '<span style="color:blue">' + "【单选题】</span></span>" + "第" + i + "题:" + data.testdetail[i].question__title + '</span>';
|
||||
divHtml += '<span style=" margin-left: 40px; color:#d5cc1d;">此题得分:' + data.testdetail[i].iscore + ' 分</span>';
|
||||
divHtml += '<br />';
|
||||
divHtml += '<div style="margin-left: 80px;margin-top: 15px;"><span>A.' + data.testdetail[i].question__answer.A + '</span></br></br><span>B.' + data.testdetail[i].question__answer.B + '</span></br></br><span>C.' + data.testdetail[i].question__answer.C + '</span></br></br><span>D.' + data.testdetail[i].question__answer.D + '</span></div>';
|
||||
for (var item in data.testdetail[i].question__answer) {
|
||||
if (data.testdetail[i].question__answer[item] != "")
|
||||
{
|
||||
divHtml += '<div style="margin-left: 80px;margin-top: 15px;"><span>' + item + '、' + data.testdetail[i].question__answer[item] + '</span></div>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
divHtml += '<br />';
|
||||
divHtml += '<div style="padding-left: 10px; padding-top: 10px;">';
|
||||
divHtml += '<div style="color:green;">正确答案:' + data.testdetail[i].question__right + '</div>';
|
||||
|
|
|
|||
|
|
@ -28,12 +28,11 @@
|
|||
<script src="https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.js"></script>
|
||||
<script type="text/javascript" src="/static/safesite/mystatic/js/util.js"></script>
|
||||
<style type="text/css">
|
||||
.easyui-linkbutton:hover
|
||||
|
||||
{
|
||||
.easyui-linkbutton:hover {
|
||||
background: #1148a0;
|
||||
color: #0E2D5F;
|
||||
}
|
||||
|
||||
.loading {
|
||||
position: absolute;
|
||||
z-index: 1000;
|
||||
|
|
@ -45,14 +44,16 @@
|
|||
text-align: left;
|
||||
padding: 5px 10px
|
||||
}
|
||||
|
||||
.northDiv {
|
||||
overflow: hidden;
|
||||
height: 80px;
|
||||
background-color: #013162;
|
||||
background-image: url("/static/safesite/mystatic/images/indexbj1.png");
|
||||
background-repeat: no-repeat;
|
||||
font-family: Verdana, 微软雅黑,黑体
|
||||
font-family: Verdana, 微软雅黑, 黑体
|
||||
}
|
||||
|
||||
.divMune {
|
||||
height: 35px;
|
||||
background-color: #f9f9f9;
|
||||
|
|
@ -76,7 +77,8 @@
|
|||
</div>
|
||||
<div region="north" class="northDiv">
|
||||
<div style="float:right;width:7%;margin-left:10px">
|
||||
<img src="/static/safesite/mystatic/images/head.png" style="float: right;width:50px;height:50px;text-align: center;margin-top: 10px;margin-right: 10px;"
|
||||
<img src="/static/safesite/mystatic/images/head.png"
|
||||
style="float: right;width:50px;height:50px;text-align: center;margin-top: 10px;margin-right: 10px;"
|
||||
id="headimg" />
|
||||
</div>
|
||||
<div style="width:30%;float:right">
|
||||
|
|
@ -88,13 +90,14 @@
|
|||
<div style="text-align: center;position: fixed;width: 500px;height: 70px;top: 40px;right: 60px;">
|
||||
<a style="color: #eee5e7;cursor: pointer;" class="easyui-linkbutton" iconCls="fa-sign-out" plain=true
|
||||
onclick="logout()">安全退出</a>
|
||||
<a style="color: #eee5e7;cursor: pointer;" id="bindwx" class="easyui-linkbutton" iconCls="fa-weixin" plain=true
|
||||
onclick="bindwx()">绑定微信</a>
|
||||
<a style="color: #eee5e7;cursor: pointer;" id="bindwx" class="easyui-linkbutton" iconCls="fa-weixin"
|
||||
plain=true onclick="bindwx()">绑定微信</a>
|
||||
<a style="color: #eee5e7;cursor: pointer;" class="easyui-linkbutton" iconCls="fa-key" plain=true
|
||||
onclick="javascript:$('#pwdg').dialog({border:false})">修改密码</a>
|
||||
<a id='setupb' class="easyui-linkbutton" iconCls="fa-cogs" plain=true style="display:none;color: #eee5e7;cursor: pointer;"
|
||||
onclick="setup()">预警设置</a>
|
||||
<a style="color: #eee5e7;cursor: pointer;" href="datashow" target="_blank" class="easyui-linkbutton" iconCls="fa-desktop" plain=true>数据大屏</a>
|
||||
<a id='setupb' class="easyui-linkbutton" iconCls="fa-cogs" plain=true
|
||||
style="display:none;color: #eee5e7;cursor: pointer;" onclick="setup()">预警设置</a>
|
||||
<a style="color: #eee5e7;cursor: pointer;" href="datashow" target="_blank" class="easyui-linkbutton"
|
||||
iconCls="fa-desktop" plain=true>数据大屏</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -102,14 +105,18 @@
|
|||
<input id="userindex" userid="{{userid}}" openid="{{openid}}" nickname="{{nickname}}"
|
||||
headimgurl="{{headimgurl}}" menus="{{menus}}" style="display:none;" />
|
||||
|
||||
<button style="margin: 15px;background-color: transparent;border: 0;color: white;cursor: pointer;" onclick="javascript:$('#main').panel({href:'mainhtml',title:'主页'})"><span style="font-size:24px">{{companyname}}</span><br/><span style="font-size:20px">安全生产管理系统</span></button>
|
||||
<button style="margin: 15px;background-color: transparent;border: 0;color: white;cursor: pointer;"
|
||||
onclick="javascript:$('#main').panel({href:'mainhtml',title:'主页'})"><span
|
||||
style="font-size:24px">{{companyname}}</span><br /><span
|
||||
style="font-size:20px">安全生产管理系统</span></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="menuTreediv" data-options="region:'west'" style="width: 150px; background-color: #ffffff;">
|
||||
<div class="divMune">
|
||||
<img src="/static/safesite/mystatic/images/fanhuiBut.png" style="float: right;width:20px;height:20px;text-align: center;margin-top: 10px;margin-right: 10px;"
|
||||
<img src="/static/safesite/mystatic/images/fanhuiBut.png"
|
||||
style="float: right;width:20px;height:20px;text-align: center;margin-top: 10px;margin-right: 10px;"
|
||||
id="headimg" />
|
||||
<a onclick="javascript:$('#main').panel({href:'mainhtml',title:'主页'})">返回主页</a>
|
||||
</div>
|
||||
|
|
@ -198,7 +205,11 @@
|
|||
var v = $("#oldpwd").val();
|
||||
var v1 = $("#newpwd").val();
|
||||
var v2 = $("#newpwd2").val();
|
||||
if (v1 == v2) {
|
||||
var regex = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z]).{8,30}');
|
||||
if (!regex.test(v1)||!regex.test(v2)) {
|
||||
$.messager.alert("提示信息", "您的密码复杂度太低(密码中必须包含字母、数字)", "error");
|
||||
}
|
||||
else if (v1 == v2) {
|
||||
$.post(
|
||||
"changepwd",
|
||||
{ "oldpassword": v, "newpassword": v1 },
|
||||
|
|
@ -221,7 +232,7 @@
|
|||
}
|
||||
|
||||
function setup() {
|
||||
opendg('预警相关设置','setup?a=setuph')
|
||||
opendg('预警相关设置', 'setup?a=setuph')
|
||||
}
|
||||
/*
|
||||
* 关闭遮罩层
|
||||
|
|
@ -252,8 +263,8 @@
|
|||
},
|
||||
});
|
||||
})
|
||||
$.get('api/rights?a=have',function(res){
|
||||
localStorage.setItem('data',JSON.stringify(res));
|
||||
$.get('api/rights?a=have', function (res) {
|
||||
localStorage.setItem('data', JSON.stringify(res));
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@
|
|||
<div class="login-center-input">
|
||||
<input type="text" name="username" value="" placeholder="请输入您的用户名" onfocus="this.placeholder=''"
|
||||
onblur="this.placeholder='请输入您的用户名'" />
|
||||
<div class="login-center-input-text">用户名</div>
|
||||
<!-- <div class="login-center-input-text">用户名</div> -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="login-center clearfix">
|
||||
|
|
@ -139,7 +139,7 @@
|
|||
<div class="login-center-input">
|
||||
<input type="password" name="password" value="" placeholder="请输入您的密码"
|
||||
onfocus="this.placeholder=''" onblur="this.placeholder='请输入您的密码'" />
|
||||
<div class="login-center-input-text">密码</div>
|
||||
<!-- <div class="login-center-input-text">密码</div> -->
|
||||
</div>
|
||||
</div>
|
||||
<p style="color:red;text-align: center">{{msg}}</p>
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
</div>
|
||||
<div style="margin-top:10px;margin-bottom:5px">
|
||||
<label class='labeldiv'>附件</label>
|
||||
<input type="file" id="file" name="" accept="*" style="margin-left: 20px" />
|
||||
<input type="file" id="file" name="" accept="image/*,.doc,.docx,.ppt,.pptx,.xls,.xlsx,.zip" style="margin-left: 20px" />
|
||||
<span id='ps' style="display:none">
|
||||
<input type="button" onclick="cancleUploadFile()" value="取消" />
|
||||
<progress id="progressBar" value="0" max="100" style="width: 100px;"></progress>
|
||||
|
|
|
|||
|
|
@ -2,16 +2,35 @@
|
|||
<div id="zytablebar" style="padding:6px;height:auto">
|
||||
<div style="margin-bottom:2px;margin-top:2px">
|
||||
<!-- <a class="easyui-menubutton" data-options="menu:'#mm1',iconCls: 'fa-plus',plain:true">申请</a> -->
|
||||
<a onclick="javascript:$('#sdg_zy').dialog('open')" class="easyui-linkbutton" data-options="iconCls: 'fa-search',plain:true">详细筛选</a>
|
||||
<a id="delzy" class="easyui-linkbutton" onclick="delzy()" data-options="iconCls: 'fa-trash',plain:true">删除</a>
|
||||
<a id="zydetail" onclick="zydetail()" class="easyui-linkbutton" data-options="iconCls: 'fa-info-circle',plain:true">查看详情</a>
|
||||
<a id="exportzyword" onclick="exportzyword()" class="easyui-linkbutton" data-options="iconCls: 'fa-download',plain:true">导出Word</a>
|
||||
<a id="exportzyexcel" onclick="exportzyexcel()" class="easyui-linkbutton" data-options="iconCls: 'fa-download',plain:true">导出Excel</a>
|
||||
|
||||
</div>
|
||||
<!-- <div id="mm1" style="width:150px;">
|
||||
<div>Cut</div>
|
||||
<div>Copy</div>
|
||||
<div>Paste</div>
|
||||
</div> -->
|
||||
<div id="sdg_zy" class="easyui-dialog" title="筛选条件" style="width:400px;height:300px;"
|
||||
data-options="iconCls:'fa-search',resizable:true,modal:true,closed:true,border:false">
|
||||
<div class="easyui-layout" style="width:100%;height:100%;">
|
||||
<div data-options="region:'center'" style="height:100%;text-align:center">
|
||||
<form id='searchzyff'>
|
||||
<div style="margin-top:6px"><label>起始时间</label><input name='qssj' style="width:300px"
|
||||
class="easyui-datebox" editable=false></div>
|
||||
<div style="margin-top:6px"><label>结束时间</label><input name='jssj' style="width:300px"
|
||||
class="easyui-datebox" editable=false></div>
|
||||
</form>
|
||||
</div>
|
||||
<div id='southdiv' data-options="region:'south'" style="height:46px;text-align:center;padding:6px">
|
||||
<a id="zysearch" onclick="zysearch()" class="easyui-linkbutton" data-options="iconCls: 'fa-search'">查询</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(function(){
|
||||
|
|
@ -38,7 +57,7 @@
|
|||
});
|
||||
function zysearch() {
|
||||
var querydata = $('#searchzyff').serializeJSON();
|
||||
querydata['a'] = 'listsearch'
|
||||
querydata['a'] = 'listall'
|
||||
$("#sdg_zy").dialog("close");
|
||||
$('#zytable').datagrid('load',querydata);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -313,7 +313,6 @@
|
|||
var row = $('#yhtable').datagrid('getSelected');
|
||||
if (row) {
|
||||
if (row.yhzt != 6) {
|
||||
//alert(row.todouser__userid);
|
||||
if ($("#userindex").attr('userid') == row.todouser__userid) {
|
||||
if (row.yhzt == 0) {
|
||||
opendg('编辑隐患','addtrouble?a=edityh&troubleid=' + row.troubleid)
|
||||
|
|
|
|||
|
|
@ -120,7 +120,8 @@
|
|||
}; //请求完成
|
||||
xhr.onerror = function (evt) { $.messager.alert('提示', '失败!文件内容有误');document.getElementById('drfile').value = ''; }; //请求失败
|
||||
}
|
||||
$('#usertable').datagrid({ url: 'getuser?a=datagrid' });
|
||||
$('#usertable').datagrid({ url: 'getuser?a=datagrid' ,pagination: 'true',
|
||||
pageSize: 20,});
|
||||
$('#parttree').tree({
|
||||
url: 'parthandle?a=tree',
|
||||
animate: true,
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
15_eb5vtB3K7Og4Bc66-8_IKKkVMBCKOiYk4LUkArIek_GirrbQk2BEg2We0WfojPyTLjP14GH4-hzwhEF2i5Mx7G8NGqbeSGWZHI3NiamHgza5JlHs9B4l32EmC6sVPZgAJABVF
|
||||
27_Nrr7EPn934_zjHeLG6DRBRwEXlDbM5bzcILgg4urLbZmI-8pK5wAp9RM_LoeQEhD5TfjTYeqDNuLnclzD32EnEnYaY9kdD2B8F6fnrmt2LTKQ2L6fJwsAen43eF72Q0PsgWWIt_KPtTqrjMrUKAaAGAGWM
|
||||
|
|
@ -157,6 +157,7 @@ urlpatterns = [
|
|||
path('api/obscount',views.observepic),
|
||||
path('api/riskas',views.apiriskas),
|
||||
path('api/trainfg',views.trainfg),
|
||||
# path('api/examtj',views.examtj),
|
||||
path('api/check_session',views.check_session),
|
||||
path('api/equipmentfig',views.equipmentfig),#设备统计图
|
||||
#path('api/rights/group/<int:groupid>',views.rightsgroup),
|
||||
|
|
|
|||
|
|
@ -30,11 +30,12 @@ from .models import CompanyInfo
|
|||
from django.contrib.sessions.models import Session
|
||||
from groups import models as g_models
|
||||
import logging
|
||||
from django.contrib.auth.hashers import make_password, check_password
|
||||
logger = logging.getLogger('log')
|
||||
|
||||
#分页功能
|
||||
def fenye(req):
|
||||
if req.GET.get('page') and req.GET.get('rows'):
|
||||
if req.GET.get('page',None) and req.GET.get('rows',None):
|
||||
page=int(req.GET.get('page'))
|
||||
rows=int(req.GET.get('rows'))
|
||||
endnum=page*rows
|
||||
|
|
@ -66,8 +67,10 @@ def getcompany(x):
|
|||
return str(a.ubelongpart.partid)
|
||||
else:
|
||||
return a.ubelongpart.partlink.split(',')[1]
|
||||
|
||||
def getparts(partid):#获取该部门及下属部门
|
||||
return Partment.objects.filter(Q(partid=partid) | Q(partlink__contains=',' + str(partid) + ','))
|
||||
|
||||
#转换为datagrid所用json
|
||||
def transjson(total, obj):
|
||||
a = {'total':total,'rows':list(obj),'code':1}
|
||||
|
|
@ -75,6 +78,7 @@ def transjson(total, obj):
|
|||
return jsondata
|
||||
def transjson2(v):
|
||||
return json.dumps(list(v), cls=DjangoJSONEncoder)
|
||||
|
||||
#转换为combobox所用string
|
||||
def transstr(obj,str1,str2):
|
||||
keylist = []
|
||||
|
|
@ -84,206 +88,22 @@ def transstr(obj,str1,str2):
|
|||
keystr = '['+','.join(keylist)+']'
|
||||
return keystr
|
||||
|
||||
#html页面
|
||||
def riskas(req):
|
||||
return render(req,'riskas.html')
|
||||
def reportedit(req):
|
||||
return render(req,'reportedit.html',{'year':req.GET.get('year'),'month':req.GET.get('month'),'part':req.GET.get('part')})
|
||||
def riskedit(req,id):
|
||||
return render(req,'riskedit.html',{'id':id})
|
||||
def riskcheck(req):#风险点排查记录
|
||||
return render(req,'riskactcheck.html')
|
||||
def taskdo(req):
|
||||
return render(req,'taskdo.html')
|
||||
def task(req):
|
||||
return render(req,'task.html')
|
||||
def riskactchose(req):
|
||||
area = 0
|
||||
if req.GET.get('area',None):
|
||||
area = req.GET.get('area')
|
||||
return render(req,'riskactchose.html',locals())
|
||||
def riskactedit(req,id):
|
||||
return render(req,'riskactedit.html',{'id':id})
|
||||
def riskactadd(req):
|
||||
return render(req,'riskactadd.html')
|
||||
def riskadd(req,id):
|
||||
return render(req,'riskadd.html',{'id':id})
|
||||
def risk(req):
|
||||
return render(req,'risk.html')
|
||||
def inspect(req):
|
||||
return render(req,'inspect.html')
|
||||
def equipment(req):
|
||||
return render(req,'equipment.html')
|
||||
def areaedit(req,id):
|
||||
return render(req,'areaedit.html',{'id':id})
|
||||
def areaadd(req):
|
||||
return render(req,'areaadd.html')
|
||||
def areadetail(req):
|
||||
id = req.GET.get('id')
|
||||
return render(req,'areadetail.html',{'id':id})
|
||||
def mapshow(req):
|
||||
return render(req,'mapshow.html')
|
||||
def area(req):
|
||||
return render(req,'area.html')
|
||||
def personaltrain(req):
|
||||
return render(req,'personaltrain.html')
|
||||
def examtest(req):
|
||||
return render(req,'examtest.html')
|
||||
def safecert(req):
|
||||
return render(req,'safecert.html')
|
||||
def safecertadd(req):
|
||||
return render(req,'safecertadd.html')
|
||||
def examtestdetail(req,id):
|
||||
return render(req,'examtestdetail.html',{'id':id})
|
||||
def examtestadd(req):
|
||||
return render(req,'examtestadd.html')
|
||||
def examtestadd2(req):
|
||||
return render(req,'examtestadd2.html')
|
||||
def questionchoose(req):
|
||||
return render(req,'questionchoose.html')
|
||||
def exampaperedit(req,id):
|
||||
return render(req,'exampaperedit.html',{'id':id})
|
||||
def exampaperadd(req):
|
||||
return render(req,'exampaperadd.html')
|
||||
def exampaper(req):
|
||||
return render(req,'exampaper.html')
|
||||
def examhistory(req,id):
|
||||
return render(req,'examhistory.html',{'id':id})
|
||||
def questionadd(req):
|
||||
return render(req,'questionadd.html')
|
||||
def questionadd2(req):
|
||||
return render(req,'questionadd2.html')
|
||||
def questionadd3(req):
|
||||
return render(req,'questionadd3.html')
|
||||
def questionedit(req,id):
|
||||
obj = Question.objects.get(id=id)
|
||||
if obj.type==1:
|
||||
return render(req,'questionedit.html',{'id':id})
|
||||
elif obj.type==2:
|
||||
return render(req,'questionedit2.html',{'id':id})
|
||||
elif obj.type==3:
|
||||
return render(req,'questionedit3.html',{'id':id})
|
||||
def question(req):
|
||||
return render(req,'question.html')
|
||||
def questioncatadd(req):
|
||||
return render(req,'questioncatadd.html')
|
||||
def questioncatedit(req,id):
|
||||
return render(req,'questioncatedit.html',{'id':id})
|
||||
def operationspjdadd(req):
|
||||
return render(req,'operationspjdadd.html')
|
||||
def fxcsadd(req):
|
||||
return render(req,'fxcsadd.html')
|
||||
def operationadd(req,zyid):
|
||||
return render(req,'operationadd.html',{'zyid':zyid})
|
||||
def operationdetail(req,zyid):
|
||||
return render(req,'operationdetail.html',{'zyid':zyid})
|
||||
def operation(req):
|
||||
return render(req,'operation.html')
|
||||
def zuoyepeizhi(req):
|
||||
return render(req,'zuoyepeizhi.html')
|
||||
def notice(req):
|
||||
return render(req,'notice.html')
|
||||
def noticeadd(req):
|
||||
return render(req,'noticeadd.html')
|
||||
def noticedetail(req,id):
|
||||
return render(req,'noticedetail.html',{'id':id})
|
||||
def noticeedit(req,id):
|
||||
return render(req,'noticeedit.html',{'id':id})
|
||||
def suggestupdate(req,jyid):
|
||||
return render(req,'suggestupdate.html',{'jyid':jyid})
|
||||
def suggestdetail(req,jyid):
|
||||
return render(req,'suggestdetail.html',{'jyid':jyid})
|
||||
def suggestadd(req):
|
||||
return render(req,'suggestadd.html')
|
||||
def suggest(req):
|
||||
return render(req,'suggest.html')
|
||||
def medetail(req):
|
||||
return render(req,'medetail.html')
|
||||
def socerthtml(req):
|
||||
return render(req,'socert.html')
|
||||
def socertadd(req):
|
||||
return render(req,'socertadd.html')
|
||||
def rightshtml(req):
|
||||
groupid = req.GET.get('groupid')
|
||||
return render(req,'rights.html',{'groupid':groupid})
|
||||
def misshtml(req):
|
||||
return render(req,'miss.html')
|
||||
def missadd(req):
|
||||
return render(req,'missadd.html')
|
||||
def missdetail(req,missid):
|
||||
return render(req,'missdetail.html',{'missid':missid})
|
||||
def troublehtml(req):
|
||||
return render(req,'trouble.html')
|
||||
def observehtml(req):
|
||||
return render(req,'observe.html')
|
||||
def addobserve(req):
|
||||
return render(req,'addobserve.html')
|
||||
def accesstrouble(req):
|
||||
return render(req,'accesstrouble.html')
|
||||
def addtrouble(req):
|
||||
return render(req,'addtrouble.html')
|
||||
def dichtml(req):
|
||||
return render(req,'dichtml.html')
|
||||
def putreehtml(req):
|
||||
return render(req,'putree.html')
|
||||
def usergroup(req):
|
||||
return render(req,'usergroup.html')
|
||||
def getuserf(req):
|
||||
return render(req,'getuser.html')
|
||||
def getusersf(req):
|
||||
return render(req,'getusers.html')
|
||||
def trainhtml(req):
|
||||
return render(req,'train.html')
|
||||
def abtrain(req):
|
||||
return render(req,'abtrain.html')
|
||||
def drillhtml(req):
|
||||
return render(req,'drill.html')
|
||||
def abdrill(req):
|
||||
return render(req,'abdrill.html')
|
||||
def reporthtml(req):
|
||||
return render(req,'report.html')
|
||||
def troubleashtml(req):
|
||||
return render(req,'troubleashtml.html')
|
||||
def userhtml(req):
|
||||
return render(req,'userhtml.html')
|
||||
def bhrhtml(req):
|
||||
return render(req,'behavior.html')
|
||||
def trainfigure(req):
|
||||
return render(req,'trainfigure.html')
|
||||
def equipmentfigure(req):
|
||||
return render(req,'equipmentfigure.html')
|
||||
|
||||
|
||||
def check_login(func):
|
||||
def warpper(request,*args,**kwargs):
|
||||
is_login = request.session.get('userid', None)
|
||||
if is_login:
|
||||
return func(request,*args,**kwargs)
|
||||
else:
|
||||
return HttpResponse(status=405)
|
||||
# try:
|
||||
# auth = request.META.get('HTTP_AUTHORIZATION').split()
|
||||
# # 用户通过 API 获取数据验证流程
|
||||
# if auth[0].lower() == 'token':
|
||||
# try:
|
||||
# dict = jwt.decode(auth[1], 'safeyun', algorithms=['HS256'])
|
||||
# userid = dict.get('data').get('userid')
|
||||
# except jwt.ExpiredSignatureError:
|
||||
# return JsonResponse({"status_code": 401, "message": "Token expired"})
|
||||
# except jwt.InvalidTokenError:
|
||||
# return JsonResponse({"status_code": 401, "message": "Invalid token"})
|
||||
# except Exception as e:
|
||||
# return JsonResponse({"status_code": 401, "message": "Can not get user object"})
|
||||
# try:
|
||||
# user = User.objects.get(userid=userid)
|
||||
# except user.DoesNotExist:
|
||||
# return JsonResponse({"status_code": 401, "message": "User Does not exist"})
|
||||
# else:
|
||||
# return JsonResponse({"status_code": 401, "message": "Not support auth type"})
|
||||
# except AttributeError:
|
||||
# return JsonResponse({"code": 401, "message": "No authenticate header"})
|
||||
# except:
|
||||
# return JsonResponse({"code": 401, "message": "please login!"})
|
||||
return redirect('login')
|
||||
return warpper
|
||||
|
||||
def apicheck_login(func):
|
||||
def warpper(request,*args,**kwargs):
|
||||
is_login = request.session.get('userid', None)
|
||||
if is_login:
|
||||
return func(request,*args,**kwargs)
|
||||
else:
|
||||
return JsonResponse({'code':0,'msg':'login required'})
|
||||
return warpper
|
||||
|
||||
def check_session(req):
|
||||
|
|
@ -291,6 +111,7 @@ def check_session(req):
|
|||
return JsonResponse({"code":1})
|
||||
else:
|
||||
return JsonResponse({"code":0})
|
||||
|
||||
#存储文件
|
||||
def upfile(req):
|
||||
username = User.objects.get(userid=req.session['userid']).username
|
||||
|
|
@ -304,71 +125,252 @@ def upfile(req):
|
|||
f.write(req.FILES['upfile'].read())
|
||||
return JsonResponse({"code":1,"filename":file_name,"filepath":filepath})
|
||||
|
||||
def login(req):
|
||||
if req.session.get('userid', None):
|
||||
return redirect('index')
|
||||
|
||||
if req.method == 'POST':
|
||||
user_form = UserForm(req.POST)
|
||||
username = req.POST.get('username')
|
||||
password = req.POST.get('password')
|
||||
user = User.objects.filter(username__exact = username, password__exact = password,deletemark=1)
|
||||
if user:
|
||||
if user_form.is_valid():
|
||||
# 比较成功,跳转index
|
||||
req.session['userid'] = user[0].userid
|
||||
# req.session.set_expiry(60*30)
|
||||
return redirect('index')
|
||||
else:
|
||||
msg = '验证码错误'
|
||||
return render(req, 'login.html', locals())
|
||||
else:
|
||||
msg = '用户名或密码错误'
|
||||
return render(req,'login.html', locals())
|
||||
else:
|
||||
user_form = UserForm()
|
||||
return render(req,'login.html', locals())
|
||||
|
||||
|
||||
def index(req):
|
||||
if not req.session.get('userid', None):
|
||||
return redirect('login')
|
||||
userid = req.session['userid']
|
||||
user=User.objects.get(userid=userid)
|
||||
companyname = user.usecomp.partname
|
||||
name = user.name
|
||||
openid=user.openid
|
||||
headimgurl=user.headimgurl
|
||||
nickname=user.nickname
|
||||
issuper = user.issuper
|
||||
return render(req, 'index.html',{'username':name,'userid':userid,'openid':openid,'headimgurl':headimgurl,'nickname':nickname,'companyname':companyname,'issuper':issuper,'token':user.token})
|
||||
|
||||
def logout(req):
|
||||
#清理cookie里保存username
|
||||
#del req.session['username']
|
||||
# if "userid" in req.session:
|
||||
# del req.session['userid']
|
||||
logger.info('method: %s user: %s 登出' % (req.method,req.session['userid']))
|
||||
req.session.flush()
|
||||
#req.session.flush()
|
||||
#req.session.delete("session_key")
|
||||
return render(req,'login.html')
|
||||
|
||||
#html页面
|
||||
@check_login
|
||||
def changepwd(req):
|
||||
#if 'userid' in req.session:
|
||||
userid = req.session['userid']
|
||||
oldpassword = req.POST.get('oldpassword')
|
||||
newpassword = req.POST.get('newpassword')
|
||||
a = User.objects.get(userid=userid)
|
||||
if a.password == oldpassword:
|
||||
a.password = newpassword
|
||||
a.save()
|
||||
del req.session['userid']
|
||||
return JsonResponse({"code":1})
|
||||
else:
|
||||
return JsonResponse({"code":2})
|
||||
|
||||
def riskas(req):
|
||||
return render(req,'riskas.html')
|
||||
@check_login
|
||||
def reportedit(req):
|
||||
return render(req,'reportedit.html',{'year':req.GET.get('year'),'month':req.GET.get('month'),'part':req.GET.get('part')})
|
||||
@check_login
|
||||
def riskedit(req,id):
|
||||
return render(req,'riskedit.html',{'id':id})
|
||||
@check_login
|
||||
def riskcheck(req):#风险点排查记录
|
||||
return render(req,'riskactcheck.html')
|
||||
@check_login
|
||||
def taskdo(req):
|
||||
return render(req,'taskdo.html')
|
||||
@check_login
|
||||
def task(req):
|
||||
return render(req,'task.html')
|
||||
@check_login
|
||||
def riskactchose(req):
|
||||
area = 0
|
||||
if req.GET.get('area',None):
|
||||
area = req.GET.get('area')
|
||||
return render(req,'riskactchose.html',locals())
|
||||
@check_login
|
||||
def riskactedit(req,id):
|
||||
return render(req,'riskactedit.html',{'id':id})
|
||||
@check_login
|
||||
def riskactadd(req):
|
||||
return render(req,'riskactadd.html')
|
||||
@check_login
|
||||
def riskadd(req,id):
|
||||
return render(req,'riskadd.html',{'id':id})
|
||||
@check_login
|
||||
def risk(req):
|
||||
return render(req,'risk.html')
|
||||
@check_login
|
||||
def inspect(req):
|
||||
return render(req,'inspect.html')
|
||||
@check_login
|
||||
def equipment(req):
|
||||
return render(req,'equipment.html')
|
||||
@check_login
|
||||
def areaedit(req,id):
|
||||
return render(req,'areaedit.html',{'id':id})
|
||||
@check_login
|
||||
def areaadd(req):
|
||||
return render(req,'areaadd.html')
|
||||
@check_login
|
||||
def areadetail(req):
|
||||
id = req.GET.get('id')
|
||||
return render(req,'areadetail.html',{'id':id})
|
||||
@check_login
|
||||
def mapshow(req):
|
||||
return render(req,'mapshow.html')
|
||||
@check_login
|
||||
def area(req):
|
||||
return render(req,'area.html')
|
||||
@check_login
|
||||
def personaltrain(req):
|
||||
return render(req,'personaltrain.html')
|
||||
@check_login
|
||||
def examtest(req):
|
||||
return render(req,'examtest.html')
|
||||
@check_login
|
||||
def safecert(req):
|
||||
return render(req,'safecert.html')
|
||||
@check_login
|
||||
def safecertadd(req):
|
||||
return render(req,'safecertadd.html')
|
||||
@check_login
|
||||
def examtestdetail(req,id):
|
||||
return render(req,'examtestdetail.html',{'id':id})
|
||||
@check_login
|
||||
def examtestadd(req):
|
||||
return render(req,'examtestadd.html')
|
||||
@check_login
|
||||
def examtestadd2(req):
|
||||
return render(req,'examtestadd2.html')
|
||||
@check_login
|
||||
def questionchoose(req):
|
||||
return render(req,'questionchoose.html')
|
||||
@check_login
|
||||
def exampaperedit(req,id):
|
||||
return render(req,'exampaperedit.html',{'id':id})
|
||||
@check_login
|
||||
def exampaperadd(req):
|
||||
return render(req,'exampaperadd.html')
|
||||
@check_login
|
||||
def exampaper(req):
|
||||
return render(req,'exampaper.html')
|
||||
@check_login
|
||||
def examhistory(req,id):
|
||||
return render(req,'examhistory.html',{'id':id})
|
||||
@check_login
|
||||
def questionadd(req):
|
||||
return render(req,'questionadd.html')
|
||||
@check_login
|
||||
def questionadd2(req):
|
||||
return render(req,'questionadd2.html')
|
||||
@check_login
|
||||
def questionadd3(req):
|
||||
return render(req,'questionadd3.html')
|
||||
@check_login
|
||||
def questionedit(req,id):
|
||||
obj = Question.objects.get(id=id)
|
||||
if obj.type==1:
|
||||
return render(req,'questionedit.html',{'id':id})
|
||||
elif obj.type==2:
|
||||
return render(req,'questionedit2.html',{'id':id})
|
||||
elif obj.type==3:
|
||||
return render(req,'questionedit3.html',{'id':id})
|
||||
@check_login
|
||||
def question(req):
|
||||
return render(req,'question.html')
|
||||
@check_login
|
||||
def questioncatadd(req):
|
||||
return render(req,'questioncatadd.html')
|
||||
@check_login
|
||||
def questioncatedit(req,id):
|
||||
return render(req,'questioncatedit.html',{'id':id})
|
||||
@check_login
|
||||
def operationspjdadd(req):
|
||||
return render(req,'operationspjdadd.html')
|
||||
@check_login
|
||||
def fxcsadd(req):
|
||||
return render(req,'fxcsadd.html')
|
||||
@check_login
|
||||
def operationadd(req,zyid):
|
||||
return render(req,'operationadd.html',{'zyid':zyid})
|
||||
@check_login
|
||||
def operationdetail(req,zyid):
|
||||
return render(req,'operationdetail.html',{'zyid':zyid})
|
||||
@check_login
|
||||
def operation(req):
|
||||
return render(req,'operation.html')
|
||||
@check_login
|
||||
def zuoyepeizhi(req):
|
||||
return render(req,'zuoyepeizhi.html')
|
||||
@check_login
|
||||
def notice(req):
|
||||
return render(req,'notice.html')
|
||||
@check_login
|
||||
def noticeadd(req):
|
||||
return render(req,'noticeadd.html')
|
||||
@check_login
|
||||
def noticedetail(req,id):
|
||||
return render(req,'noticedetail.html',{'id':id})
|
||||
@check_login
|
||||
def noticeedit(req,id):
|
||||
return render(req,'noticeedit.html',{'id':id})
|
||||
@check_login
|
||||
def suggestupdate(req,jyid):
|
||||
return render(req,'suggestupdate.html',{'jyid':jyid})
|
||||
@check_login
|
||||
def suggestdetail(req,jyid):
|
||||
return render(req,'suggestdetail.html',{'jyid':jyid})
|
||||
@check_login
|
||||
def suggestadd(req):
|
||||
return render(req,'suggestadd.html')
|
||||
@check_login
|
||||
def suggest(req):
|
||||
return render(req,'suggest.html')
|
||||
@check_login
|
||||
def medetail(req):
|
||||
return render(req,'medetail.html')
|
||||
@check_login
|
||||
def socerthtml(req):
|
||||
return render(req,'socert.html')
|
||||
@check_login
|
||||
def socertadd(req):
|
||||
return render(req,'socertadd.html')
|
||||
@check_login
|
||||
def rightshtml(req):
|
||||
groupid = req.GET.get('groupid')
|
||||
return render(req,'rights.html',{'groupid':groupid})
|
||||
@check_login
|
||||
def misshtml(req):
|
||||
return render(req,'miss.html')
|
||||
@check_login
|
||||
def missadd(req):
|
||||
return render(req,'missadd.html')
|
||||
@check_login
|
||||
def missdetail(req,missid):
|
||||
return render(req,'missdetail.html',{'missid':missid})
|
||||
@check_login
|
||||
def troublehtml(req):
|
||||
return render(req,'trouble.html')
|
||||
@check_login
|
||||
def observehtml(req):
|
||||
return render(req,'observe.html')
|
||||
@check_login
|
||||
def addobserve(req):
|
||||
return render(req,'addobserve.html')
|
||||
@check_login
|
||||
def accesstrouble(req):
|
||||
return render(req,'accesstrouble.html')
|
||||
@check_login
|
||||
def addtrouble(req):
|
||||
return render(req,'addtrouble.html')
|
||||
@check_login
|
||||
def dichtml(req):
|
||||
return render(req,'dichtml.html')
|
||||
@check_login
|
||||
def putreehtml(req):
|
||||
return render(req,'putree.html')
|
||||
@check_login
|
||||
def usergroup(req):
|
||||
return render(req,'usergroup.html')
|
||||
@check_login
|
||||
def getuserf(req):
|
||||
return render(req,'getuser.html')
|
||||
@check_login
|
||||
def getusersf(req):
|
||||
return render(req,'getusers.html')
|
||||
@check_login
|
||||
def trainhtml(req):
|
||||
return render(req,'train.html')
|
||||
@check_login
|
||||
def abtrain(req):
|
||||
return render(req,'abtrain.html')
|
||||
@check_login
|
||||
def drillhtml(req):
|
||||
return render(req,'drill.html')
|
||||
@check_login
|
||||
def abdrill(req):
|
||||
return render(req,'abdrill.html')
|
||||
@check_login
|
||||
def reporthtml(req):
|
||||
return render(req,'report.html')
|
||||
@check_login
|
||||
def troubleashtml(req):
|
||||
return render(req,'troubleashtml.html')
|
||||
@check_login
|
||||
def userhtml(req):
|
||||
return render(req,'userhtml.html')
|
||||
@check_login
|
||||
def bhrhtml(req):
|
||||
return render(req,'behavior.html')
|
||||
@check_login
|
||||
def trainfigure(req):
|
||||
return render(req,'trainfigure.html')
|
||||
@check_login
|
||||
def equipmentfigure(req):
|
||||
return render(req,'equipmentfigure.html')
|
||||
@check_login
|
||||
def mainhtml(req):
|
||||
#计算一些数据
|
||||
|
|
@ -389,6 +391,64 @@ def mainhtml(req):
|
|||
ylnum =c.filter(state=0,submituser__userid=userid).count()
|
||||
monthyl=c.filter(starttime__range=(first_day, first_day_of_next_month)).count()
|
||||
return render(req,'main.html',{'yhnum':yhnum,'totalyh':totalyh,'monthyh':monthyh,'pxnum':pxnum,'totalpx':totalpx,'monthpx':monthpx,'ylnum':ylnum,'totalyl':totalyl,'monthyl':monthyl})
|
||||
def login(req):
|
||||
if req.session.get('userid', None):
|
||||
return redirect('index')
|
||||
if req.method == 'POST':
|
||||
user_form = UserForm(req.POST)
|
||||
if user_form.is_valid():
|
||||
username = req.POST.get('username')
|
||||
password = req.POST.get('password')
|
||||
user = User.objects.filter(username = username,deletemark=1)
|
||||
if user.exists():
|
||||
if check_password(password,user[0].epassword):
|
||||
req.session['userid'] = user[0].userid
|
||||
return redirect('index')
|
||||
else:
|
||||
msg = '密码错误'
|
||||
return render(req, 'login.html', locals())
|
||||
else:
|
||||
msg = '用户不存在或被禁用'
|
||||
return render(req,'login.html', locals())
|
||||
else:
|
||||
msg = '验证码错误'
|
||||
return render(req, 'login.html', locals())
|
||||
else:
|
||||
user_form = UserForm()
|
||||
return render(req,'login.html', locals())
|
||||
|
||||
def index(req):
|
||||
if not req.session.get('userid', None):
|
||||
return redirect('login')
|
||||
userid = req.session['userid']
|
||||
user=User.objects.get(userid=userid)
|
||||
companyname = user.usecomp.partname
|
||||
name = user.name
|
||||
openid=user.openid
|
||||
headimgurl=user.headimgurl
|
||||
nickname=user.nickname
|
||||
issuper = user.issuper
|
||||
return render(req, 'index.html',{'username':name,'userid':userid,'openid':openid,'headimgurl':headimgurl,'nickname':nickname,'companyname':companyname,'issuper':issuper,'token':user.token})
|
||||
def logout(req):
|
||||
if req.session.get('userid',None):
|
||||
logger.info('method: %s user: %s 登出' % (req.method,req.session['userid']))
|
||||
req.session.flush()
|
||||
return redirect('login')
|
||||
|
||||
|
||||
def changepwd(req):
|
||||
userid = req.session['userid']
|
||||
oldpassword = req.POST.get('oldpassword')
|
||||
newpassword = req.POST.get('newpassword')
|
||||
a = User.objects.get(userid=userid)
|
||||
if check_password(oldpassword,a.epassword):
|
||||
a.password = newpassword
|
||||
a.epassword = make_password(newpassword)
|
||||
a.save()
|
||||
del req.session['userid']
|
||||
return JsonResponse({"code":1})
|
||||
else:
|
||||
return JsonResponse({"code":2})
|
||||
|
||||
def mainapi(req):
|
||||
#计算一些数据
|
||||
|
|
@ -561,7 +621,7 @@ def getsprs_ubp2(userid,ubp):
|
|||
else:
|
||||
return False
|
||||
|
||||
@check_login
|
||||
|
||||
def menutree(req):
|
||||
userid = req.session['userid']
|
||||
if User.objects.get(userid=userid).issuper == 1:#如果是超管
|
||||
|
|
@ -578,7 +638,7 @@ def menutree(req):
|
|||
menus = Menu.objects.exclude(menuid__in=[11,9]).filter(menuid__in=list(filter(None,list(set(list1)))),deletemark=1).order_by('sortnum').values('menuid','menucode','parentid','url','menuname','icon').distinct()
|
||||
return HttpResponse(json.dumps(list(menus)),content_type="application/json")
|
||||
|
||||
@check_login
|
||||
|
||||
def apirights(req):
|
||||
a = req.GET.get('a')
|
||||
if a=='detail':
|
||||
|
|
@ -636,7 +696,7 @@ def addyh(req):
|
|||
zgms = yhdata['zgms'] if 'zgms' in yhdata else ''
|
||||
sybzt=0
|
||||
if troubleid!='':
|
||||
a=Trouble.objects.get(troubleid=troubleid)
|
||||
a = Trouble.objects.get(troubleid=troubleid)
|
||||
else:
|
||||
a = Trouble()
|
||||
companyid=getcompany(userid)
|
||||
|
|
@ -676,6 +736,9 @@ def addyh(req):
|
|||
a.csqrr = user
|
||||
a.shr = user
|
||||
a.sybzt=0
|
||||
if zgbm and zgr:
|
||||
a.zgbm = Partment.objects.get(partid=zgbm)
|
||||
a.zgr = User.objects.get(userid=zgr)
|
||||
a.save()
|
||||
m=TroubleAccess(troubleid=a,clr=user,yhzt=0,action='新增隐患已整改',result=1)
|
||||
m.save()
|
||||
|
|
@ -1667,7 +1730,7 @@ def troublehandle(req):
|
|||
a = a.filter(Q(zgbm__in=parts) | Q(fxbm__in=parts,zgbm=None))
|
||||
total = a.count()
|
||||
startnum,endnum=fenye(req)
|
||||
obj = a.order_by('-xgsj')[startnum:endnum].values('troubleid','fxr__userid','fxr__name','yhms','yhzt','fxsj','tbsj','yhlb__dickeyname','todouser__name','yhpg__dickeyname','yhnum','yhdj__dickeyname','shresult','zgqx','yhtp','zghtp')
|
||||
obj = a.order_by('-xgsj')[startnum:endnum].values('troubleid','fxr__userid','fxr__name','yhms','yhzt','fxsj','tbsj','yhlb__dickeyname','todouser__name','yhpg__dickeyname','yhnum','yhdj__dickeyname','shresult','zgqx','yhtp','zghtp','todouser__userid')
|
||||
return HttpResponse(transjson(total,obj),content_type="application/json")
|
||||
elif a == 'listarea':
|
||||
userid = req.session['userid']
|
||||
|
|
@ -2190,6 +2253,7 @@ def userhandle(req):
|
|||
a.empid = req.POST.get('empid')
|
||||
a.username=req.POST.get('username')
|
||||
a.password=req.POST.get('password')
|
||||
a.epassword = make_password(req.POST.get('password'))
|
||||
a.ubelongpart=Partment.objects.get(partid=req.POST.get('ubelongpart'))
|
||||
a.save()
|
||||
companyid = getcompany(a.userid)
|
||||
|
|
@ -2213,8 +2277,12 @@ def getuser(req):
|
|||
partid = req.GET.get('partid')
|
||||
parts=Partment.objects.filter(partlink__contains=','+partid+',')|Partment.objects.filter(partid=partid)
|
||||
if req.GET.get('a')=='datagrid':
|
||||
a = User.objects.filter(ubelongpart__in=parts,deletemark=1).exclude(issuper=1).values('userid','empid','name','ubelongpart__partname','ubelongpart__partid','username','openid')
|
||||
a = User.objects.filter(ubelongpart__in=parts,deletemark=1).exclude(issuper=1)
|
||||
total = a.count()
|
||||
if req.GET.get('page',None):
|
||||
startnum,endnum = fenye(req)
|
||||
a = a[startnum:endnum]
|
||||
a = a.values('userid','empid','name','ubelongpart__partname','ubelongpart__partid','username','openid')
|
||||
return HttpResponse(transjson(total,a),content_type="application/json")
|
||||
else:
|
||||
a = User.objects.filter(ubelongpart__in=parts,deletemark=1).exclude(issuper=1).values('userid','name')
|
||||
|
|
@ -2244,8 +2312,10 @@ def getuser(req):
|
|||
keystr=transstr(a,'userid','name')
|
||||
return HttpResponse(keystr,content_type="application/json")
|
||||
else:
|
||||
a=User.objects.filter(ubelongpart__in = parts,deletemark=1).exclude(issuper=1).order_by('userid').values('userid','empid','name','ubelongpart__partname','ubelongpart__partid','username','openid')
|
||||
a=User.objects.filter(ubelongpart__in = parts,deletemark=1).exclude(issuper=1)
|
||||
total = a.count()
|
||||
startnum,endnum = fenye(req)
|
||||
a = a.order_by('userid')[startnum:endnum].values('userid','empid','name','ubelongpart__partname','ubelongpart__partid','username','openid')
|
||||
return HttpResponse(transjson(total,a),content_type="application/json")
|
||||
|
||||
|
||||
|
|
@ -2967,8 +3037,9 @@ def bwlogin2(req):
|
|||
openid = req.POST.get('openid')
|
||||
nickname = req.POST.get('nickname')
|
||||
headimgurl = req.POST.get('headimgurl')
|
||||
user = User.objects.filter(username__exact = username, password__exact = password)
|
||||
if user:
|
||||
user = User.objects.filter(username= username,deletemark=1)
|
||||
if user.exists():
|
||||
if check_password(password,user[0].epassword):
|
||||
mpuser = User.objects.filter(openid=openid).exclude(username = username)
|
||||
if mpuser.exists():
|
||||
return render(req,'bindwechat.html',{'msg':'您的微信已绑定平台下'+mpuser[0].username+'账号,不可重复绑定,请先至pc端解绑!','code':0}) #已绑定其他账号
|
||||
|
|
@ -2982,7 +3053,9 @@ def bwlogin2(req):
|
|||
else:
|
||||
return render(req,'bindwechat.html',{'msg':'该平台账号已绑定昵称为'+user[0].nickname+'的微信,不可重复绑定,请先至pc端解绑!','code':0}) #已绑定其他账号
|
||||
else:
|
||||
return render(req,'bwlogin.html',{'msg':'用户名或密码错误!'})
|
||||
return render(req,'bwlogin.html',{'msg':'密码错误'})
|
||||
else:
|
||||
return render(req,'bwlogin.html',{'msg':'用户不存在或已禁用'})
|
||||
|
||||
def bwlogin(req):
|
||||
if req.method == 'GET':
|
||||
|
|
@ -3008,25 +3081,17 @@ def bwlogin(req):
|
|||
openid = req.POST.get('openid')
|
||||
nickname = req.POST.get('nickname')
|
||||
headimgurl = req.POST.get('headimgurl')
|
||||
user = User.objects.filter(username__exact = username, password__exact = password)
|
||||
if user:
|
||||
# mpuser = User.objects.filter(openid=openid).exclude(username = username)
|
||||
# if mpuser.exists():
|
||||
# return render(req,'bindwechat.html',{'msg':'您的微信已绑定平台下'+mpuser[0].username+'账号,不可重复绑定,请先至pc端解绑!','code':0}) #已绑定其他账号
|
||||
# else:
|
||||
# if user[0].openid == '0' or user[0].openid == None or user[0].openid == '':
|
||||
# user.update(openid=openid,headimgurl=headimgurl,nickname=nickname)
|
||||
# return render(req,'bindwechat.html',{'msg':'绑定成功,请刷新电脑端浏览器!','code':1})
|
||||
# else:
|
||||
user = User.objects.filter(username = username,deletemark=1)
|
||||
if user.exists():
|
||||
if check_password(password,user[0].epassword):
|
||||
User.objects.filter(openid=openid).update(openid=None,headimgurl=None,nickname=None)
|
||||
user.update(openid=openid,headimgurl=headimgurl,nickname=nickname)
|
||||
return render(req,'bindwechat.html',{'msg':'绑定成功,请刷新电脑端浏览器!','code':1})
|
||||
# if user[0].openid == openid:
|
||||
# return render(req,'bindwechat.html',{'msg':'绑定成功,请刷新电脑端浏览器!','code':1})
|
||||
# else:
|
||||
# return render(req,'bindwechat.html',{'msg':'该平台账号已绑定昵称为'+user[0].nickname+'的微信,不可重复绑定,请先至pc端解绑!','code':0}) #已绑定其他账号
|
||||
else:
|
||||
return render(req,'bwlogin.html',{'msg':'用户名或密码错误!'})
|
||||
return render(req,'bwlogin.html',{'msg':'密码错误'})
|
||||
else:
|
||||
return render(req,'bwlogin.html',{'msg':'用户不存在或已禁用'})
|
||||
|
||||
|
||||
|
||||
def unbindwechat(req):
|
||||
|
|
@ -3052,6 +3117,9 @@ def minip_px(req):
|
|||
|
||||
def mplogin(req):
|
||||
res = req.body.decode('utf-8')
|
||||
try:
|
||||
code = req.POST.get('code')
|
||||
except:
|
||||
code = json.loads(res)['code']
|
||||
info = requests.get('https://api.weixin.qq.com/sns/jscode2session?appid=wx5c39b569f01c27db&secret=68762892f8df2b4a0b1940c5250a8dc0&js_code='+code+'&grant_type=authorization_code').content.decode('utf-8')
|
||||
info = json.loads(info)
|
||||
|
|
@ -3062,6 +3130,7 @@ def mplogin(req):
|
|||
userid = a.userid
|
||||
username = a.username
|
||||
req.session['userid'] = userid
|
||||
# print(req.session,req.COOKIES)
|
||||
return JsonResponse({"code":1,'userid':userid,'username':username,'mpopenid':mpopenid})
|
||||
else:
|
||||
return JsonResponse({"code":0,'mpopenid':mpopenid})
|
||||
|
|
@ -3071,12 +3140,16 @@ def bindmp(req):
|
|||
password = req.POST.get('password')
|
||||
mpopenid = req.POST.get('mpopenid')
|
||||
#print(username,password,mpopenid)
|
||||
user = User.objects.filter(username__exact = username, password__exact = password)
|
||||
if user:
|
||||
user = User.objects.filter(username = username,deletemark=1)
|
||||
if user.exists():
|
||||
if check_password(password,user[0].epassword):
|
||||
user.update(mpopenid=mpopenid)
|
||||
return JsonResponse({"code":1})
|
||||
else:
|
||||
return JsonResponse({"code":0})
|
||||
else:
|
||||
return JsonResponse({"code":0})
|
||||
|
||||
def setup(req):
|
||||
if req.GET.get('a') == 'setuph':
|
||||
userid = req.session['userid']
|
||||
|
|
@ -3120,7 +3193,9 @@ def importusers(req):
|
|||
drusers(companyid)
|
||||
return JsonResponse({"code":1})
|
||||
|
||||
@apicheck_login
|
||||
def apicompany(req):
|
||||
if int(request.session.get('userid'))==8:
|
||||
a = req.GET.get('a')
|
||||
menurights = '11,1,2,3,4,5,6,7,8,9,10,12,13,15,16,17,18,19,20,21,22,23,24,28,29,32,36,46,47,48,50'#菜单编码
|
||||
if a=='add':
|
||||
|
|
@ -3137,7 +3212,8 @@ def apicompany(req):
|
|||
x = User()
|
||||
x.username = admin
|
||||
x.name = '超级管理员'
|
||||
x.password = '0000'
|
||||
x.password = 'Aq123456'
|
||||
x.epassword = make_password('Aq123456')
|
||||
x.issuper = 1
|
||||
x.ubelongpart = y
|
||||
x.usecomp = y
|
||||
|
|
@ -3154,6 +3230,8 @@ def apicompany(req):
|
|||
Yjsetup.objects.create(monthyhavg=100,safev=50,warnv=75,alertv=100,maxv=200,yhpgqz=4,yhdjqz=4,yhsblqz=1,yhzglqz=4,pxdjqz=3,pxxgqz=4,yldjqz=3,ylxgqz=3,usecomp=y)
|
||||
Map.objects.create(name='默认地图',pic='/static/safesite/mystatic/images/snc.jpg',usecomp=y,default=1)
|
||||
return JsonResponse({'code':1,'companyid':y.partid})
|
||||
else:
|
||||
return JsonResponse({'code':0,'msg':'no right!'})
|
||||
|
||||
def drapi(req):
|
||||
a = req.GET.get('a')
|
||||
|
|
@ -3691,7 +3769,7 @@ def apiuser(req):
|
|||
nowuserid = req.GET.get('userid')
|
||||
a = User.objects.get(userid=userid)
|
||||
if a.issuper==1:
|
||||
User.objects.filter(userid=nowuserid).update(password='0000')
|
||||
User.objects.filter(userid=nowuserid).update(password='0000',epassword=make_password('0000'))
|
||||
return JsonResponse({"code":1})
|
||||
else:
|
||||
return JsonResponse({"code":0})
|
||||
|
|
@ -4076,6 +4154,11 @@ def apitool(req):
|
|||
if create:
|
||||
print(i.partname+'---加入supergroup')
|
||||
return JsonResponse({"code":1})
|
||||
elif a == 'correct_password':
|
||||
for i in User.objects.filter(epassword=None):
|
||||
i.epassword = make_password(i.password)
|
||||
i.save()
|
||||
return JsonResponse({"code":1})
|
||||
|
||||
|
||||
|
||||
|
|
@ -4310,6 +4393,7 @@ def apioperation(req):
|
|||
postdict={
|
||||
'touser':'',
|
||||
'template_id':'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
|
||||
"miniprogram":{"appid":"wx5c39b569f01c27db"},
|
||||
'data':{
|
||||
'first':{
|
||||
'value':obj.zylx.dickeyname + '作业通知:'
|
||||
|
|
@ -4336,6 +4420,10 @@ def apioperation(req):
|
|||
a = Operation.objects.filter(usecomp=usecomp,deletemark=1).order_by('-submittime')
|
||||
if req.GET.get('zyqy',False):
|
||||
a = a.filter(zyqy__id=req.GET.get('zyqy'))
|
||||
if req.GET.get('qssj',None):
|
||||
a = a.filter(kssj__gte = req.GET.get('qssj'))
|
||||
if req.GET.get('jssj',None):
|
||||
a = a.filter(jssj__lte = req.GET.get('jssj'))
|
||||
total = a.count()
|
||||
startnum,endnum=fenye(req)
|
||||
a = a[startnum:endnum].values('zyid','zylx__dickeyname','zynum','zyfzr__name','zynr','zyzt','submittime','todouser__name')
|
||||
|
|
@ -4415,6 +4503,7 @@ def apioperation(req):
|
|||
postdict={
|
||||
'touser':'',
|
||||
'template_id':User.objects.get(userid=i).openid,
|
||||
"miniprogram":{"appid":"wx5c39b569f01c27db"},
|
||||
'data':{
|
||||
'first':{
|
||||
'value':obj.zylx.dickeyname + '作业审批:'
|
||||
|
|
@ -4444,7 +4533,7 @@ def apioperation(req):
|
|||
oldjdmc = obj.zyzt['jdmc']
|
||||
nextindex = obj.zyzt['index']+1
|
||||
spruser = User.objects.get(userid=userid)
|
||||
if 'zzsp' in data:
|
||||
if 'zzsp' in data:#关闭审批
|
||||
obj.zyzt['zyzt'] = '待关闭'
|
||||
obj.todouser = obj.zyfzr
|
||||
obj.todousers = None
|
||||
|
|
@ -4453,6 +4542,7 @@ def apioperation(req):
|
|||
postdict={
|
||||
'touser':'',
|
||||
'template_id':obj.zyfzr.openid,
|
||||
"miniprogram":{"appid":"wx5c39b569f01c27db"},
|
||||
'data':{
|
||||
'first':{
|
||||
'value':obj.zylx.dickeyname + '作业审批通过:'
|
||||
|
|
@ -4473,7 +4563,7 @@ def apioperation(req):
|
|||
}
|
||||
send_wechatmsg.delay(postdict)
|
||||
return JsonResponse({"code":1})
|
||||
if 'zjsp' in data:
|
||||
if 'zjsp' in data:#转交审批
|
||||
newsprs = data['newsprs']#新审批人
|
||||
obj.todousers = newsprs
|
||||
obj.save()
|
||||
|
|
@ -4481,6 +4571,7 @@ def apioperation(req):
|
|||
postdict={
|
||||
'touser':'',
|
||||
'template_id':User.objects.get(userid=i).openid,
|
||||
"miniprogram":{"appid":"wx5c39b569f01c27db"},
|
||||
'data':{
|
||||
'first':{
|
||||
'value':obj.zylx.dickeyname + '作业审批:'
|
||||
|
|
@ -4513,6 +4604,7 @@ def apioperation(req):
|
|||
postdict={
|
||||
'touser':'',
|
||||
'template_id':User.objects.get(userid=i).openid,
|
||||
"miniprogram":{"appid":"wx5c39b569f01c27db"},
|
||||
'data':{
|
||||
'first':{
|
||||
'value':obj.zylx.dickeyname + '作业审批:'
|
||||
|
|
@ -4543,6 +4635,7 @@ def apioperation(req):
|
|||
postdict={
|
||||
'touser':'',
|
||||
'template_id':obj.zyfzr.openid,
|
||||
"miniprogram":{"appid":"wx5c39b569f01c27db"},
|
||||
'data':{
|
||||
'first':{
|
||||
'value':obj.zylx.dickeyname + '作业审批通过:'
|
||||
|
|
@ -4596,15 +4689,7 @@ def apioperation(req):
|
|||
return JsonResponse({"code":1})
|
||||
else:
|
||||
return JsonResponse({"code":0})
|
||||
# elif a == 'splcdetail':
|
||||
# zylx = req.GET.get('zylx')
|
||||
# userid = req.session['userid']
|
||||
# company = User.objects.get(userid=userid).usecomp
|
||||
# objs = Operationspjd.objects.get(zylx=Dickey.objects.get(dickeyid=zylx),usecomp=company)
|
||||
# str='作业部门主管——属地部门主管'
|
||||
# for i in objs:
|
||||
# str = str + '——' + i.jdmc
|
||||
# return JsonResponse({"code":1,"splcdetail":str})
|
||||
|
||||
|
||||
def apioperationsetting(req):
|
||||
a = req.GET.get('a')
|
||||
|
|
@ -5355,19 +5440,22 @@ def apiequipment(req):
|
|||
userid = req.session['userid']
|
||||
companyid = getcompany(userid)
|
||||
if a=='listall':
|
||||
a = Equipment.objects.filter(deletemark=1,usecomp__partid=companyid)
|
||||
objs = Equipment.objects.filter(deletemark=1,usecomp__partid=companyid)
|
||||
if req.GET.get('area',False):
|
||||
a = a.filter(area__id=req.GET.get('area'))
|
||||
objs = objs.filter(area__id=req.GET.get('area'))
|
||||
if req.GET.get('cate'):
|
||||
a = a.filter(cate__dickeyid=req.GET.get('cate'))
|
||||
objs = objs.filter(cate__dickeyid=req.GET.get('cate'))
|
||||
if req.GET.get('state'):
|
||||
a = a.filter(state=req.GET.get('state'))
|
||||
objs = objs.filter(state=req.GET.get('state'))
|
||||
if req.GET.get('name'):
|
||||
a = a.filter(name__contains=req.GET.get('name'))
|
||||
total = a.count()
|
||||
objs = objs.filter(name__contains=req.GET.get('name'))
|
||||
if req.GET.get('b',None) == 'exportexcel':
|
||||
res = exportxlsx('equipment',objs)#导出设备列表
|
||||
return res
|
||||
total = objs.count()
|
||||
startnum,endnum=fenye(req)
|
||||
a = a.order_by('num')[startnum:endnum].values('id','num','name','type','oem','udate','place','istz','iskey','state','cate__dickeyname','area__name')
|
||||
return HttpResponse(transjson(total,a),content_type="application/json")
|
||||
objs = objs.order_by('num')[startnum:endnum].values('id','num','name','type','oem','udate','place','istz','iskey','state','cate__dickeyname','area__name')
|
||||
return HttpResponse(transjson(total,objs),content_type="application/json")
|
||||
elif a == 'update':
|
||||
data = json.loads(req.body.decode('utf-8'))
|
||||
id = data['id']
|
||||
|
|
|
|||
|
|
@ -423,7 +423,7 @@ textarea {
|
|||
}
|
||||
|
||||
input[type=text], input[type=password], input[type=email], input[type=url],
|
||||
input[type=number], textarea, select, .vTextField {
|
||||
input[type=number], input[type=tel], textarea, select, .vTextField {
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
padding: 5px 6px;
|
||||
|
|
@ -431,8 +431,8 @@ input[type=number], textarea, select, .vTextField {
|
|||
}
|
||||
|
||||
input[type=text]:focus, input[type=password]:focus, input[type=email]:focus,
|
||||
input[type=url]:focus, input[type=number]:focus, textarea:focus, select:focus,
|
||||
.vTextField:focus {
|
||||
input[type=url]:focus, input[type=number]:focus, input[type=tel]:focus,
|
||||
textarea:focus, select:focus, .vTextField:focus {
|
||||
border-color: #999;
|
||||
}
|
||||
|
||||
|
|
@ -441,6 +441,8 @@ select {
|
|||
}
|
||||
|
||||
select[multiple] {
|
||||
/* Allow HTML size attribute to override the height in the rule above. */
|
||||
height: auto;
|
||||
min-height: 150px;
|
||||
}
|
||||
|
||||
|
|
@ -662,6 +664,11 @@ div.breadcrumbs a:focus, div.breadcrumbs a:hover {
|
|||
|
||||
/* ACTION ICONS */
|
||||
|
||||
.viewlink, .inlineviewlink {
|
||||
padding-left: 16px;
|
||||
background: url(../img/icon-viewlink.svg) 0 1px no-repeat;
|
||||
}
|
||||
|
||||
.addlink {
|
||||
padding-left: 16px;
|
||||
background: url(../img/icon-addlink.svg) 0 1px no-repeat;
|
||||
|
|
@ -822,10 +829,12 @@ table#change-history tbody th {
|
|||
|
||||
#header {
|
||||
width: auto;
|
||||
height: 40px;
|
||||
height: auto;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 10px 40px;
|
||||
background: #417690;
|
||||
line-height: 40px;
|
||||
color: #ffc;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ form .aligned table p {
|
|||
padding-left: 0;
|
||||
}
|
||||
|
||||
fieldset .field-box {
|
||||
fieldset .fieldBox {
|
||||
float: left;
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
|
@ -291,12 +291,29 @@ body.popup .submit-row {
|
|||
color: #fff;
|
||||
}
|
||||
|
||||
.submit-row a.closelink {
|
||||
display: inline-block;
|
||||
background: #bbbbbb;
|
||||
border-radius: 4px;
|
||||
padding: 10px 15px;
|
||||
height: 15px;
|
||||
line-height: 15px;
|
||||
margin: 0 0 0 5px;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.submit-row a.deletelink:focus,
|
||||
.submit-row a.deletelink:hover,
|
||||
.submit-row a.deletelink:active {
|
||||
background: #a41515;
|
||||
}
|
||||
|
||||
.submit-row a.closelink:focus,
|
||||
.submit-row a.closelink:hover,
|
||||
.submit-row a.closelink:active {
|
||||
background: #aaaaaa;
|
||||
}
|
||||
|
||||
/* CUSTOM FORM FIELDS */
|
||||
|
||||
.vSelectMultipleField {
|
||||
|
|
@ -336,7 +353,7 @@ body.popup .submit-row {
|
|||
width: 2.2em;
|
||||
}
|
||||
|
||||
.vTextField {
|
||||
.vTextField, .vUUIDField {
|
||||
width: 20em;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ body.login {
|
|||
|
||||
.login #header {
|
||||
height: auto;
|
||||
padding: 5px 16px;
|
||||
padding: 15px 16px;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.login #header h1 {
|
||||
|
|
|
|||
|
|
@ -38,11 +38,9 @@ input[type="submit"], button {
|
|||
/* Header */
|
||||
|
||||
#header {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 15px 30px;
|
||||
height: auto;
|
||||
line-height: 1;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
#branding h1 {
|
||||
|
|
|
|||
|
|
@ -77,4 +77,8 @@
|
|||
margin-left: 0;
|
||||
margin-right: 15px;
|
||||
}
|
||||
|
||||
[dir="rtl"] .aligned ul {
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ th {
|
|||
margin-right: 1.5em;
|
||||
}
|
||||
|
||||
.addlink, .changelink {
|
||||
.viewlink, .addlink, .changelink {
|
||||
padding-left: 0;
|
||||
padding-right: 16px;
|
||||
background-position: 100% 1px;
|
||||
|
|
@ -170,6 +170,11 @@ form .aligned p.help, form .aligned div.help {
|
|||
clear: right;
|
||||
}
|
||||
|
||||
form .aligned ul {
|
||||
margin-right: 163px;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
form ul.inline li {
|
||||
float: right;
|
||||
padding-right: 0;
|
||||
|
|
@ -180,7 +185,7 @@ input[type=submit].default, .submit-row input.default {
|
|||
float: left;
|
||||
}
|
||||
|
||||
fieldset .field-box {
|
||||
fieldset .fieldBox {
|
||||
float: right;
|
||||
margin-left: 20px;
|
||||
margin-right: 0;
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
Roboto webfont source: https://www.google.com/fonts/specimen/Roboto
|
||||
WOFF files extracted using https://github.com/majodev/google-webfonts-helper
|
||||
Weights used in this project: Light (300), Regular (400), Bold (700)
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,6 +1,6 @@
|
|||
All icons are taken from Font Awesome (http://fontawesome.io/) project.
|
||||
The Font Awesome font is licensed under the SIL OFL 1.1:
|
||||
- http://scripts.sil.org/OFL
|
||||
- https://scripts.sil.org/OFL
|
||||
|
||||
SVG icons source: https://github.com/encharm/Font-Awesome-SVG-PNG
|
||||
Font-Awesome-SVG-PNG is licensed under the MIT license (see file license
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/*global SelectBox, addEvent, gettext, interpolate, quickElement, SelectFilter*/
|
||||
/*global SelectBox, gettext, interpolate, quickElement, SelectFilter*/
|
||||
/*
|
||||
SelectFilter2 - Turns a multiple-select box into a filter interface.
|
||||
|
||||
|
|
@ -118,19 +118,33 @@ Requires jQuery, core.js, and SelectBox.js.
|
|||
}
|
||||
e.preventDefault();
|
||||
};
|
||||
addEvent(choose_all, 'click', function(e) { move_selection(e, this, SelectBox.move_all, field_id + '_from', field_id + '_to'); });
|
||||
addEvent(add_link, 'click', function(e) { move_selection(e, this, SelectBox.move, field_id + '_from', field_id + '_to'); });
|
||||
addEvent(remove_link, 'click', function(e) { move_selection(e, this, SelectBox.move, field_id + '_to', field_id + '_from'); });
|
||||
addEvent(clear_all, 'click', function(e) { move_selection(e, this, SelectBox.move_all, field_id + '_to', field_id + '_from'); });
|
||||
addEvent(filter_input, 'keypress', function(e) { SelectFilter.filter_key_press(e, field_id); });
|
||||
addEvent(filter_input, 'keyup', function(e) { SelectFilter.filter_key_up(e, field_id); });
|
||||
addEvent(filter_input, 'keydown', function(e) { SelectFilter.filter_key_down(e, field_id); });
|
||||
addEvent(selector_div, 'change', function(e) {
|
||||
choose_all.addEventListener('click', function(e) {
|
||||
move_selection(e, this, SelectBox.move_all, field_id + '_from', field_id + '_to');
|
||||
});
|
||||
add_link.addEventListener('click', function(e) {
|
||||
move_selection(e, this, SelectBox.move, field_id + '_from', field_id + '_to');
|
||||
});
|
||||
remove_link.addEventListener('click', function(e) {
|
||||
move_selection(e, this, SelectBox.move, field_id + '_to', field_id + '_from');
|
||||
});
|
||||
clear_all.addEventListener('click', function(e) {
|
||||
move_selection(e, this, SelectBox.move_all, field_id + '_to', field_id + '_from');
|
||||
});
|
||||
filter_input.addEventListener('keypress', function(e) {
|
||||
SelectFilter.filter_key_press(e, field_id);
|
||||
});
|
||||
filter_input.addEventListener('keyup', function(e) {
|
||||
SelectFilter.filter_key_up(e, field_id);
|
||||
});
|
||||
filter_input.addEventListener('keydown', function(e) {
|
||||
SelectFilter.filter_key_down(e, field_id);
|
||||
});
|
||||
selector_div.addEventListener('change', function(e) {
|
||||
if (e.target.tagName === 'SELECT') {
|
||||
SelectFilter.refresh_icons(field_id);
|
||||
}
|
||||
});
|
||||
addEvent(selector_div, 'dblclick', function(e) {
|
||||
selector_div.addEventListener('dblclick', function(e) {
|
||||
if (e.target.tagName === 'OPTION') {
|
||||
if (e.target.closest('select').id === field_id + '_to') {
|
||||
SelectBox.move(field_id + '_to', field_id + '_from');
|
||||
|
|
@ -140,7 +154,9 @@ Requires jQuery, core.js, and SelectBox.js.
|
|||
SelectFilter.refresh_icons(field_id);
|
||||
}
|
||||
});
|
||||
addEvent(findForm(from_box), 'submit', function() { SelectBox.select_all(field_id + '_to'); });
|
||||
findForm(from_box).addEventListener('submit', function() {
|
||||
SelectBox.select_all(field_id + '_to');
|
||||
});
|
||||
SelectBox.init(field_id + '_from');
|
||||
SelectBox.init(field_id + '_to');
|
||||
// Move selected from_box options to to_box
|
||||
|
|
@ -148,15 +164,9 @@ Requires jQuery, core.js, and SelectBox.js.
|
|||
|
||||
if (!is_stacked) {
|
||||
// In horizontal mode, give the same height to the two boxes.
|
||||
var j_from_box = $(from_box);
|
||||
var j_to_box = $(to_box);
|
||||
var resize_filters = function() { j_to_box.height($(filter_p).outerHeight() + j_from_box.outerHeight()); };
|
||||
if (j_from_box.outerHeight() > 0) {
|
||||
resize_filters(); // This fieldset is already open. Resize now.
|
||||
} else {
|
||||
// This fieldset is probably collapsed. Wait for its 'show' event.
|
||||
j_to_box.closest('fieldset').one('show.fieldset', resize_filters);
|
||||
}
|
||||
var j_from_box = $('#' + field_id + '_from');
|
||||
var j_to_box = $('#' + field_id + '_to');
|
||||
j_to_box.height($(filter_p).outerHeight() + j_from_box.outerHeight());
|
||||
}
|
||||
|
||||
// Initial icon refresh
|
||||
|
|
@ -225,7 +235,7 @@ Requires jQuery, core.js, and SelectBox.js.
|
|||
}
|
||||
};
|
||||
|
||||
addEvent(window, 'load', function(e) {
|
||||
window.addEventListener('load', function(e) {
|
||||
$('select.selectfilter, select.selectfilterstacked').each(function() {
|
||||
var $el = $(this),
|
||||
data = $el.data();
|
||||
|
|
|
|||
|
|
@ -71,16 +71,16 @@
|
|||
showClear();
|
||||
}
|
||||
});
|
||||
$(options.allToggle).show().click(function() {
|
||||
$(options.allToggle).show().on('click', function() {
|
||||
checker($(this).prop("checked"));
|
||||
updateCounter();
|
||||
});
|
||||
$("a", options.acrossQuestions).click(function(event) {
|
||||
$("a", options.acrossQuestions).on('click', function(event) {
|
||||
event.preventDefault();
|
||||
$(options.acrossInput).val(1);
|
||||
showClear();
|
||||
});
|
||||
$("a", options.acrossClears).click(function(event) {
|
||||
$("a", options.acrossClears).on('click', function(event) {
|
||||
event.preventDefault();
|
||||
$(options.allToggle).prop("checked", false);
|
||||
clearAcross();
|
||||
|
|
@ -88,7 +88,7 @@
|
|||
updateCounter();
|
||||
});
|
||||
lastChecked = null;
|
||||
$(actionCheckboxes).click(function(event) {
|
||||
$(actionCheckboxes).on('click', function(event) {
|
||||
if (!event) { event = window.event; }
|
||||
var target = event.target ? event.target : event.srcElement;
|
||||
if (lastChecked && $.data(lastChecked) !== $.data(target) && event.shiftKey === true) {
|
||||
|
|
@ -109,15 +109,15 @@
|
|||
lastChecked = target;
|
||||
updateCounter();
|
||||
});
|
||||
$('form#changelist-form table#result_list tr').find('td:gt(0) :input').change(function() {
|
||||
$('form#changelist-form table#result_list tr').on('change', 'td:gt(0) :input', function() {
|
||||
list_editable_changed = true;
|
||||
});
|
||||
$('form#changelist-form button[name="index"]').click(function(event) {
|
||||
$('form#changelist-form button[name="index"]').on('click', function(event) {
|
||||
if (list_editable_changed) {
|
||||
return confirm(gettext("You have unsaved changes on individual editable fields. If you run an action, your unsaved changes will be lost."));
|
||||
}
|
||||
});
|
||||
$('form#changelist-form input[name="_save"]').click(function(event) {
|
||||
$('form#changelist-form input[name="_save"]').on('click', function(event) {
|
||||
var action_changed = false;
|
||||
$('select option:selected', options.actionContainer).each(function() {
|
||||
if ($(this).val()) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
(function(a){var f;a.fn.actions=function(e){var b=a.extend({},a.fn.actions.defaults,e),g=a(this),k=!1,l=function(){a(b.acrossClears).hide();a(b.acrossQuestions).show();a(b.allContainer).hide()},m=function(){a(b.acrossClears).show();a(b.acrossQuestions).hide();a(b.actionContainer).toggleClass(b.selectedClass);a(b.allContainer).show();a(b.counterContainer).hide()},n=function(){a(b.acrossClears).hide();a(b.acrossQuestions).hide();a(b.allContainer).hide();a(b.counterContainer).show()},p=function(){n();
|
||||
a(b.acrossInput).val(0);a(b.actionContainer).removeClass(b.selectedClass)},q=function(c){c?l():n();a(g).prop("checked",c).parent().parent().toggleClass(b.selectedClass,c)},h=function(){var c=a(g).filter(":checked").length,d=a(".action-counter").data("actionsIcnt");a(b.counterContainer).html(interpolate(ngettext("%(sel)s of %(cnt)s selected","%(sel)s of %(cnt)s selected",c),{sel:c,cnt:d},!0));a(b.allToggle).prop("checked",function(){var a;c===g.length?(a=!0,l()):(a=!1,p());return a})};a(b.counterContainer).show();
|
||||
a(this).filter(":checked").each(function(c){a(this).parent().parent().toggleClass(b.selectedClass);h();1===a(b.acrossInput).val()&&m()});a(b.allToggle).show().click(function(){q(a(this).prop("checked"));h()});a("a",b.acrossQuestions).click(function(c){c.preventDefault();a(b.acrossInput).val(1);m()});a("a",b.acrossClears).click(function(c){c.preventDefault();a(b.allToggle).prop("checked",!1);p();q(0);h()});f=null;a(g).click(function(c){c||(c=window.event);var d=c.target?c.target:c.srcElement;if(f&&
|
||||
a.data(f)!==a.data(d)&&!0===c.shiftKey){var e=!1;a(f).prop("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked);a(g).each(function(){if(a.data(this)===a.data(f)||a.data(this)===a.data(d))e=e?!1:!0;e&&a(this).prop("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked)})}a(d).parent().parent().toggleClass(b.selectedClass,d.checked);f=d;h()});a("form#changelist-form table#result_list tr").find("td:gt(0) :input").change(function(){k=!0});a('form#changelist-form button[name="index"]').click(function(a){if(k)return confirm(gettext("You have unsaved changes on individual editable fields. If you run an action, your unsaved changes will be lost."))});
|
||||
a('form#changelist-form input[name="_save"]').click(function(c){var d=!1;a("select option:selected",b.actionContainer).each(function(){a(this).val()&&(d=!0)});if(d)return k?confirm(gettext("You have selected an action, but you haven't saved your changes to individual fields yet. Please click OK to save. You'll need to re-run the action.")):confirm(gettext("You have selected an action, and you haven't made any changes on individual fields. You're probably looking for the Go button rather than the Save button."))})};
|
||||
a.fn.actions.defaults={actionContainer:"div.actions",counterContainer:"span.action-counter",allContainer:"div.actions span.all",acrossInput:"div.actions input.select-across",acrossQuestions:"div.actions span.question",acrossClears:"div.actions span.clear",allToggle:"#action-toggle",selectedClass:"selected"};a(document).ready(function(){var e=a("tr input.action-select");0<e.length&&e.actions()})})(django.jQuery);
|
||||
a(b.acrossInput).val(0);a(b.actionContainer).removeClass(b.selectedClass)},q=function(c){c?l():n();a(g).prop("checked",c).parent().parent().toggleClass(b.selectedClass,c)},h=function(){var c=a(g).filter(":checked").length,d=a(".action-counter").data("actionsIcnt");a(b.counterContainer).html(interpolate(ngettext("%(sel)s of %(cnt)s selected","%(sel)s of %(cnt)s selected",c),{sel:c,cnt:d},!0));a(b.allToggle).prop("checked",function(){if(c===g.length){var a=!0;l()}else a=!1,p();return a})};a(b.counterContainer).show();
|
||||
a(this).filter(":checked").each(function(c){a(this).parent().parent().toggleClass(b.selectedClass);h();1===a(b.acrossInput).val()&&m()});a(b.allToggle).show().on("click",function(){q(a(this).prop("checked"));h()});a("a",b.acrossQuestions).on("click",function(c){c.preventDefault();a(b.acrossInput).val(1);m()});a("a",b.acrossClears).on("click",function(c){c.preventDefault();a(b.allToggle).prop("checked",!1);p();q(0);h()});f=null;a(g).on("click",function(c){c||(c=window.event);var d=c.target?c.target:
|
||||
c.srcElement;if(f&&a.data(f)!==a.data(d)&&!0===c.shiftKey){var e=!1;a(f).prop("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked);a(g).each(function(){if(a.data(this)===a.data(f)||a.data(this)===a.data(d))e=e?!1:!0;e&&a(this).prop("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked)})}a(d).parent().parent().toggleClass(b.selectedClass,d.checked);f=d;h()});a("form#changelist-form table#result_list tr").on("change","td:gt(0) :input",function(){k=!0});
|
||||
a('form#changelist-form button[name="index"]').on("click",function(a){if(k)return confirm(gettext("You have unsaved changes on individual editable fields. If you run an action, your unsaved changes will be lost."))});a('form#changelist-form input[name="_save"]').on("click",function(c){var d=!1;a("select option:selected",b.actionContainer).each(function(){a(this).val()&&(d=!0)});if(d)return k?confirm(gettext("You have selected an action, but you haven't saved your changes to individual fields yet. Please click OK to save. You'll need to re-run the action.")):
|
||||
confirm(gettext("You have selected an action, and you haven't made any changes on individual fields. You're probably looking for the Go button rather than the Save button."))})};a.fn.actions.defaults={actionContainer:"div.actions",counterContainer:"span.action-counter",allContainer:"div.actions span.all",acrossInput:"div.actions input.select-across",acrossQuestions:"div.actions span.question",acrossClears:"div.actions span.clear",allToggle:"#action-toggle",selectedClass:"selected"};a(document).ready(function(){var e=
|
||||
a("tr input.action-select");0<e.length&&e.actions()})})(django.jQuery);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/*global addEvent, Calendar, cancelEventPropagation, findPosX, findPosY, getStyle, get_format, gettext, interpolate, ngettext, quickElement, removeEvent*/
|
||||
/*global Calendar, findPosX, findPosY, getStyle, get_format, gettext, gettext_noop, interpolate, ngettext, quickElement*/
|
||||
// Inserts shortcut buttons after all of the following:
|
||||
// <input type="text" class="vDateField">
|
||||
// <input type="text" class="vTimeField">
|
||||
|
|
@ -8,11 +8,20 @@
|
|||
calendars: [],
|
||||
calendarInputs: [],
|
||||
clockInputs: [],
|
||||
clockHours: {
|
||||
default_: [
|
||||
[gettext_noop('Now'), -1],
|
||||
[gettext_noop('Midnight'), 0],
|
||||
[gettext_noop('6 a.m.'), 6],
|
||||
[gettext_noop('Noon'), 12],
|
||||
[gettext_noop('6 p.m.'), 18]
|
||||
]
|
||||
},
|
||||
dismissClockFunc: [],
|
||||
dismissCalendarFunc: [],
|
||||
calendarDivName1: 'calendarbox', // name of calendar <div> that gets toggled
|
||||
calendarDivName2: 'calendarin', // name of <div> that contains calendar
|
||||
calendarLinkName: 'calendarlink',// name of the link that is used to toggle
|
||||
calendarLinkName: 'calendarlink', // name of the link that is used to toggle
|
||||
clockDivName: 'clockbox', // name of clock <div> that gets toggled
|
||||
clockLinkName: 'clocklink', // name of the link that is used to toggle
|
||||
shortCutsClass: 'datetimeshortcuts', // class of the clock and cal shortcuts
|
||||
|
|
@ -54,7 +63,6 @@
|
|||
},
|
||||
// Add a warning when the time zone in the browser and backend do not match.
|
||||
addTimezoneWarning: function(inp) {
|
||||
var $ = django.jQuery;
|
||||
var warningClass = DateTimeShortcuts.timezoneWarningClass;
|
||||
var timezoneOffset = DateTimeShortcuts.timezoneOffset / 3600;
|
||||
|
||||
|
|
@ -64,7 +72,7 @@
|
|||
}
|
||||
|
||||
// Check if warning is already there.
|
||||
if ($(inp).siblings('.' + warningClass).length) {
|
||||
if (inp.parentNode.querySelectorAll('.' + warningClass).length) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -86,13 +94,11 @@
|
|||
}
|
||||
message = interpolate(message, [timezoneOffset]);
|
||||
|
||||
var $warning = $('<span>');
|
||||
$warning.attr('class', warningClass);
|
||||
$warning.text(message);
|
||||
|
||||
$(inp).parent()
|
||||
.append($('<br>'))
|
||||
.append($warning);
|
||||
var warning = document.createElement('span');
|
||||
warning.className = warningClass;
|
||||
warning.textContent = message;
|
||||
inp.parentNode.appendChild(document.createElement('br'));
|
||||
inp.parentNode.appendChild(warning);
|
||||
},
|
||||
// Add clock widget to a given field
|
||||
addClock: function(inp) {
|
||||
|
|
@ -106,15 +112,15 @@
|
|||
inp.parentNode.insertBefore(shortcuts_span, inp.nextSibling);
|
||||
var now_link = document.createElement('a');
|
||||
now_link.setAttribute('href', "#");
|
||||
now_link.appendChild(document.createTextNode(gettext('Now')));
|
||||
addEvent(now_link, 'click', function(e) {
|
||||
now_link.textContent = gettext('Now');
|
||||
now_link.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
DateTimeShortcuts.handleClockQuicklink(num, -1);
|
||||
});
|
||||
var clock_link = document.createElement('a');
|
||||
clock_link.setAttribute('href', '#');
|
||||
clock_link.id = DateTimeShortcuts.clockLinkName + num;
|
||||
addEvent(clock_link, 'click', function(e) {
|
||||
clock_link.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
// avoid triggering the document click handler to dismiss the clock
|
||||
e.stopPropagation();
|
||||
|
|
@ -152,46 +158,32 @@
|
|||
clock_box.className = 'clockbox module';
|
||||
clock_box.setAttribute('id', DateTimeShortcuts.clockDivName + num);
|
||||
document.body.appendChild(clock_box);
|
||||
addEvent(clock_box, 'click', cancelEventPropagation);
|
||||
clock_box.addEventListener('click', function(e) { e.stopPropagation(); });
|
||||
|
||||
quickElement('h2', clock_box, gettext('Choose a time'));
|
||||
var time_list = quickElement('ul', clock_box);
|
||||
time_list.className = 'timelist';
|
||||
var time_link = quickElement("a", quickElement("li", time_list), gettext("Now"), "href", "#");
|
||||
addEvent(time_link, 'click', function(e) {
|
||||
// The list of choices can be overridden in JavaScript like this:
|
||||
// DateTimeShortcuts.clockHours.name = [['3 a.m.', 3]];
|
||||
// where name is the name attribute of the <input>.
|
||||
var name = typeof DateTimeShortcuts.clockHours[inp.name] === 'undefined' ? 'default_' : inp.name;
|
||||
DateTimeShortcuts.clockHours[name].forEach(function(element) {
|
||||
var time_link = quickElement('a', quickElement('li', time_list), gettext(element[0]), 'href', '#');
|
||||
time_link.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
DateTimeShortcuts.handleClockQuicklink(num, -1);
|
||||
DateTimeShortcuts.handleClockQuicklink(num, element[1]);
|
||||
});
|
||||
time_link = quickElement("a", quickElement("li", time_list), gettext("Midnight"), "href", "#");
|
||||
addEvent(time_link, 'click', function(e) {
|
||||
e.preventDefault();
|
||||
DateTimeShortcuts.handleClockQuicklink(num, 0);
|
||||
});
|
||||
time_link = quickElement("a", quickElement("li", time_list), gettext("6 a.m."), "href", "#");
|
||||
addEvent(time_link, 'click', function(e) {
|
||||
e.preventDefault();
|
||||
DateTimeShortcuts.handleClockQuicklink(num, 6);
|
||||
});
|
||||
time_link = quickElement("a", quickElement("li", time_list), gettext("Noon"), "href", "#");
|
||||
addEvent(time_link, 'click', function(e) {
|
||||
e.preventDefault();
|
||||
DateTimeShortcuts.handleClockQuicklink(num, 12);
|
||||
});
|
||||
time_link = quickElement("a", quickElement("li", time_list), gettext("6 p.m."), "href", "#");
|
||||
addEvent(time_link, 'click', function(e) {
|
||||
e.preventDefault();
|
||||
DateTimeShortcuts.handleClockQuicklink(num, 18);
|
||||
});
|
||||
|
||||
var cancel_p = quickElement('p', clock_box);
|
||||
cancel_p.className = 'calendar-cancel';
|
||||
var cancel_link = quickElement('a', cancel_p, gettext('Cancel'), 'href', '#');
|
||||
addEvent(cancel_link, 'click', function(e) {
|
||||
cancel_link.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
DateTimeShortcuts.dismissClock(num);
|
||||
});
|
||||
|
||||
django.jQuery(document).bind('keyup', function(event) {
|
||||
document.addEventListener('keyup', function(event) {
|
||||
if (event.which === 27) {
|
||||
// ESC key closes popup
|
||||
DateTimeShortcuts.dismissClock(num);
|
||||
|
|
@ -219,11 +211,11 @@
|
|||
|
||||
// Show the clock box
|
||||
clock_box.style.display = 'block';
|
||||
addEvent(document, 'click', DateTimeShortcuts.dismissClockFunc[num]);
|
||||
document.addEventListener('click', DateTimeShortcuts.dismissClockFunc[num]);
|
||||
},
|
||||
dismissClock: function(num) {
|
||||
document.getElementById(DateTimeShortcuts.clockDivName + num).style.display = 'none';
|
||||
removeEvent(document, 'click', DateTimeShortcuts.dismissClockFunc[num]);
|
||||
document.removeEventListener('click', DateTimeShortcuts.dismissClockFunc[num]);
|
||||
},
|
||||
handleClockQuicklink: function(num, val) {
|
||||
var d;
|
||||
|
|
@ -251,14 +243,14 @@
|
|||
var today_link = document.createElement('a');
|
||||
today_link.setAttribute('href', '#');
|
||||
today_link.appendChild(document.createTextNode(gettext('Today')));
|
||||
addEvent(today_link, 'click', function(e) {
|
||||
today_link.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
DateTimeShortcuts.handleCalendarQuickLink(num, 0);
|
||||
});
|
||||
var cal_link = document.createElement('a');
|
||||
cal_link.setAttribute('href', '#');
|
||||
cal_link.id = DateTimeShortcuts.calendarLinkName + num;
|
||||
addEvent(cal_link, 'click', function(e) {
|
||||
cal_link.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
// avoid triggering the document click handler to dismiss the calendar
|
||||
e.stopPropagation();
|
||||
|
|
@ -297,20 +289,20 @@
|
|||
cal_box.className = 'calendarbox module';
|
||||
cal_box.setAttribute('id', DateTimeShortcuts.calendarDivName1 + num);
|
||||
document.body.appendChild(cal_box);
|
||||
addEvent(cal_box, 'click', cancelEventPropagation);
|
||||
cal_box.addEventListener('click', function(e) { e.stopPropagation(); });
|
||||
|
||||
// next-prev links
|
||||
var cal_nav = quickElement('div', cal_box);
|
||||
var cal_nav_prev = quickElement('a', cal_nav, '<', 'href', '#');
|
||||
cal_nav_prev.className = 'calendarnav-previous';
|
||||
addEvent(cal_nav_prev, 'click', function(e) {
|
||||
cal_nav_prev.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
DateTimeShortcuts.drawPrev(num);
|
||||
});
|
||||
|
||||
var cal_nav_next = quickElement('a', cal_nav, '>', 'href', '#');
|
||||
cal_nav_next.className = 'calendarnav-next';
|
||||
addEvent(cal_nav_next, 'click', function(e) {
|
||||
cal_nav_next.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
DateTimeShortcuts.drawNext(num);
|
||||
});
|
||||
|
|
@ -325,19 +317,19 @@
|
|||
var shortcuts = quickElement('div', cal_box);
|
||||
shortcuts.className = 'calendar-shortcuts';
|
||||
var day_link = quickElement('a', shortcuts, gettext('Yesterday'), 'href', '#');
|
||||
addEvent(day_link, 'click', function(e) {
|
||||
day_link.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
DateTimeShortcuts.handleCalendarQuickLink(num, -1);
|
||||
});
|
||||
shortcuts.appendChild(document.createTextNode('\u00A0|\u00A0'));
|
||||
day_link = quickElement('a', shortcuts, gettext('Today'), 'href', '#');
|
||||
addEvent(day_link, 'click', function(e) {
|
||||
day_link.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
DateTimeShortcuts.handleCalendarQuickLink(num, 0);
|
||||
});
|
||||
shortcuts.appendChild(document.createTextNode('\u00A0|\u00A0'));
|
||||
day_link = quickElement('a', shortcuts, gettext('Tomorrow'), 'href', '#');
|
||||
addEvent(day_link, 'click', function(e) {
|
||||
day_link.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
DateTimeShortcuts.handleCalendarQuickLink(num, +1);
|
||||
});
|
||||
|
|
@ -346,11 +338,11 @@
|
|||
var cancel_p = quickElement('p', cal_box);
|
||||
cancel_p.className = 'calendar-cancel';
|
||||
var cancel_link = quickElement('a', cancel_p, gettext('Cancel'), 'href', '#');
|
||||
addEvent(cancel_link, 'click', function(e) {
|
||||
cancel_link.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
DateTimeShortcuts.dismissCalendar(num);
|
||||
});
|
||||
django.jQuery(document).bind('keyup', function(event) {
|
||||
document.addEventListener('keyup', function(event) {
|
||||
if (event.which === 27) {
|
||||
// ESC key closes popup
|
||||
DateTimeShortcuts.dismissCalendar(num);
|
||||
|
|
@ -391,11 +383,11 @@
|
|||
cal_box.style.top = Math.max(0, findPosY(cal_link) - 75) + 'px';
|
||||
|
||||
cal_box.style.display = 'block';
|
||||
addEvent(document, 'click', DateTimeShortcuts.dismissCalendarFunc[num]);
|
||||
document.addEventListener('click', DateTimeShortcuts.dismissCalendarFunc[num]);
|
||||
},
|
||||
dismissCalendar: function(num) {
|
||||
document.getElementById(DateTimeShortcuts.calendarDivName1 + num).style.display = 'none';
|
||||
removeEvent(document, 'click', DateTimeShortcuts.dismissCalendarFunc[num]);
|
||||
document.removeEventListener('click', DateTimeShortcuts.dismissCalendarFunc[num]);
|
||||
},
|
||||
drawPrev: function(num) {
|
||||
DateTimeShortcuts.calendars[num].drawPreviousMonth();
|
||||
|
|
@ -406,11 +398,11 @@
|
|||
handleCalendarCallback: function(num) {
|
||||
var format = get_format('DATE_INPUT_FORMATS')[0];
|
||||
// the format needs to be escaped a little
|
||||
format = format.replace('\\', '\\\\');
|
||||
format = format.replace('\r', '\\r');
|
||||
format = format.replace('\n', '\\n');
|
||||
format = format.replace('\t', '\\t');
|
||||
format = format.replace("'", "\\'");
|
||||
format = format.replace('\\', '\\\\')
|
||||
.replace('\r', '\\r')
|
||||
.replace('\n', '\\n')
|
||||
.replace('\t', '\\t')
|
||||
.replace("'", "\\'");
|
||||
return function(y, m, d) {
|
||||
DateTimeShortcuts.calendarInputs[num].value = new Date(y, m - 1, d).strftime(format);
|
||||
DateTimeShortcuts.calendarInputs[num].focus();
|
||||
|
|
@ -426,6 +418,6 @@
|
|||
}
|
||||
};
|
||||
|
||||
addEvent(window, 'load', DateTimeShortcuts.init);
|
||||
window.addEventListener('load', DateTimeShortcuts.init);
|
||||
window.DateTimeShortcuts = DateTimeShortcuts;
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@
|
|||
|
||||
function updateRelatedObjectLinks(triggeringLink) {
|
||||
var $this = $(triggeringLink);
|
||||
var siblings = $this.nextAll('.change-related, .delete-related');
|
||||
var siblings = $this.nextAll('.view-related, .change-related, .delete-related');
|
||||
if (!siblings.length) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -108,6 +108,12 @@
|
|||
this.value = newId;
|
||||
}
|
||||
});
|
||||
selects.next().find('.select2-selection__rendered').each(function() {
|
||||
// The element can have a clear button as a child.
|
||||
// Use the lastChild to modify only the displayed value.
|
||||
this.lastChild.textContent = newRepr;
|
||||
this.title = newRepr;
|
||||
});
|
||||
win.close();
|
||||
}
|
||||
|
||||
|
|
@ -140,7 +146,7 @@
|
|||
window.dismissAddAnotherPopup = dismissAddRelatedObjectPopup;
|
||||
|
||||
$(document).ready(function() {
|
||||
$("a[data-popup-opener]").click(function(event) {
|
||||
$("a[data-popup-opener]").on('click', function(event) {
|
||||
event.preventDefault();
|
||||
opener.dismissRelatedLookupPopup(window, $(this).data("popup-opener"));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/*global gettext, pgettext, get_format, quickElement, removeChildren, addEvent*/
|
||||
/*global gettext, pgettext, get_format, quickElement, removeChildren*/
|
||||
/*
|
||||
calendar.js - Calendar functions by Adrian Holovaty
|
||||
depends on core.js for utility functions like removeChildren or quickElement
|
||||
|
|
@ -103,7 +103,7 @@ depends on core.js for utility functions like removeChildren or quickElement
|
|||
function calendarMonth(y, m) {
|
||||
function onClick(e) {
|
||||
e.preventDefault();
|
||||
callback(y, m, django.jQuery(this).text());
|
||||
callback(y, m, this.textContent);
|
||||
}
|
||||
return onClick;
|
||||
}
|
||||
|
|
@ -130,7 +130,7 @@ depends on core.js for utility functions like removeChildren or quickElement
|
|||
|
||||
var cell = quickElement('td', tableRow, '', 'class', todayClass);
|
||||
var link = quickElement('a', cell, currentDay, 'href', '#');
|
||||
addEvent(link, 'click', calendarMonth(year, month));
|
||||
link.addEventListener('click', calendarMonth(year, month));
|
||||
currentDay++;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
(function($) {
|
||||
'use strict';
|
||||
$(function() {
|
||||
$('.cancel-link').click(function(e) {
|
||||
$('.cancel-link').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
window.history.back();
|
||||
if (window.location.search.indexOf('&_popup=1') === -1) {
|
||||
window.history.back(); // Go back if not a popup.
|
||||
} else {
|
||||
window.close(); // Otherwise, close the popup.
|
||||
}
|
||||
});
|
||||
});
|
||||
})(django.jQuery);
|
||||
|
|
|
|||
|
|
@ -1,26 +1,55 @@
|
|||
/*global gettext*/
|
||||
(function($) {
|
||||
(function() {
|
||||
'use strict';
|
||||
$(document).ready(function() {
|
||||
// Add anchor tag for Show/Hide link
|
||||
$("fieldset.collapse").each(function(i, elem) {
|
||||
// Don't hide if fields in this fieldset have errors
|
||||
if ($(elem).find("div.errors").length === 0) {
|
||||
$(elem).addClass("collapsed").find("h2").first().append(' (<a id="fieldsetcollapser' +
|
||||
i + '" class="collapse-toggle" href="#">' + gettext("Show") +
|
||||
'</a>)');
|
||||
var closestElem = function(elem, tagName) {
|
||||
if (elem.nodeName === tagName.toUpperCase()) {
|
||||
return elem;
|
||||
}
|
||||
});
|
||||
// Add toggle to anchor tag
|
||||
$("fieldset.collapse a.collapse-toggle").click(function(ev) {
|
||||
if ($(this).closest("fieldset").hasClass("collapsed")) {
|
||||
if (elem.parentNode.nodeName === 'BODY') {
|
||||
return null;
|
||||
}
|
||||
return elem.parentNode && closestElem(elem.parentNode, tagName);
|
||||
};
|
||||
|
||||
window.addEventListener('load', function() {
|
||||
// Add anchor tag for Show/Hide link
|
||||
var fieldsets = document.querySelectorAll('fieldset.collapse');
|
||||
for (var i = 0; i < fieldsets.length; i++) {
|
||||
var elem = fieldsets[i];
|
||||
// Don't hide if fields in this fieldset have errors
|
||||
if (elem.querySelectorAll('div.errors').length === 0) {
|
||||
elem.classList.add('collapsed');
|
||||
var h2 = elem.querySelector('h2');
|
||||
var link = document.createElement('a');
|
||||
link.setAttribute('id', 'fieldsetcollapser' + i);
|
||||
link.setAttribute('class', 'collapse-toggle');
|
||||
link.setAttribute('href', '#');
|
||||
link.textContent = gettext('Show');
|
||||
h2.appendChild(document.createTextNode(' ('));
|
||||
h2.appendChild(link);
|
||||
h2.appendChild(document.createTextNode(')'));
|
||||
}
|
||||
}
|
||||
// Add toggle to hide/show anchor tag
|
||||
var toggleFunc = function(ev) {
|
||||
if (ev.target.matches('.collapse-toggle')) {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
var fieldset = closestElem(ev.target, 'fieldset');
|
||||
if (fieldset.classList.contains('collapsed')) {
|
||||
// Show
|
||||
$(this).text(gettext("Hide")).closest("fieldset").removeClass("collapsed").trigger("show.fieldset", [$(this).attr("id")]);
|
||||
ev.target.textContent = gettext('Hide');
|
||||
fieldset.classList.remove('collapsed');
|
||||
} else {
|
||||
// Hide
|
||||
$(this).text(gettext("Show")).closest("fieldset").addClass("collapsed").trigger("hide.fieldset", [$(this).attr("id")]);
|
||||
ev.target.textContent = gettext('Show');
|
||||
fieldset.classList.add('collapsed');
|
||||
}
|
||||
}
|
||||
};
|
||||
var inlineDivs = document.querySelectorAll('fieldset.module');
|
||||
for (i = 0; i < inlineDivs.length; i++) {
|
||||
inlineDivs[i].addEventListener('click', toggleFunc);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
});
|
||||
})(django.jQuery);
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
(function(a){a(document).ready(function(){a("fieldset.collapse").each(function(b,c){0===a(c).find("div.errors").length&&a(c).addClass("collapsed").find("h2").first().append(' (<a id="fieldsetcollapser'+b+'" class="collapse-toggle" href="#">'+gettext("Show")+"</a>)")});a("fieldset.collapse a.collapse-toggle").click(function(b){a(this).closest("fieldset").hasClass("collapsed")?a(this).text(gettext("Hide")).closest("fieldset").removeClass("collapsed").trigger("show.fieldset",[a(this).attr("id")]):a(this).text(gettext("Show")).closest("fieldset").addClass("collapsed").trigger("hide.fieldset",
|
||||
[a(this).attr("id")]);return!1})})})(django.jQuery);
|
||||
(function(){var e=function(b,a){return b.nodeName===a.toUpperCase()?b:"BODY"===b.parentNode.nodeName?null:b.parentNode&&e(b.parentNode,a)};window.addEventListener("load",function(){for(var b=document.querySelectorAll("fieldset.collapse"),a=0;a<b.length;a++){var c=b[a];if(0===c.querySelectorAll("div.errors").length){c.classList.add("collapsed");c=c.querySelector("h2");var d=document.createElement("a");d.setAttribute("id","fieldsetcollapser"+a);d.setAttribute("class","collapse-toggle");d.setAttribute("href",
|
||||
"#");d.textContent=gettext("Show");c.appendChild(document.createTextNode(" ("));c.appendChild(d);c.appendChild(document.createTextNode(")"))}}b=function(a){if(a.target.matches(".collapse-toggle")){a.preventDefault();a.stopPropagation();var b=e(a.target,"fieldset");b.classList.contains("collapsed")?(a.target.textContent=gettext("Hide"),b.classList.remove("collapsed")):(a.target.textContent=gettext("Show"),b.classList.add("collapsed"))}};c=document.querySelectorAll("fieldset.module");for(a=0;a<c.length;a++)c[a].addEventListener("click",
|
||||
b)})})();
|
||||
|
|
|
|||
|
|
@ -4,44 +4,6 @@
|
|||
var isOpera = (navigator.userAgent.indexOf("Opera") >= 0) && parseFloat(navigator.appVersion);
|
||||
var isIE = ((document.all) && (!isOpera)) && parseFloat(navigator.appVersion.split("MSIE ")[1].split(";")[0]);
|
||||
|
||||
// Cross-browser event handlers.
|
||||
function addEvent(obj, evType, fn) {
|
||||
'use strict';
|
||||
if (obj.addEventListener) {
|
||||
obj.addEventListener(evType, fn, false);
|
||||
return true;
|
||||
} else if (obj.attachEvent) {
|
||||
var r = obj.attachEvent("on" + evType, fn);
|
||||
return r;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function removeEvent(obj, evType, fn) {
|
||||
'use strict';
|
||||
if (obj.removeEventListener) {
|
||||
obj.removeEventListener(evType, fn, false);
|
||||
return true;
|
||||
} else if (obj.detachEvent) {
|
||||
obj.detachEvent("on" + evType, fn);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function cancelEventPropagation(e) {
|
||||
'use strict';
|
||||
if (!e) {
|
||||
e = window.event;
|
||||
}
|
||||
e.cancelBubble = true;
|
||||
if (e.stopPropagation) {
|
||||
e.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
// quickElement(tagType, parentReference [, textInChildNode, attribute, attributeValue ...]);
|
||||
function quickElement() {
|
||||
'use strict';
|
||||
|
|
@ -68,7 +30,7 @@ function removeChildren(a) {
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Find-position functions by PPK
|
||||
// See http://www.quirksmode.org/js/findpos.html
|
||||
// See https://www.quirksmode.org/js/findpos.html
|
||||
// ----------------------------------------------------------------------------
|
||||
function findPosX(obj) {
|
||||
'use strict';
|
||||
|
|
@ -191,9 +153,9 @@ function findPosY(obj) {
|
|||
return result;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// String object extensions
|
||||
// ----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
// String object extensions
|
||||
// ----------------------------------------------------------------------------
|
||||
String.prototype.pad_left = function(pad_length, pad_string) {
|
||||
var new_string = this;
|
||||
for (var i = 0; new_string.length < pad_length; i++) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* and modified for Django by Jannis Leidel, Travis Swicegood and Julien Phalip.
|
||||
*
|
||||
* Licensed under the New BSD License
|
||||
* See: http://www.opensource.org/licenses/bsd-license.php
|
||||
* See: https://opensource.org/licenses/bsd-license.php
|
||||
*/
|
||||
(function($) {
|
||||
'use strict';
|
||||
|
|
@ -58,7 +58,7 @@
|
|||
addButton = $this.filter(":last").next().find("a");
|
||||
}
|
||||
}
|
||||
addButton.click(function(e) {
|
||||
addButton.on('click', function(e) {
|
||||
e.preventDefault();
|
||||
var template = $("#" + options.prefix + "-empty");
|
||||
var row = template.clone(true);
|
||||
|
|
@ -91,7 +91,7 @@
|
|||
addButton.parent().hide();
|
||||
}
|
||||
// The delete button of each row triggers a bunch of other things
|
||||
row.find("a." + options.deleteCssClass).click(function(e1) {
|
||||
row.find("a." + options.deleteCssClass).on('click', function(e1) {
|
||||
e1.preventDefault();
|
||||
// Remove the parent form containing this button:
|
||||
row.remove();
|
||||
|
|
@ -145,10 +145,10 @@
|
|||
|
||||
|
||||
// Tabular inlines ---------------------------------------------------------
|
||||
$.fn.tabularFormset = function(options) {
|
||||
$.fn.tabularFormset = function(selector, options) {
|
||||
var $rows = $(this);
|
||||
var alternatingRows = function(row) {
|
||||
$($rows.selector).not(".add-row").removeClass("row1 row2")
|
||||
$(selector).not(".add-row").removeClass("row1 row2")
|
||||
.filter(":even").addClass("row1").end()
|
||||
.filter(":odd").addClass("row2");
|
||||
};
|
||||
|
|
@ -212,10 +212,10 @@
|
|||
};
|
||||
|
||||
// Stacked inlines ---------------------------------------------------------
|
||||
$.fn.stackedFormset = function(options) {
|
||||
$.fn.stackedFormset = function(selector, options) {
|
||||
var $rows = $(this);
|
||||
var updateInlineLabel = function(row) {
|
||||
$($rows.selector).find(".inline_label").each(function(i) {
|
||||
$(selector).find(".inline_label").each(function(i) {
|
||||
var count = i + 1;
|
||||
$(this).html($(this).html().replace(/(#\d+)/g, "#" + count));
|
||||
});
|
||||
|
|
@ -281,13 +281,16 @@
|
|||
$(document).ready(function() {
|
||||
$(".js-inline-admin-formset").each(function() {
|
||||
var data = $(this).data(),
|
||||
inlineOptions = data.inlineFormset;
|
||||
inlineOptions = data.inlineFormset,
|
||||
selector;
|
||||
switch(data.inlineType) {
|
||||
case "stacked":
|
||||
$(inlineOptions.name + "-group .inline-related").stackedFormset(inlineOptions.options);
|
||||
selector = inlineOptions.name + "-group .inline-related";
|
||||
$(selector).stackedFormset(selector, inlineOptions.options);
|
||||
break;
|
||||
case "tabular":
|
||||
$(inlineOptions.name + "-group .tabular.inline-related tbody tr").tabularFormset(inlineOptions.options);
|
||||
selector = inlineOptions.name + "-group .tabular.inline-related tbody:first > tr";
|
||||
$(selector).tabularFormset(selector, inlineOptions.options);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
(function(c){c.fn.formset=function(b){var a=c.extend({},c.fn.formset.defaults,b),d=c(this);b=d.parent();var k=function(a,g,l){var b=new RegExp("("+g+"-(\\d+|__prefix__))");g=g+"-"+l;c(a).prop("for")&&c(a).prop("for",c(a).prop("for").replace(b,g));a.id&&(a.id=a.id.replace(b,g));a.name&&(a.name=a.name.replace(b,g))},e=c("#id_"+a.prefix+"-TOTAL_FORMS").prop("autocomplete","off"),l=parseInt(e.val(),10),g=c("#id_"+a.prefix+"-MAX_NUM_FORMS").prop("autocomplete","off"),h=""===g.val()||0<g.val()-e.val();
|
||||
d.each(function(g){c(this).not("."+a.emptyCssClass).addClass(a.formCssClass)});if(d.length&&h){var m=a.addButton;null===m&&("TR"===d.prop("tagName")?(d=this.eq(-1).children().length,b.append('<tr class="'+a.addCssClass+'"><td colspan="'+d+'"><a href="#">'+a.addText+"</a></tr>"),m=b.find("tr:last a")):(d.filter(":last").after('<div class="'+a.addCssClass+'"><a href="#">'+a.addText+"</a></div>"),m=d.filter(":last").next().find("a")));m.click(function(b){b.preventDefault();b=c("#"+a.prefix+"-empty");
|
||||
var f=b.clone(!0);f.removeClass(a.emptyCssClass).addClass(a.formCssClass).attr("id",a.prefix+"-"+l);f.is("tr")?f.children(":last").append('<div><a class="'+a.deleteCssClass+'" href="#">'+a.deleteText+"</a></div>"):f.is("ul")||f.is("ol")?f.append('<li><a class="'+a.deleteCssClass+'" href="#">'+a.deleteText+"</a></li>"):f.children(":first").append('<span><a class="'+a.deleteCssClass+'" href="#">'+a.deleteText+"</a></span>");f.find("*").each(function(){k(this,a.prefix,e.val())});f.insertBefore(c(b));
|
||||
c(e).val(parseInt(e.val(),10)+1);l+=1;""!==g.val()&&0>=g.val()-e.val()&&m.parent().hide();f.find("a."+a.deleteCssClass).click(function(b){b.preventDefault();f.remove();--l;a.removed&&a.removed(f);c(document).trigger("formset:removed",[f,a.prefix]);b=c("."+a.formCssClass);c("#id_"+a.prefix+"-TOTAL_FORMS").val(b.length);(""===g.val()||0<g.val()-b.length)&&m.parent().show();var h,d,e=function(){k(this,a.prefix,h)};h=0;for(d=b.length;h<d;h++)k(c(b).get(h),a.prefix,h),c(b.get(h)).find("*").each(e)});a.added&&
|
||||
a.added(f);c(document).trigger("formset:added",[f,a.prefix])})}return this};c.fn.formset.defaults={prefix:"form",addText:"add another",deleteText:"remove",addCssClass:"add-row",deleteCssClass:"delete-row",emptyCssClass:"empty-row",formCssClass:"dynamic-form",added:null,removed:null,addButton:null};c.fn.tabularFormset=function(b){var a=c(this),d=function(b){c(a.selector).not(".add-row").removeClass("row1 row2").filter(":even").addClass("row1").end().filter(":odd").addClass("row2")},k=function(){"undefined"!==
|
||||
typeof SelectFilter&&(c(".selectfilter").each(function(a,c){var b=c.name.split("-");SelectFilter.init(c.id,b[b.length-1],!1)}),c(".selectfilterstacked").each(function(a,c){var b=c.name.split("-");SelectFilter.init(c.id,b[b.length-1],!0)}))},e=function(a){a.find(".prepopulated_field").each(function(){var b=c(this).find("input, select, textarea"),h=b.data("dependency_list")||[],d=[];c.each(h,function(c,b){d.push("#"+a.find(".field-"+b).find("input, select, textarea").attr("id"))});d.length&&b.prepopulate(d,
|
||||
b.attr("maxlength"))})};a.formset({prefix:b.prefix,addText:b.addText,formCssClass:"dynamic-"+b.prefix,deleteCssClass:"inline-deletelink",deleteText:b.deleteText,emptyCssClass:"empty-form",removed:d,added:function(a){e(a);"undefined"!==typeof DateTimeShortcuts&&(c(".datetimeshortcuts").remove(),DateTimeShortcuts.init());k();d(a)},addButton:b.addButton});return a};c.fn.stackedFormset=function(b){var a=c(this),d=function(b){c(a.selector).find(".inline_label").each(function(a){a+=1;c(this).html(c(this).html().replace(/(#\d+)/g,
|
||||
"#"+a))})},k=function(){"undefined"!==typeof SelectFilter&&(c(".selectfilter").each(function(a,c){var b=c.name.split("-");SelectFilter.init(c.id,b[b.length-1],!1)}),c(".selectfilterstacked").each(function(a,c){var b=c.name.split("-");SelectFilter.init(c.id,b[b.length-1],!0)}))},e=function(a){a.find(".prepopulated_field").each(function(){var b=c(this).find("input, select, textarea"),d=b.data("dependency_list")||[],e=[];c.each(d,function(b,c){e.push("#"+a.find(".form-row .field-"+c).find("input, select, textarea").attr("id"))});
|
||||
e.length&&b.prepopulate(e,b.attr("maxlength"))})};a.formset({prefix:b.prefix,addText:b.addText,formCssClass:"dynamic-"+b.prefix,deleteCssClass:"inline-deletelink",deleteText:b.deleteText,emptyCssClass:"empty-form",removed:d,added:function(a){e(a);"undefined"!==typeof DateTimeShortcuts&&(c(".datetimeshortcuts").remove(),DateTimeShortcuts.init());k();d(a)},addButton:b.addButton});return a};c(document).ready(function(){c(".js-inline-admin-formset").each(function(){var b=c(this).data(),a=b.inlineFormset;
|
||||
switch(b.inlineType){case "stacked":c(a.name+"-group .inline-related").stackedFormset(a.options);break;case "tabular":c(a.name+"-group .tabular.inline-related tbody tr").tabularFormset(a.options)}})})})(django.jQuery);
|
||||
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(b,d,a){b instanceof String&&(b=String(b));for(var c=b.length,f=0;f<c;f++){var g=b[f];if(d.call(a,g,f,b))return{i:f,v:g}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(b,d,a){b!=Array.prototype&&b!=Object.prototype&&(b[d]=a.value)};
|
||||
$jscomp.getGlobal=function(b){return"undefined"!=typeof window&&window===b?b:"undefined"!=typeof global&&null!=global?global:b};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(b,d,a,c){if(d){a=$jscomp.global;b=b.split(".");for(c=0;c<b.length-1;c++){var f=b[c];f in a||(a[f]={});a=a[f]}b=b[b.length-1];c=a[b];d=d(c);d!=c&&null!=d&&$jscomp.defineProperty(a,b,{configurable:!0,writable:!0,value:d})}};
|
||||
$jscomp.polyfill("Array.prototype.find",function(b){return b?b:function(b,a){return $jscomp.findInternal(this,b,a).v}},"es6","es3");
|
||||
(function(b){b.fn.formset=function(d){var a=b.extend({},b.fn.formset.defaults,d),c=b(this);d=c.parent();var f=function(a,e,d){var c=new RegExp("("+e+"-(\\d+|__prefix__))");e=e+"-"+d;b(a).prop("for")&&b(a).prop("for",b(a).prop("for").replace(c,e));a.id&&(a.id=a.id.replace(c,e));a.name&&(a.name=a.name.replace(c,e))},g=b("#id_"+a.prefix+"-TOTAL_FORMS").prop("autocomplete","off"),h=parseInt(g.val(),10),e=b("#id_"+a.prefix+"-MAX_NUM_FORMS").prop("autocomplete","off"),m=""===e.val()||0<e.val()-g.val();
|
||||
c.each(function(e){b(this).not("."+a.emptyCssClass).addClass(a.formCssClass)});if(c.length&&m){var l=a.addButton;null===l&&("TR"===c.prop("tagName")?(c=this.eq(-1).children().length,d.append('<tr class="'+a.addCssClass+'"><td colspan="'+c+'"><a href="#">'+a.addText+"</a></tr>"),l=d.find("tr:last a")):(c.filter(":last").after('<div class="'+a.addCssClass+'"><a href="#">'+a.addText+"</a></div>"),l=c.filter(":last").next().find("a")));l.on("click",function(d){d.preventDefault();d=b("#"+a.prefix+"-empty");
|
||||
var c=d.clone(!0);c.removeClass(a.emptyCssClass).addClass(a.formCssClass).attr("id",a.prefix+"-"+h);c.is("tr")?c.children(":last").append('<div><a class="'+a.deleteCssClass+'" href="#">'+a.deleteText+"</a></div>"):c.is("ul")||c.is("ol")?c.append('<li><a class="'+a.deleteCssClass+'" href="#">'+a.deleteText+"</a></li>"):c.children(":first").append('<span><a class="'+a.deleteCssClass+'" href="#">'+a.deleteText+"</a></span>");c.find("*").each(function(){f(this,a.prefix,g.val())});c.insertBefore(b(d));
|
||||
b(g).val(parseInt(g.val(),10)+1);h+=1;""!==e.val()&&0>=e.val()-g.val()&&l.parent().hide();c.find("a."+a.deleteCssClass).on("click",function(d){d.preventDefault();c.remove();--h;a.removed&&a.removed(c);b(document).trigger("formset:removed",[c,a.prefix]);d=b("."+a.formCssClass);b("#id_"+a.prefix+"-TOTAL_FORMS").val(d.length);(""===e.val()||0<e.val()-d.length)&&l.parent().show();var m,g=function(){f(this,a.prefix,k)};var k=0;for(m=d.length;k<m;k++)f(b(d).get(k),a.prefix,k),b(d.get(k)).find("*").each(g)});
|
||||
a.added&&a.added(c);b(document).trigger("formset:added",[c,a.prefix])})}return this};b.fn.formset.defaults={prefix:"form",addText:"add another",deleteText:"remove",addCssClass:"add-row",deleteCssClass:"delete-row",emptyCssClass:"empty-row",formCssClass:"dynamic-form",added:null,removed:null,addButton:null};b.fn.tabularFormset=function(d,a){var c=b(this),f=function(a){b(d).not(".add-row").removeClass("row1 row2").filter(":even").addClass("row1").end().filter(":odd").addClass("row2")},g=function(){"undefined"!==
|
||||
typeof SelectFilter&&(b(".selectfilter").each(function(b,a){b=a.name.split("-");SelectFilter.init(a.id,b[b.length-1],!1)}),b(".selectfilterstacked").each(function(b,a){b=a.name.split("-");SelectFilter.init(a.id,b[b.length-1],!0)}))},h=function(a){a.find(".prepopulated_field").each(function(){var c=b(this).find("input, select, textarea"),d=c.data("dependency_list")||[],e=[];b.each(d,function(b,c){e.push("#"+a.find(".field-"+c).find("input, select, textarea").attr("id"))});e.length&&c.prepopulate(e,
|
||||
c.attr("maxlength"))})};c.formset({prefix:a.prefix,addText:a.addText,formCssClass:"dynamic-"+a.prefix,deleteCssClass:"inline-deletelink",deleteText:a.deleteText,emptyCssClass:"empty-form",removed:f,added:function(a){h(a);"undefined"!==typeof DateTimeShortcuts&&(b(".datetimeshortcuts").remove(),DateTimeShortcuts.init());g();f(a)},addButton:a.addButton});return c};b.fn.stackedFormset=function(d,a){var c=b(this),f=function(a){b(d).find(".inline_label").each(function(a){a+=1;b(this).html(b(this).html().replace(/(#\d+)/g,
|
||||
"#"+a))})},g=function(){"undefined"!==typeof SelectFilter&&(b(".selectfilter").each(function(a,b){a=b.name.split("-");SelectFilter.init(b.id,a[a.length-1],!1)}),b(".selectfilterstacked").each(function(a,b){a=b.name.split("-");SelectFilter.init(b.id,a[a.length-1],!0)}))},h=function(a){a.find(".prepopulated_field").each(function(){var c=b(this).find("input, select, textarea"),d=c.data("dependency_list")||[],e=[];b.each(d,function(b,c){e.push("#"+a.find(".form-row .field-"+c).find("input, select, textarea").attr("id"))});
|
||||
e.length&&c.prepopulate(e,c.attr("maxlength"))})};c.formset({prefix:a.prefix,addText:a.addText,formCssClass:"dynamic-"+a.prefix,deleteCssClass:"inline-deletelink",deleteText:a.deleteText,emptyCssClass:"empty-form",removed:f,added:function(a){h(a);"undefined"!==typeof DateTimeShortcuts&&(b(".datetimeshortcuts").remove(),DateTimeShortcuts.init());g();f(a)},addButton:a.addButton});return c};b(document).ready(function(){b(".js-inline-admin-formset").each(function(){var d=b(this).data(),a=d.inlineFormset;
|
||||
switch(d.inlineType){case "stacked":d=a.name+"-group .inline-related";b(d).stackedFormset(d,a.options);break;case "tabular":d=a.name+"-group .tabular.inline-related tbody:first > tr",b(d).tabularFormset(d,a.options)}})})})(django.jQuery);
|
||||
|
|
|
|||
|
|
@ -30,12 +30,12 @@
|
|||
};
|
||||
|
||||
prepopulatedField.data('_changed', false);
|
||||
prepopulatedField.change(function() {
|
||||
prepopulatedField.on('change', function() {
|
||||
prepopulatedField.data('_changed', true);
|
||||
});
|
||||
|
||||
if (!prepopulatedField.val()) {
|
||||
$(dependencies.join(',')).keyup(populate).change(populate).focus(populate);
|
||||
$(dependencies.join(',')).on('keyup change focus', populate);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
(function(c){c.fn.prepopulate=function(e,f,g){return this.each(function(){var a=c(this),b=function(){if(!a.data("_changed")){var b=[];c.each(e,function(a,d){d=c(d);0<d.val().length&&b.push(d.val())});a.val(URLify(b.join(" "),f,g))}};a.data("_changed",!1);a.change(function(){a.data("_changed",!0)});a.val()||c(e.join(",")).keyup(b).change(b).focus(b)})}})(django.jQuery);
|
||||
(function(b){b.fn.prepopulate=function(d,f,g){return this.each(function(){var a=b(this),h=function(){if(!a.data("_changed")){var e=[];b.each(d,function(a,c){c=b(c);0<c.val().length&&e.push(c.val())});a.val(URLify(e.join(" "),f,g))}};a.data("_changed",!1);a.on("change",function(){a.data("_changed",!0)});if(!a.val())b(d.join(",")).on("keyup change focus",h)})}})(django.jQuery);
|
||||
|
|
|
|||
|
|
@ -58,6 +58,14 @@
|
|||
'ů': 'u', 'ž': 'z', 'Č': 'C', 'Ď': 'D', 'Ě': 'E', 'Ň': 'N', 'Ř': 'R',
|
||||
'Š': 'S', 'Ť': 'T', 'Ů': 'U', 'Ž': 'Z'
|
||||
};
|
||||
var SLOVAK_MAP = {
|
||||
'á': 'a', 'ä': 'a', 'č': 'c', 'ď': 'd', 'é': 'e', 'í': 'i', 'ľ': 'l',
|
||||
'ĺ': 'l', 'ň': 'n', 'ó': 'o', 'ô': 'o', 'ŕ': 'r', 'š': 's', 'ť': 't',
|
||||
'ú': 'u', 'ý': 'y', 'ž': 'z',
|
||||
'Á': 'a', 'Ä': 'A', 'Č': 'C', 'Ď': 'D', 'É': 'E', 'Í': 'I', 'Ľ': 'L',
|
||||
'Ĺ': 'L', 'Ň': 'N', 'Ó': 'O', 'Ô': 'O', 'Ŕ': 'R', 'Š': 'S', 'Ť': 'T',
|
||||
'Ú': 'U', 'Ý': 'Y', 'Ž': 'Z'
|
||||
};
|
||||
var POLISH_MAP = {
|
||||
'ą': 'a', 'ć': 'c', 'ę': 'e', 'ł': 'l', 'ń': 'n', 'ó': 'o', 'ś': 's',
|
||||
'ź': 'z', 'ż': 'z',
|
||||
|
|
@ -108,6 +116,7 @@
|
|||
RUSSIAN_MAP,
|
||||
UKRAINIAN_MAP,
|
||||
CZECH_MAP,
|
||||
SLOVAK_MAP,
|
||||
POLISH_MAP,
|
||||
LATVIAN_MAP,
|
||||
ARABIC_MAP,
|
||||
|
|
@ -155,13 +164,19 @@
|
|||
if (!allowUnicode) {
|
||||
s = downcode(s);
|
||||
}
|
||||
var removelist = [
|
||||
"a", "an", "as", "at", "before", "but", "by", "for", "from", "is",
|
||||
"in", "into", "like", "of", "off", "on", "onto", "per", "since",
|
||||
"than", "the", "this", "that", "to", "up", "via", "with"
|
||||
var hasUnicodeChars = /[^\u0000-\u007f]/.test(s);
|
||||
// Remove English words only if the string contains ASCII (English)
|
||||
// characters.
|
||||
if (!hasUnicodeChars) {
|
||||
var removeList = [
|
||||
"a", "an", "as", "at", "before", "but", "by", "for", "from",
|
||||
"is", "in", "into", "like", "of", "off", "on", "onto", "per",
|
||||
"since", "than", "the", "this", "that", "to", "up", "via",
|
||||
"with"
|
||||
];
|
||||
var r = new RegExp('\\b(' + removelist.join('|') + ')\\b', 'gi');
|
||||
var r = new RegExp('\\b(' + removeList.join('|') + ')\\b', 'gi');
|
||||
s = s.replace(r, '');
|
||||
}
|
||||
// if downcode doesn't hit, the char will be stripped here
|
||||
if (allowUnicode) {
|
||||
// Keep Unicode letters including both lowercase and uppercase
|
||||
|
|
@ -172,8 +187,9 @@
|
|||
}
|
||||
s = s.replace(/^\s+|\s+$/g, ''); // trim leading/trailing spaces
|
||||
s = s.replace(/[-\s]+/g, '-'); // convert spaces to hyphens
|
||||
s = s.toLowerCase(); // convert to lowercase
|
||||
return s.substring(0, num_chars); // trim to first num_chars chars
|
||||
s = s.substring(0, num_chars); // trim to first num_chars chars
|
||||
s = s.replace(/-+$/g, ''); // trim any trailing hyphens
|
||||
return s.toLowerCase(); // convert to lowercase
|
||||
}
|
||||
window.URLify = URLify;
|
||||
})();
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
|
@ -6,14 +6,14 @@
|
|||
path="*"
|
||||
verb="*"
|
||||
modules="FastCgiModule"
|
||||
scriptProcessor="c:\python35\python.exe|c:\python35\lib\site-packages\wfastcgi.py"
|
||||
scriptProcessor="c:\python36\python.exe|c:\python36\lib\site-packages\wfastcgi.py"
|
||||
resourceType="Unspecified"
|
||||
requireAccess="Script"/>
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
<appSettings>
|
||||
<add key="WSGI_HANDLER" value="django.core.wsgi.get_wsgi_application()" />
|
||||
<add key="PYTHONPATH" value="d:\caoqianming\mysite" />
|
||||
<add key="PYTHONPATH" value="d:\safesite" />
|
||||
<add key="DJANGO_SETTINGS_MODULE" value="mysite.settings" />
|
||||
</appSettings>
|
||||
</configuration>
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
import os,datetime,time
|
||||
while True:
|
||||
os.system('python D:\mysite\manage.py clearsessions')
|
||||
print('清除过期session成功--'+ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
|
||||
time.sleep(60*60*24)
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
import requests,time,json,datetime
|
||||
|
||||
def gettoken():
|
||||
r=requests.get('https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx4d75244c1b980b5b&secret=edf7d23a457fb4df5ad47eeb9d4b7a39').text
|
||||
token=json.loads(r)['access_token']
|
||||
with open('D:/safesite/safesite/token.txt','w') as f:
|
||||
f.write(token)
|
||||
while True:
|
||||
gettoken()
|
||||
print('微信token读取----'+ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
|
||||
time.sleep(600)
|
||||
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
import datetime,time,os,schedule
|
||||
|
||||
#filepath = 'E:/safeyunbackup/'+filename
|
||||
#backstr = 'C:/PostgreSQL/10/bin/pg_dump -h localhost -U postgres safedb > '+ filepath
|
||||
#os.system(backstr)
|
||||
#print(filename +'备份成功')
|
||||
|
||||
def backup():
|
||||
os.system('save.bat')
|
||||
filename = 'safedb_'+ datetime.datetime.now().strftime("%Y-%m-%d")
|
||||
print('pg备份成功--'+ filename)
|
||||
|
||||
def clearsession():
|
||||
os.system('python D:\mysite\manage.py clearsessions')
|
||||
print('清除过期session成功--'+ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
|
||||
|
||||
schedule.every().day.at("01:30").do(backup)
|
||||
#schedule.every(6).hour.do(backup)
|
||||
|
||||
while True:
|
||||
schedule.run_pending()
|
||||
time.sleep(1)
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
@ECHO OFF
|
||||
@setlocal enableextensions
|
||||
@cd /d "%~dp0"
|
||||
|
||||
set PGPASSWORD=cTc1111Qa
|
||||
SET PGPATH=C:\PostgreSQL\10\bin\
|
||||
SET SVPATH=E:\safeyunbackup\
|
||||
SET PRJDB=safedb
|
||||
SET DBUSR=postgres
|
||||
FOR /F "TOKENS=1,2,3 DELIMS=/ " %%i IN ('DATE /T') DO SET d=%%i-%%j-%%k
|
||||
|
||||
SET DBDUMP=%PRJDB%_%d%.bak
|
||||
@ECHO OFF
|
||||
%PGPATH%pg_dump -h localhost -U postgres %PRJDB% > %SVPATH%%DBDUMP%
|
||||
|
||||
echo Backup Taken Complete %SVPATH%%DBDUMP%
|
||||
|
||||
forfiles /p %SVPATH% /d -5 /c "cmd /c echo deleting @file ... && del /f @path"
|
||||
Loading…
Reference in New Issue