国检集团答题活动
This commit is contained in:
parent
4d0da0d851
commit
d11c44e062
|
|
@ -93,7 +93,7 @@ DATABASES = {
|
|||
'PASSWORD':'cTc1111Qa',
|
||||
'HOST':'121.36.23.77',
|
||||
'PORT':'5432',
|
||||
'CONN_MAX_AGE': 600,
|
||||
'CONN_MAX_AGE': 60,
|
||||
},
|
||||
'OPTIONS': {
|
||||
'isolation_level': psycopg2.extensions.ISOLATION_LEVEL_SERIALIZABLE,
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -40,7 +40,7 @@ def edulessondetail(req,jyid):
|
|||
def upload(req):
|
||||
username = User.objects.get(userid=req.session['userid']).username
|
||||
file_name = time.strftime('%Y%m%d%H%M%S')+ '_' + req.FILES['mf'].name
|
||||
user_upload_folder = os.path.join('media/video', username)
|
||||
user_upload_folder = os.path.join('media/', username)
|
||||
if not os.path.exists(user_upload_folder):
|
||||
os.mkdir(user_upload_folder)
|
||||
filepath = os.path.join(user_upload_folder, file_name)
|
||||
|
|
@ -59,7 +59,7 @@ def selectDate(req):
|
|||
a = a.filter(type=req.GET.get('type'))
|
||||
total = a.count()
|
||||
startnum,endnum=fenye(req)
|
||||
a = a.order_by('-submittime')[startnum:endnum].values('id','num','title','user__name','desciption','submittime','type','cate__name','url','watchnum')
|
||||
a = a.order_by('-submittime')[startnum:endnum].values('id','num','title','user__name','desciption','submittime','type','cate__name','url','downnum')
|
||||
return HttpResponse(transjson(total,a),content_type="application/json")
|
||||
def api(req):
|
||||
a = req.GET.get('a')
|
||||
|
|
@ -68,53 +68,74 @@ def api(req):
|
|||
userid = req.session['userid']
|
||||
companyid = getcompany(userid)
|
||||
startnum,endnum=fenye(req)
|
||||
a = Edulesson.objects.filter(usecomp__partid__in= [1,Partment.objects.get(partid=companyid).partid] ,deletemark=1).order_by('id')#无deletemark
|
||||
a = Edulesson.objects.filter(usecomp__partid__in= [1,Partment.objects.get(partid=companyid).partid] ,deletemark=1)#无deletemark
|
||||
if req.GET.get('search',None):
|
||||
search = req.GET.get('search')
|
||||
a = a.filter(Q(title__contains=search)|Q(desciption__contains=search))
|
||||
total = a.count()
|
||||
startnum,endnum=fenye(req)
|
||||
a = a[startnum:endnum].values('id','num','title','user__name','desciption','submittime','type','cate__name','url','watchnum')
|
||||
a = a.order_by('modifytime','downnum')[startnum:endnum].values('id','num','title','user__name','user__ubelongpart__partname','desciption','submittime','type','cate__name','url','downnum','modifytime')
|
||||
return HttpResponse(transjson(total,a),content_type="application/json")
|
||||
elif a == 'detail':
|
||||
id = req.GET.get('id')
|
||||
obj = Edulesson.objects.filter(id=id).values('id','num','title','user__name','user__ubelongpart__partname','desciption','submittime','type','cate__name','url','downnum','modifytime')
|
||||
return JsonResponse(list(obj)[0])
|
||||
#视频
|
||||
elif a=='add':
|
||||
userid = req.session['userid']#用户ID
|
||||
companyid = getcompany(userid)#公司ID
|
||||
obj = Edulesson()
|
||||
data = json.loads(req.body.decode('utf-8'))
|
||||
obj.title = data['title']
|
||||
obj.num='ZXJY'+time.strftime('%Y%m%d%H%M%S')
|
||||
obj.submittime=data['submittime']
|
||||
obj.desciption=data['desciption']
|
||||
obj.type=data['type']
|
||||
obj.deletemark=1
|
||||
obj.modifytime= datetime.now()
|
||||
obj.url=data['url']
|
||||
obj.watchnum=0
|
||||
obj.cate= Questioncat.objects.get(id=data['cate'])
|
||||
obj.usecomp=Partment.objects.get(partid=companyid)
|
||||
obj.user=User.objects.get(userid=userid)
|
||||
|
||||
obj.save()
|
||||
return JsonResponse({"code":1})
|
||||
userid = req.session['userid']#用户ID
|
||||
companyid = getcompany(userid)#公司ID
|
||||
obj = Edulesson()
|
||||
data = json.loads(req.body.decode('utf-8'))
|
||||
obj.title = data['title']
|
||||
obj.num='XXZL'+time.strftime('%Y%m%d%H%M%S')
|
||||
if 'submittime' in data and data['submittime']:
|
||||
obj.submittime=data['submittime']
|
||||
else:
|
||||
obj.submittime=datetime.now()
|
||||
obj.desciption=data['desciption']
|
||||
obj.type=1
|
||||
obj.deletemark=1
|
||||
obj.url=data['url']
|
||||
obj.downnum=0
|
||||
obj.cate= Questioncat.objects.get(id=data['cate'])
|
||||
obj.usecomp=Partment.objects.get(partid=companyid)
|
||||
obj.user=User.objects.get(userid=userid)
|
||||
obj.save()
|
||||
return JsonResponse({"code":1})
|
||||
#文件
|
||||
elif a=='addwj':
|
||||
userid = req.session['userid']#用户ID
|
||||
companyid = getcompany(userid)#公司ID
|
||||
obj = Edulesson()
|
||||
data = json.loads(req.body.decode('utf-8'))
|
||||
obj.title = data['title']
|
||||
obj.num='ZXJY'+time.strftime('%Y%m%d%H%M%S')
|
||||
obj.submittime=data['submittime']
|
||||
obj.desciption=data['desciption']
|
||||
obj.type=1
|
||||
obj.deletemark=1
|
||||
obj.modifytime= datetime.now()
|
||||
obj.url=data['url']
|
||||
obj.watchnum=0
|
||||
obj.cate= Questioncat.objects.get(id=data['cate'])
|
||||
obj.usecomp=Partment.objects.get(partid=companyid)
|
||||
obj.user=User.objects.get(userid=userid)
|
||||
|
||||
obj.save()
|
||||
return JsonResponse({"code":1})
|
||||
userid = req.session['userid']#用户ID
|
||||
companyid = getcompany(userid)#公司ID
|
||||
obj = Edulesson()
|
||||
data = json.loads(req.body.decode('utf-8'))
|
||||
obj.title = data['title']
|
||||
obj.num='ZXJY'+time.strftime('%Y%m%d%H%M%S')
|
||||
if 'submittime' in data and data['submittime']:
|
||||
obj.submittime=data['submittime']
|
||||
else:
|
||||
obj.submittime=datetime.now()
|
||||
obj.desciption=data['desciption']
|
||||
obj.deletemark=1
|
||||
obj.url=data['url']
|
||||
fileurl = data['url']
|
||||
if fileurl.endswith('.doc') or fileurl.endswith('.docx'):
|
||||
obj.type = 2
|
||||
elif fileurl.endswith('.ppt') or fileurl.endswith('.pptx'):
|
||||
obj.type = 3
|
||||
elif fileurl.endswith('.pdf'):
|
||||
obj.type = 4
|
||||
elif fileurl.endswith('.xls') or fileurl.endswith('.xlsx'):
|
||||
obj.type = 5
|
||||
elif fileurl.endswith('.zip') or fileurl.endswith('.rar'):
|
||||
obj.type = 6
|
||||
else:
|
||||
obj.type = 7 #其他
|
||||
obj.downnum=0
|
||||
obj.cate= Questioncat.objects.get(id=data['cate'])
|
||||
obj.usecomp=Partment.objects.get(partid=companyid)
|
||||
obj.user=User.objects.get(userid=userid)
|
||||
obj.save()
|
||||
return JsonResponse({"code":1})
|
||||
#删除
|
||||
elif a == 'del':
|
||||
id =req.GET.get('id')
|
||||
|
|
@ -125,17 +146,14 @@ def api(req):
|
|||
a.deletemark=0
|
||||
a.save()
|
||||
return JsonResponse({"code":1})
|
||||
|
||||
else:
|
||||
|
||||
return JsonResponse({"code":0})
|
||||
|
||||
#点击阅读
|
||||
elif a=='readnumber':
|
||||
#点击下载
|
||||
elif a=='downfile':
|
||||
id =req.GET.get('id')
|
||||
userid = req.session['userid']
|
||||
a = Edulesson.objects.get(id=id)
|
||||
a.watchnum=a.watchnum+1
|
||||
a.downnum=a.downnum+1
|
||||
a.save()
|
||||
obj = EdulessonWatch()
|
||||
obj.edulesson=a
|
||||
|
|
@ -143,7 +161,6 @@ def api(req):
|
|||
obj.save()
|
||||
return JsonResponse({"code":1,"url": a.url})
|
||||
#观看详情
|
||||
|
||||
elif a=='detail':
|
||||
id=req.GET.get('zrid')
|
||||
a = EdulessonWatch.objects.filter(edulesson=id).values('id','user__name','submittime')
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
# Generated by Django 2.2.8 on 2020-02-12 21:35
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('safesite', '0316_auto_20200115_1653'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# migrations.RemoveField(
|
||||
# model_name='companyinfo',
|
||||
# name='liaison_fax',
|
||||
# ),
|
||||
migrations.AddField(
|
||||
model_name='notice',
|
||||
name='like',
|
||||
field=models.IntegerField(default=0),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='notice',
|
||||
name='poster',
|
||||
field=models.CharField(blank=True, max_length=200, null=True, verbose_name='封面图'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='notice',
|
||||
name='supply_part',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='tgbm', to='safesite.Partment', verbose_name='资料提供部门'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='noticeto',
|
||||
name='islike',
|
||||
field=models.IntegerField(default=0),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='notice',
|
||||
name='reads',
|
||||
field=models.IntegerField(default=0),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='noticeto',
|
||||
name='read',
|
||||
field=models.IntegerField(default=0),
|
||||
),
|
||||
]
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
# Generated by Django 2.2.8 on 2020-02-14 14:27
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('safesite', '0317_auto_20200212_2135'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='edulesson',
|
||||
old_name='watchnum',
|
||||
new_name='downnum',
|
||||
),
|
||||
# migrations.RemoveField(
|
||||
# model_name='companyinfo',
|
||||
# name='liaison_fax',
|
||||
# ),
|
||||
]
|
||||
|
|
@ -551,7 +551,7 @@ class Suggestflow(models.Model): # 建议流程
|
|||
submittime = models.DateTimeField(default=timezone.now)
|
||||
|
||||
|
||||
class Notice(models.Model): # 通知通告
|
||||
class Notice(models.Model): # 资料/公告/通知
|
||||
id = models.AutoField(primary_key=True)
|
||||
title = models.CharField(u'标题', max_length=100)
|
||||
pubpart = models.ForeignKey(
|
||||
|
|
@ -565,9 +565,13 @@ class Notice(models.Model): # 通知通告
|
|||
User, related_name='tzry', through='Noticeto')
|
||||
material = models.CharField(max_length=1000, null=True, blank=True)
|
||||
deletemark = models.IntegerField(default='1')
|
||||
reads = models.IntegerField(default='0')
|
||||
isgg = models.IntegerField(default='1')
|
||||
reads = models.IntegerField(default=0)
|
||||
isgg = models.IntegerField(default='1') #1是公告,0是通知,2是资料文件
|
||||
usecomps = models.CharField(max_length=1000, null=True, blank=True) # 使用公司
|
||||
like = models.IntegerField(default=0)
|
||||
poster = models.CharField(max_length=200, null=True, blank=True, verbose_name='封面图')
|
||||
supply_part = models.ForeignKey(
|
||||
Partment, related_name='tgbm', on_delete=models.CASCADE, verbose_name="资料提供部门",null=True,blank=True)
|
||||
# def __str__(self):
|
||||
# return self.title
|
||||
# class Meta:
|
||||
|
|
@ -579,7 +583,8 @@ class Noticeto(models.Model): # 通知阅读表
|
|||
noticeid = models.ForeignKey(Notice, on_delete=models.CASCADE)
|
||||
receiver = models.ForeignKey(User, on_delete=models.CASCADE) # 接收人
|
||||
comment = models.CharField(max_length=500)
|
||||
read = models.IntegerField(default='0')
|
||||
read = models.IntegerField(default=0)
|
||||
islike = models.IntegerField(default=0)
|
||||
|
||||
|
||||
class Operation(models.Model): # 作业表
|
||||
|
|
@ -737,7 +742,7 @@ class ExamTest(models.Model): # 考试表
|
|||
num = models.CharField(max_length=200, default='') # 编号
|
||||
name = models.CharField(max_length=200, default='')
|
||||
type = models.IntegerField(default=1) # 正式考试/模拟考试/练习
|
||||
state = models.IntegerField(default=1) # 1进行中
|
||||
state = models.IntegerField(default=1) # 1进行中 0是已关闭
|
||||
exampaper = models.ForeignKey(ExamPaper, on_delete=models.CASCADE)
|
||||
user = models.ManyToManyField(User, through='ExamTestDetail') # 考试人员
|
||||
starttime = models.DateTimeField(null=True, blank=True) # 最早参加
|
||||
|
|
@ -983,7 +988,7 @@ class Risk(models.Model): # 风险表
|
|||
tasktime = models.DateTimeField(null=True, blank=True) # 最后任务开始时间
|
||||
|
||||
|
||||
class Edulesson(models.Model): # 在线视频表
|
||||
class Edulesson(models.Model): # 学习资料表
|
||||
id = models.AutoField(primary_key=True)
|
||||
num = models.CharField(max_length=50)
|
||||
title = models.CharField(max_length=50)
|
||||
|
|
@ -997,13 +1002,12 @@ class Edulesson(models.Model): # 在线视频表
|
|||
deletemark = models.IntegerField(default=1)
|
||||
modifytime = models.DateTimeField(auto_now=True)
|
||||
url = models.CharField(max_length=200, null=True, blank=True)
|
||||
watchnum = models.IntegerField(default=0)
|
||||
downnum = models.IntegerField(default=0) # 下载量
|
||||
usecomp = models.ForeignKey(
|
||||
Partment, on_delete=models.CASCADE, null=True, blank=True)
|
||||
watchrecord = models.ManyToManyField(
|
||||
User, related_name='gkr', through='EdulessonWatch')
|
||||
|
||||
|
||||
class EdulessonWatch(models.Model): # 在线视频观看情况表
|
||||
id = models.AutoField(primary_key=True)
|
||||
edulesson = models.ForeignKey(Edulesson, on_delete=models.CASCADE)
|
||||
|
|
@ -1207,3 +1211,6 @@ class ReaderOperproce(models.Model):
|
|||
num = models.CharField(max_length=50)
|
||||
readeruser = models.ForeignKey(User,on_delete=models.CASCADE)
|
||||
readertime = models.DateTimeField(default = timezone.now)
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -103,13 +103,13 @@
|
|||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<!-- <tr>
|
||||
<td>上传时间:</td>
|
||||
<td>
|
||||
<input id="submittime" editable="false" name="submittime" class="easyui-datetimebox" style="width:480px"
|
||||
data-options="currentText:'今天',closeText:'关闭',showSeconds:false" />
|
||||
</td>
|
||||
</tr>
|
||||
</tr> -->
|
||||
|
||||
<tr>
|
||||
<td>文件描述:</td>
|
||||
|
|
|
|||
|
|
@ -107,25 +107,23 @@
|
|||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<!-- <tr>
|
||||
<td>上传时间:</td>
|
||||
<td>
|
||||
<input id="submittime" editable="false" name="submittime" class="easyui-datetimebox" style="width:480px"
|
||||
data-options="currentText:'今天',closeText:'关闭',showSeconds:false" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>资料分类:</td>
|
||||
</tr> -->
|
||||
<!-- <tr>
|
||||
<td>资料类型:</td>
|
||||
<td>
|
||||
<select name='type' id='type' style="width:480px;height:32px">
|
||||
<option value="2" selected>world文档</option>
|
||||
<option value="3">ppt文档</option>
|
||||
<option value="4">pdf文档</option>
|
||||
|
||||
<option value="2" selected>office文档</option>
|
||||
<option value="3">压缩包</option>
|
||||
</select>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tr> -->
|
||||
<tr>
|
||||
<td>文件描述:</td>
|
||||
<td>
|
||||
|
|
@ -148,7 +146,7 @@
|
|||
<p class="_p">
|
||||
|
||||
<a class="list" href="javascript:;">
|
||||
<input id="file" type="file" name="myfile" accept=".xls,.txt,.ppt,.doc,.pdf,dot" onchange="UpladFile(this); " /><span>选择文件</span>
|
||||
<input id="file" type="file" name="myfile" accept=".xls,.ppt,.doc,.pdf,.rar,.zip,.pptx,.docx,.xlsx" onchange="UpladFile(this); " /><span>选择文件</span>
|
||||
</a>
|
||||
<!--<button class="btn" type="button" onclick="sub();">上传</button>-->
|
||||
<a class="el-upload-list__item-name">
|
||||
|
|
@ -192,7 +190,7 @@
|
|||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: 'edu/api?a=add',
|
||||
url: 'edu/api?a=addwj',
|
||||
data: JSON.stringify(edudata),
|
||||
datatype: "json",
|
||||
processData: false,
|
||||
|
|
@ -233,7 +231,7 @@
|
|||
};
|
||||
|
||||
|
||||
var filetypes = [".xls",".txt",".ppt",".doc",".pdf",".dot"];
|
||||
var filetypes = [".xls",".txt",".ppt",".doc",".pdf",".dot",".rar",".zip",".docx", ".pptx", ".xlsx"];
|
||||
var filepath = target.value;
|
||||
if (filepath) {
|
||||
var isnext = false;
|
||||
|
|
@ -258,8 +256,8 @@
|
|||
|
||||
|
||||
var imagSize = fileObj.size;
|
||||
if (imagSize > 1024 * 1024 * 3) {
|
||||
alert("文件大小为:" + (imagSize / (1024 * 1024)).toFixed(2) + "M,超出了上传大小," + "请选择3M以内的文件!");
|
||||
if (imagSize > 1024 * 1024 * 10) {
|
||||
alert("文件大小为:" + (imagSize / (1024 * 1024)).toFixed(2) + "M,超出了上传大小," + "请选择10M以内的文件!");
|
||||
$("#videoName").text('文件太大了超出范围!');
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,11 @@
|
|||
<label>查询</label>
|
||||
<select id='kjcxws' style='width:150px;height:30px'>
|
||||
<option value="all">请选择</option>
|
||||
<option value="1">视频</option>
|
||||
<option value="1">mp4视频</option>
|
||||
<option value="2">word文档</option>
|
||||
<option value="3">ppt文档</option>
|
||||
<option value="4">pdf文档</option>
|
||||
<option value="5">excel文档</option>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
|
@ -24,11 +25,11 @@
|
|||
<a id="deledu" class="easyui-linkbutton" onclick="deledu()" data-options="iconCls: 'fa-trash',plain:true">删除文件</a>
|
||||
{% endif %}
|
||||
{% if request|has_permission:'b_edu_study' %}
|
||||
<a id="tzdetail" onclick="tzdetail()" class="easyui-linkbutton" data-options="iconCls: 'fa-info-circle',plain:true">点击学习</a>
|
||||
<a id="tzdetail" onclick="tzdetail()" class="easyui-linkbutton" data-options="iconCls: 'fa-info-circle',plain:true">下载/查看</a>
|
||||
{% endif %}
|
||||
{% if request|has_permission:'b_edu_detail' %}
|
||||
<!-- {% if request|has_permission:'b_edu_detail' %}
|
||||
<a id="edulook" class="easyui-linkbutton" onclick="jydetail()" data-options="iconCls: 'fa-plus',plain:true">观看历史</a>
|
||||
{% endif %}
|
||||
{% endif %} -->
|
||||
|
||||
|
||||
</div>
|
||||
|
|
@ -46,7 +47,7 @@
|
|||
var row = $('#edutab').datagrid('getSelected');
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "edu/api?a=readnumber",
|
||||
url: "edu/api?a=downfile",
|
||||
data: { 'id': row.id },
|
||||
dateType: "json",
|
||||
success: function (data) {
|
||||
|
|
@ -93,9 +94,9 @@
|
|||
{ field: 'desciption', title: '简要描述', width: 300 },
|
||||
{ field: 'submittime', title: '上传时间', width: 300 },
|
||||
{
|
||||
field: 'type', title: '资料分类', width: '10%', formatter: function (value, row, index) {
|
||||
field: 'type', title: '资源类型', width: '10%', formatter: function (value, row, index) {
|
||||
if (value == 1) {
|
||||
return '视频';
|
||||
return 'mp4视频';
|
||||
}
|
||||
else if (value == 2) {
|
||||
return 'word文档'
|
||||
|
|
@ -106,6 +107,9 @@
|
|||
else if (value == 4) {
|
||||
return 'pdf文档'
|
||||
}
|
||||
else if (value == 5) {
|
||||
return 'excel文档'
|
||||
}
|
||||
}
|
||||
},
|
||||
{ field: 'cate__name', title: '所属类别', width: 200 },
|
||||
|
|
@ -115,7 +119,7 @@
|
|||
return '<a style="color:blue" target="_blank" href="' + row.url + '" id="one">点击学习</a>';
|
||||
}
|
||||
},
|
||||
{ field: 'watchnum', title: '观看次数', width: 200 },
|
||||
{ field: 'downnum', title: '下载量', width: 200 },
|
||||
]]
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
</div>
|
||||
<div style="margin-bottom:5px">
|
||||
<input class="easyui-textbox" id="participantname" style="width:80%;height:120px" editable="false"
|
||||
data-options="label:'参加人员',multiline:true,prompt:'请选择'" required=true>
|
||||
data-options="label:'通知人员',multiline:true,prompt:'请选择'" >
|
||||
<input type="hidden" id="participant" name="participant" />
|
||||
<a class='easyui-linkbutton' onclick="choseusers()" style="width:auto">选择</a>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
</div>
|
||||
<div style="margin-bottom:5px">
|
||||
<input class="easyui-textbox" id="participantname" style="width:90%;height:120px" editable="false"
|
||||
data-options="label:'参加人员',multiline:true,prompt:'请选择'" required=true>
|
||||
data-options="label:'通知人员',multiline:true,prompt:'请选择'" >
|
||||
<input type="hidden" id="participant" name="participant" />
|
||||
<a class='easyui-linkbutton' onclick="choseusers()" style="width:auto">选择</a>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -176,6 +176,8 @@ urlpatterns = [
|
|||
path('api/equipmentcheckform',viewsdrf.EquipmentCheckFormAPIView.as_view()),
|
||||
path('api/equipmentcheckform/<int:pk>',viewsdrf.EquipmentCheckFormDetailView.as_view()),
|
||||
|
||||
path('api/examtestrate',views.apiexamtestrate),
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ from groups import models as g_models
|
|||
import logging
|
||||
from django.contrib.auth.hashers import make_password, check_password
|
||||
import re
|
||||
import pickle
|
||||
logger = logging.getLogger('log')
|
||||
|
||||
# 分页功能
|
||||
|
|
@ -3550,6 +3551,7 @@ def unbindmp(req):
|
|||
userid = req.session['userid']
|
||||
User.objects.filter(userid=userid).update(
|
||||
openid=None, headimgurl=None, nickname=None, mpopenid=None)
|
||||
req.session.flush() #清除登陆态
|
||||
return JsonResponse({"code": 1})
|
||||
|
||||
|
||||
|
|
@ -3584,21 +3586,24 @@ def mplogin(req):
|
|||
userid = a.userid
|
||||
username = a.username
|
||||
req.session['userid'] = userid
|
||||
allrights = list(a.usecomp.role.permissions.all().values_list('menuid',flat=True))
|
||||
# print(req.session,req.COOKIES)
|
||||
return JsonResponse({"code": 1, 'userid': userid, 'username': username, 'mpopenid': mpopenid,'openid':a.openid})
|
||||
return JsonResponse({"code": 1, 'userid': userid, 'username': username, 'mpopenid': mpopenid,'openid':a.openid, 'nickname':a.nickname, 'headimgurl':a.headimgurl, 'companyid':a.usecomp.partid, 'rights': allrights, 'name':a.name})
|
||||
else:
|
||||
return JsonResponse({"code": 0, 'mpopenid': mpopenid})
|
||||
|
||||
|
||||
def bindmp(req):
|
||||
username = req.POST.get('username')
|
||||
password = req.POST.get('password')
|
||||
mpopenid = req.POST.get('mpopenid')
|
||||
data = json.loads(req.body.decode('utf-8'))
|
||||
username = data['username']
|
||||
password = data['password']
|
||||
mpopenid = data['mpopenid']
|
||||
userinfo = data['userInfo']
|
||||
# print(username,password,mpopenid)
|
||||
user = User.objects.filter(username=username, deletemark=1)
|
||||
if user.exists():
|
||||
if check_password(password, user[0].epassword):
|
||||
user.update(mpopenid=mpopenid)
|
||||
user.update(mpopenid=mpopenid,headimgurl=userinfo['avatarUrl'],nickname=userinfo['nickName'])
|
||||
return JsonResponse({"code": 1})
|
||||
else:
|
||||
return JsonResponse({"code": 0})
|
||||
|
|
@ -3606,6 +3611,8 @@ def bindmp(req):
|
|||
return JsonResponse({"code": 0})
|
||||
|
||||
|
||||
|
||||
|
||||
def setup(req):
|
||||
if req.GET.get('a') == 'setuph':
|
||||
userid = req.session['userid']
|
||||
|
|
@ -4326,6 +4333,16 @@ def apiuser(req):
|
|||
user.save()
|
||||
Group.objects.get(usecomp=user.usecomp,grouptype=3).users.add(user)#授予基本权限
|
||||
return JsonResponse({"code": 1})
|
||||
elif a == 'updateHeadimg':
|
||||
userid = req.GET.get('userid')
|
||||
user = User.objects.get(userid=ruserid)
|
||||
data = json.loads(req.body.decode('utf-8'))
|
||||
if 'headimgurl' in data:
|
||||
user.headimgurl = data['headimgurl']
|
||||
if 'nickname' in data:
|
||||
user.nickname = data['nickname']
|
||||
user.save()
|
||||
return JsonResponse({'code':1})
|
||||
|
||||
|
||||
def apiduibiao(req):
|
||||
|
|
@ -4780,6 +4797,13 @@ def apitool(req):
|
|||
i.menulist = menulist
|
||||
i.save()
|
||||
return JsonResponse({"code": 1})
|
||||
elif a == 'correct_examtesttook':
|
||||
for i in ExamTestDetail.objects.exclude(starttime=None,endtime=None):
|
||||
i.took = (i.endtime-i.starttime).total_seconds()
|
||||
i.save()
|
||||
return JsonResponse({"code":1})
|
||||
|
||||
|
||||
def apinotice(req):
|
||||
a = req.GET.get('a')
|
||||
if a == 'add':
|
||||
|
|
@ -4859,6 +4883,19 @@ def apinotice(req):
|
|||
a = a[startnum:endnum].values('id', 'title', 'pubpart__partname', 'pubuser__name',
|
||||
'pubuser__userid', 'submittime', 'modifytime', 'reads', 'isgg')
|
||||
return HttpResponse(transjson(total, a), content_type="application/json")
|
||||
elif a == 'listdata':
|
||||
userid = req.session['userid']
|
||||
usecomp = User.objects.get(userid=userid).usecomp
|
||||
a = (Notice.objects.filter(usecomps__contains=',' + str(usecomp.partid)+',', deletemark=1, isgg=1) |
|
||||
Notice.objects.filter(usecomps__contains=',1,', deletemark=1, isgg=1))
|
||||
if req.GET.get('search'):
|
||||
a = a.filter(title__contains=req.GET.get('search'))
|
||||
a = a.distinct().order_by('-submittime')
|
||||
total = a.count()
|
||||
startnum, endnum = fenye(req)
|
||||
a = a[startnum:endnum].values('id', 'title', 'pubpart__partname', 'pubuser__name',
|
||||
'pubuser__userid', 'submittime', 'modifytime', 'reads', 'isgg')
|
||||
return HttpResponse(transjson(total, a), content_type="application/json")
|
||||
elif a == 'listtodomain':
|
||||
userid = req.session['userid']
|
||||
a = Noticeto.objects.filter(receiver=User.objects.get(userid=userid)).values(
|
||||
|
|
@ -5762,11 +5799,17 @@ def apiexamtest(req):
|
|||
if a == 'listall':
|
||||
a = ExamTest.objects
|
||||
a = a.filter(usecomps__contains=','+companyid +
|
||||
',').exclude(nousecomps__contains=','+companyid+',').order_by('-id')
|
||||
',').exclude(nousecomps__contains=','+companyid+',')
|
||||
state = req.GET.get('state',None)
|
||||
if state == 'open':
|
||||
a = a.filter(state=1)
|
||||
if state == 'close':
|
||||
a = a.filter(state=0)
|
||||
a = a.order_by('-id')
|
||||
total = a.count()
|
||||
startnum, endnum = fenye(req)
|
||||
a = a[startnum:endnum].values('id', 'num', 'name', 'state', 'type', 'exampaper__id',
|
||||
'exampaper__name', 'starttime', 'endtime', 'duration', 'createuser__name', 'createtime')
|
||||
'exampaper__name', 'starttime', 'endtime', 'duration', 'createuser__name', 'createtime','passscore')
|
||||
return HttpResponse(transjson(total, a), content_type="application/json")
|
||||
elif a == 'listok':
|
||||
a = ExamTest.objects
|
||||
|
|
@ -5805,32 +5848,33 @@ def apiexamtest(req):
|
|||
obj.qrcode = makeqr_examtest(
|
||||
'https://safeyun.ctcshe.com/miniprogram/examtest?id='+str(obj.id))
|
||||
obj.save()
|
||||
ksry = data['participant'].split(',')
|
||||
b = []
|
||||
for i in ksry:
|
||||
uobj = User.objects.get(userid=i)
|
||||
ExamTestDetail.objects.create(examtest=obj, user=uobj)
|
||||
b.append(uobj.openid)
|
||||
postdict = {
|
||||
'touser': '',
|
||||
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
|
||||
"miniprogram": {"appid": "wx5c39b569f01c27db", "path": "pages/examtest/index"},
|
||||
'data': {
|
||||
'first': {
|
||||
'value': '小程序考试通知:'
|
||||
},
|
||||
'keyword1': {
|
||||
'value': data['name']
|
||||
},
|
||||
'keyword2': {
|
||||
'value': '满分' + str(obj.totalscore)
|
||||
},
|
||||
'remark': {
|
||||
'value': '用时限制为'+data['duration']+'分钟,注意把握时间'
|
||||
if 'participant' in data and data['participant']:
|
||||
ksry = data['participant'].split(',')
|
||||
b = []
|
||||
for i in ksry:
|
||||
uobj = User.objects.get(userid=i)
|
||||
ExamTestDetail.objects.create(examtest=obj, user=uobj)
|
||||
b.append(uobj.openid)
|
||||
postdict = {
|
||||
'touser': '',
|
||||
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
|
||||
"miniprogram": {"appid": "wx5c39b569f01c27db", "path": "pages/examtest/index"},
|
||||
'data': {
|
||||
'first': {
|
||||
'value': '小程序考试通知:'
|
||||
},
|
||||
'keyword1': {
|
||||
'value': data['name']
|
||||
},
|
||||
'keyword2': {
|
||||
'value': '满分' + str(obj.totalscore)
|
||||
},
|
||||
'remark': {
|
||||
'value': '用时限制为'+data['duration']+'分钟,注意把握时间'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
send_wechatmsgs.delay(postdict, b)
|
||||
send_wechatmsgs.delay(postdict, b)
|
||||
return JsonResponse({"code": 1})
|
||||
elif a == 'add2':
|
||||
data = json.loads(req.body.decode('utf-8'))
|
||||
|
|
@ -5890,32 +5934,33 @@ def apiexamtest(req):
|
|||
obj.qrcode = makeqr_examtest(
|
||||
'https://safeyun.ctcshe.com/miniprogram/examtest?id='+str(obj.id))
|
||||
obj.save()
|
||||
ksry = data['participant'].split(',')
|
||||
b = []
|
||||
for i in ksry:
|
||||
uobj = User.objects.get(userid=i)
|
||||
ExamTestDetail.objects.create(examtest=obj, user=uobj)
|
||||
b.append(uobj.openid)
|
||||
postdict = {
|
||||
'touser': '',
|
||||
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
|
||||
"miniprogram": {"appid": "wx5c39b569f01c27db", "path": "pages/examtest/index"},
|
||||
'data': {
|
||||
'first': {
|
||||
'value': '小程序考试通知:'
|
||||
},
|
||||
'keyword1': {
|
||||
'value': data['name']
|
||||
},
|
||||
'keyword2': {
|
||||
'value': '满分' + str(obj.totalscore)
|
||||
},
|
||||
'remark': {
|
||||
'value': '用时限制为'+data['duration']+'分钟,注意把握时间'
|
||||
if 'participant' in data and data['participant']:
|
||||
ksry = data['participant'].split(',')
|
||||
b = []
|
||||
for i in ksry:
|
||||
uobj = User.objects.get(userid=i)
|
||||
ExamTestDetail.objects.create(examtest=obj, user=uobj)
|
||||
b.append(uobj.openid)
|
||||
postdict = {
|
||||
'touser': '',
|
||||
'template_id': 'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
|
||||
"miniprogram": {"appid": "wx5c39b569f01c27db", "path": "pages/examtest/index"},
|
||||
'data': {
|
||||
'first': {
|
||||
'value': '小程序考试通知:'
|
||||
},
|
||||
'keyword1': {
|
||||
'value': data['name']
|
||||
},
|
||||
'keyword2': {
|
||||
'value': '满分' + str(obj.totalscore)
|
||||
},
|
||||
'remark': {
|
||||
'value': '用时限制为'+data['duration']+'分钟,注意把握时间'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
send_wechatmsgs.delay(postdict, b)
|
||||
send_wechatmsgs.delay(postdict, b)
|
||||
return JsonResponse({"code": 1})
|
||||
elif a == 'del':
|
||||
id = req.GET.get('id')
|
||||
|
|
@ -5944,7 +5989,7 @@ def apiexamtest(req):
|
|||
objs = ExamTestDetail.objects.filter(examtest__id=id).order_by('-score').values(
|
||||
'id', 'user__name', 'user__ubelongpart__partname', 'took', 'score', 'ison', 'passcode','starttime')
|
||||
a['cjrydetail'] = list(objs)
|
||||
a['ison'] = 1
|
||||
a['ison'] = 0
|
||||
tests = ExamTestDetail.objects.filter(examtest__id=id,user__userid=userid)#考试记录
|
||||
if tests.exists():
|
||||
a['ison'] = tests[0].ison
|
||||
|
|
@ -5961,6 +6006,13 @@ def apiexamtest(req):
|
|||
data = json.loads(req.body.decode('utf-8'))
|
||||
url = exportdoc2('ks', data)
|
||||
return JsonResponse({"code": 1, "downloadurl": url})
|
||||
elif a == 'dknum':#未参加且还未关闭的考试
|
||||
a = ExamTest.objects
|
||||
a = a.filter(usecomps__contains=','+companyid + #未关闭的考试
|
||||
',').exclude(nousecomps__contains=','+companyid+',').filter(state=1,endtime__gte=datetime.now())
|
||||
hasAttend = ExamTestDetail.objects.filter(examtest__in=a,user__userid=req.session['userid'],ison=1) #在未关闭的考试中已经参加的
|
||||
return JsonResponse({"code":1, "dknum":a.count()-hasAttend.count()})
|
||||
|
||||
|
||||
|
||||
def apiexamtestdetail(req):
|
||||
|
|
@ -5992,10 +6044,10 @@ def apiexamtestdetail(req):
|
|||
return HttpResponse(transjson(total, a), content_type="application/json")
|
||||
elif a == 'listyk':
|
||||
a = ExamTestDetail.objects
|
||||
a = a.filter(user__userid=userid).exclude(ison=0).order_by('-id')
|
||||
a = a.filter(user__userid=userid).exclude(ison=0)
|
||||
total = a.count()
|
||||
startnum, endnum = fenye(req)
|
||||
a = a[startnum:endnum].values('id', 'examtest__id', 'examtest__name', 'starttime', 'examtest__passscore',
|
||||
a = a.order_by('-starttime')[startnum:endnum].values('id', 'examtest__id', 'examtest__name', 'starttime', 'examtest__passscore',
|
||||
'examtest__state', 'ison', 'examtest__duration', 'took', 'score', 'passcode')
|
||||
return HttpResponse(transjson(total, a), content_type="application/json")
|
||||
elif a == 'handtest':
|
||||
|
|
@ -6003,8 +6055,8 @@ def apiexamtestdetail(req):
|
|||
testid = data['testid']
|
||||
starttime = data['starttime']
|
||||
endtime = data['endtime']
|
||||
took = round((datetime.strptime(endtime, '%Y-%m-%d %H:%M:%S') -
|
||||
datetime.strptime(starttime, '%Y-%m-%d %H:%M:%S')).total_seconds()/60)
|
||||
took = (datetime.strptime(endtime, '%Y-%m-%d %H:%M:%S') -
|
||||
datetime.strptime(starttime, '%Y-%m-%d %H:%M:%S')).total_seconds() #计算相差多少秒
|
||||
testdetail = data['sheet']
|
||||
score = 0
|
||||
rights = 0
|
||||
|
|
@ -6019,10 +6071,11 @@ def apiexamtestdetail(req):
|
|||
iscore = i['score']
|
||||
rights = rights + 1
|
||||
else:
|
||||
miniscore = i['score']/len(i['question__right'])
|
||||
wrongs.append(str(i['question__id']))
|
||||
for x in i['userchecked']:
|
||||
if x in i['question__right']:
|
||||
iscore = iscore + 0.5
|
||||
iscore = iscore + miniscore
|
||||
else:
|
||||
iscore = 0
|
||||
break
|
||||
|
|
@ -6037,14 +6090,15 @@ def apiexamtestdetail(req):
|
|||
i['iscore'] = iscore
|
||||
score = score + iscore
|
||||
tms.append(str(i['question__id']))
|
||||
obj = ExamTestDetail.objects.get(
|
||||
examtest__id=testid, user__userid=userid)
|
||||
obj,created = ExamTestDetail.objects.get_or_create(examtest__id=testid, user__userid=userid,
|
||||
defaults={'examtest': ExamTest.objects.get(id=testid),'user':User.objects.get(userid=userid)})
|
||||
obj.testnum = obj.testnum + 1
|
||||
obj.starttime = starttime
|
||||
obj.endtime = endtime
|
||||
obj.took = took
|
||||
obj.testdetail = testdetail
|
||||
obj.rights = rights
|
||||
score = round(score,1)
|
||||
obj.score = score
|
||||
obj.ison = 1
|
||||
examtestobj = obj.examtest
|
||||
|
|
@ -6061,12 +6115,12 @@ def apiexamtestdetail(req):
|
|||
obj.wrongs = ','+','.join(wrongs)+','
|
||||
obj.save()
|
||||
tmnum = len(testdetail)
|
||||
objs = ExamTestDetail.objects.filter(examtest__id=testid, passcode=0) # 如果全部考完并通过,关闭考试
|
||||
if objs.exists():
|
||||
pass
|
||||
else:
|
||||
ExamTest.objects.filter(id=testid).update(state=0)
|
||||
return JsonResponse({'code': 1, 'data': {'passcode': passcode, 'score': score, 'totalscore': totalscore, 'rights': rights, 'tmnum': tmnum, 'examtestdetailid': obj.id}})
|
||||
# objs = ExamTestDetail.objects.filter(examtest__id=testid, passcode=0) 必须得手动关闭考试
|
||||
# if objs.exists():
|
||||
# pass
|
||||
# else:
|
||||
# ExamTest.objects.filter(id=testid).update(state=0)
|
||||
return JsonResponse({'code': 1, 'data': {'passcode': passcode, 'score': score, 'totalscore': totalscore, 'rights': rights, 'tmnum': tmnum, 'examtestdetailid': obj.id, 'examtestid':obj.examtest.id}})
|
||||
elif a == 'detail':
|
||||
id = req.GET.get('id')
|
||||
obj = ExamTestDetail.objects.filter(id=id)
|
||||
|
|
@ -6085,6 +6139,37 @@ def apiexamtestdetail(req):
|
|||
return JsonResponse({"code":1,"msg":"发布成功!"})
|
||||
else:
|
||||
return JsonResponse({"code":2,"msg":"您没有发布权限!"})
|
||||
elif a == 'rate':
|
||||
examtestid = req.GET.get('examtestid')
|
||||
examtestobj = ExamTest.objects.get(id=examtestid)
|
||||
objs = ExamTestDetail.objects.filter(examtest=examtestobj)
|
||||
objs = objs.order_by('-score','took')
|
||||
total = objs.count()
|
||||
startnum, endnum = fenye(req)
|
||||
objsdata = objs[startnum:endnum].values('id','took', 'score', 'user__name', 'user__ubelongpart__partname', 'user__headimgurl')
|
||||
return JsonResponse({'total':total,'rows':list(objsdata),'examtestname':examtestobj.name})
|
||||
elif a == 'totalrate':
|
||||
startnum, endnum = fenye(req)
|
||||
with open('ratedata.dat','rb') as f:
|
||||
data = pickle.load(f)
|
||||
data['rows'] = data['rows'][startnum:endnum]
|
||||
return JsonResponse(data)
|
||||
|
||||
|
||||
def apiexamtestrate(req):
|
||||
'''
|
||||
公司活动总排名
|
||||
'''
|
||||
companyid = req.GET.get('companyid')
|
||||
alltest = ExamTest.objects.filter(usecomps__contains=','+str(companyid)+',').exclude(nousecomps__contains=','+str(companyid)+',')
|
||||
objs = ExamTestDetail.objects.filter(examtest__in=alltest,ison=1).values('user__userid','user__name','user__headimgurl','user__ubelongpart__partname').annotate(totalscore=Sum('score'),totaltook=Sum('took'),testnum=Count('user__userid')).order_by('-totalscore','totaltook')
|
||||
total = objs.count()
|
||||
with open('ratedata.dat','wb') as f:
|
||||
pickle.dump({'total':total,'rows':list(objs),'updatetime':datetime.now().strftime('%Y-%m-%d %H:%M')},f)
|
||||
return JsonResponse({"code": 1})
|
||||
|
||||
|
||||
|
||||
def apitrain(req):
|
||||
if req.GET.get('a') == 'listjoin':
|
||||
userid = req.session['userid']
|
||||
|
|
|
|||
Loading…
Reference in New Issue