diff --git a/safesite/daoru.py b/safesite/daoru.py index 8c88145c..7d6822ec 100644 --- a/safesite/daoru.py +++ b/safesite/daoru.py @@ -95,7 +95,7 @@ def drquestions(companyid,path,userid): cateobj = Questioncat.objects.create(usecomp=Partment.objects.get(partid=companyid),name=cate) if type == '单选': if Question.objects.filter(type=1,title=title,right=right,deletemark=1,usecomps = ','+companyid+',').exists(): - Question.objects.filter(type=1,title=title,right=right,deletemark=1,usecomps = ','+companyid+',').update(nousecomps='') + Question.objects.filter(type=1,title=title,right=right,deletemark=1,usecomps = ','+companyid+',').update(nousecomps='', questioncat=cateobj) else: if right in ['A','B','C','D','E','F']: obj = Question() @@ -115,7 +115,7 @@ def drquestions(companyid,path,userid): elif type == '多选': right = list(right) if Question.objects.filter(type=2,title=title,right=right,deletemark=1,usecomps = ','+companyid+',').exists(): - Question.objects.filter(type=2,title=title,right=right,deletemark=1,usecomps = ','+companyid+',').update(nousecomps='') + Question.objects.filter(type=2,title=title,right=right,deletemark=1,usecomps = ','+companyid+',').update(nousecomps='', questioncat=cateobj) else: if [False for c in right if c not in qlist]: pass @@ -140,7 +140,7 @@ def drquestions(companyid,path,userid): else: right = 'B' if Question.objects.filter(type=3,title=title,right=right,deletemark=1,usecomps = ','+companyid+',').exists(): - Question.objects.filter(type=3,title=title,right=right,deletemark=1,usecomps = ','+companyid+',').update(nousecomps='') + Question.objects.filter(type=3,title=title,right=right,deletemark=1,usecomps = ','+companyid+',').update(nousecomps='', questioncat=cateobj) else: obj = Question() obj.type = 3 diff --git a/safesite/migrations/0366_auto_20201117_1314.py b/safesite/migrations/0366_auto_20201117_1314.py new file mode 100644 index 00000000..319a3f31 --- /dev/null +++ b/safesite/migrations/0366_auto_20201117_1314.py @@ -0,0 +1,27 @@ +# Generated by Django 2.2.8 on 2020-11-17 13:14 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('safesite', '0365_auto_20201115_2158'), + ] + + operations = [ + # migrations.RemoveField( + # model_name='companyinfo', + # name='liaison_fax', + # ), + migrations.AlterField( + model_name='checktask', + name='checkplace', + field=models.TextField(default=''), + ), + migrations.AlterField( + model_name='checktask', + name='userlist', + field=models.TextField(default=''), + ), + ] diff --git a/safesite/migrations/0367_auto_20201117_1405.py b/safesite/migrations/0367_auto_20201117_1405.py new file mode 100644 index 00000000..f17b788f --- /dev/null +++ b/safesite/migrations/0367_auto_20201117_1405.py @@ -0,0 +1,22 @@ +# Generated by Django 2.2.8 on 2020-11-17 14:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('safesite', '0366_auto_20201117_1314'), + ] + + operations = [ + # migrations.RemoveField( + # model_name='companyinfo', + # name='liaison_fax', + # ), + migrations.AddField( + model_name='questioncat', + name='isopen', + field=models.IntegerField(default=0), + ), + ] diff --git a/safesite/models.py b/safesite/models.py index fa26ed4a..10a0311c 100644 --- a/safesite/models.py +++ b/safesite/models.py @@ -693,6 +693,7 @@ class Questioncat(models.Model): # 题目分类 modifytime = models.DateTimeField(auto_now=True) usecomp = models.ForeignKey( Partment, on_delete=models.CASCADE, null=True, blank=True) + isopen = models.IntegerField(default=0) #默认不共享 # 题库数据表 @@ -1291,13 +1292,13 @@ class Checktask(models.Model): checktype=models.ForeignKey(Checktable,on_delete=models.CASCADE)#关联检查表 checkname=models.ManyToManyField(User,related_name='jiancha')#检查人员 checktime= models.DateTimeField(null=True, blank=True)#任务首次执行时间 - checkplace=models.CharField(max_length=200)#检查地点 + checkplace=models.TextField(default='')#检查地点 createuser = models.ForeignKey(User,related_name='chuangjians',on_delete=models.CASCADE)#创建人 createdate = models.DateTimeField(default = timezone.now)#创建时间 usecomp = models.ForeignKey(Partment,related_name='taskscomp',on_delete=models.CASCADE,null=True,blank=True)#创建公司 deletemark = models.IntegerField(default=1)#是否删除 tasktype = models.IntegerField(default=0)#任务执行频率(1每天,2每周,3每月,4每季度,5每半年,6每年) - userlist = models.CharField(max_length=200,null=True,)#检查人列表 + userlist = models.TextField(default='')#检查人列表 zxstate = models.IntegerField(default=1)#1同时执行,2一个执行就执行 taskstate = models.IntegerField(default=1)#是否暂停,1运行,2暂停 diff --git a/safesite/safespider.py b/safesite/safespider.py index e9f58e90..0c697b9d 100644 --- a/safesite/safespider.py +++ b/safesite/safespider.py @@ -15,16 +15,11 @@ headers = { def getTzzs(certnum,stu_name):#特种证书(身份证号,姓名,均是字符) certtype_code='720' - proxies = { - "http": "http://112.91.78.240:5412" -} stu_name=parse.quote(parse.quote(stu_name)) - text1 = requests.post('http://cx.mem.gov.cn//cms/html/certQuery/certQuery.do?method=getServerTime',headers=headers, proxies=proxies).text - print(text1) + text1 = requests.post('http://cx.mem.gov.cn//cms/html/certQuery/certQuery.do?method=getServerTime',headers=headers).text sessionId = eval(text1)['time'] - url = "http://cx.mem.gov.cn/cms/html/certQuery/certQuery.do?method=getCertQueryResult&ref=ch&certtype_code="+certtype_code+"&certnum="+certnum+"&stu_name="+stu_name+'&passcode=1234'+'&sessionId='+sessionId - data = requests.get(url,headers=headers, proxies=proxies).text + data = requests.get(url,headers=headers).text tree = etree.HTML(data) e1 = tree.xpath("//th[text()='姓名']/following-sibling::td[1]/text()") e2 = tree.xpath("//th[text()='性别']/following-sibling::td[1]/text()") diff --git a/safesite/static/safesite/easyui/themes/icon.css b/safesite/static/safesite/easyui/themes/icon.css index 82778c70..5441ca86 100644 --- a/safesite/static/safesite/easyui/themes/icon.css +++ b/safesite/static/safesite/easyui/themes/icon.css @@ -178,7 +178,9 @@ .icon-inspectitem { background: url('icons/inspectitem.png') no-repeat center center; } - +.icon-scheduleset { + background: url('icons/scheduleset.png') no-repeat center center; +} .icon-mini-add{ diff --git a/safesite/static/safesite/easyui/themes/icons/scheduleset.png b/safesite/static/safesite/easyui/themes/icons/scheduleset.png new file mode 100644 index 00000000..df1f8107 Binary files /dev/null and b/safesite/static/safesite/easyui/themes/icons/scheduleset.png differ diff --git a/safesite/static/safesite/mystatic/js/util.js b/safesite/static/safesite/mystatic/js/util.js index 8364bc05..0470b57e 100644 --- a/safesite/static/safesite/mystatic/js/util.js +++ b/safesite/static/safesite/mystatic/js/util.js @@ -213,14 +213,16 @@ function convert(rows, x) { id: row.id, text: row.name, state: x, - pic: row.pic + pic: row.pic, + isopen: row.isopen } if(row.name=='默认分类'){ node = { id: row.id, text: row.name, state: 'closed', - pic: row.pic + pic: row.pic, + isopen: row.isopen } } @@ -238,7 +240,7 @@ function convert(rows, x) { for (var i = 0; i < rows.length; i++) { var row = rows[i]; if (row.parentId == node.id) { - var child = { id: row.id, text: row.name, pic: row.pic }; + var child = { id: row.id, text: row.name, pic: row.pic, isopen:row.isopen }; if (node.children) { node.children.push(child); } else { diff --git a/safesite/templates/examtestadd2.html b/safesite/templates/examtestadd2.html index 4a6afeb0..abba88c8 100644 --- a/safesite/templates/examtestadd2.html +++ b/safesite/templates/examtestadd2.html @@ -16,7 +16,7 @@
-
@@ -94,7 +94,7 @@ }) $("#tmfls").combotree({ - url: 'api/questioncat?a=tree3', + url: 'api/questioncat?a=tree4', method: 'get', multiple: true, loadFilter: function (rows) { diff --git a/safesite/templates/examtestdetail.html b/safesite/templates/examtestdetail.html index 03827a66..52bbf657 100644 --- a/safesite/templates/examtestdetail.html +++ b/safesite/templates/examtestdetail.html @@ -217,7 +217,7 @@ success: function (data) { alert(data.msg); - $("#dd").dialog("close"); + $("#dd").dialog("refresh"); } }); }; diff --git a/safesite/templates/index.html b/safesite/templates/index.html index 2ea26b3a..acd4c535 100644 --- a/safesite/templates/index.html +++ b/safesite/templates/index.html @@ -171,7 +171,12 @@ \ No newline at end of file diff --git a/safesite/templates/questioncatadd.html b/safesite/templates/questioncatadd.html index fe4a240f..90f2d7b5 100644 --- a/safesite/templates/questioncatadd.html +++ b/safesite/templates/questioncatadd.html @@ -16,6 +16,10 @@ editable="false">
+
+ + +
\ No newline at end of file diff --git a/safesite/templates/safecertadd.html b/safesite/templates/safecertadd.html index 0be5e79f..abbe2cbf 100644 --- a/safesite/templates/safecertadd.html +++ b/safesite/templates/safecertadd.html @@ -1,12 +1,11 @@
提交查询 + id="submitb">提交 取消
-

请输入相关信息后提交进行联网查询证书

@@ -14,12 +13,29 @@ 选择
- +
- + +
+
+ +
+
+ +
+
+ +
+
+ +
@@ -29,7 +45,7 @@ var aqzsdata = $('#aqzsff').serializeJSON(); $.ajax({ type: "POST", - url: 'api/safecert?a=addspider', + url: 'api/safecert?a=add', data: JSON.stringify(aqzsdata), datatype: "json", processData: false, diff --git a/safesite/templates/safecertadd_.html b/safesite/templates/safecertadd_.html new file mode 100644 index 00000000..0be5e79f --- /dev/null +++ b/safesite/templates/safecertadd_.html @@ -0,0 +1,96 @@ +
+
+ 提交查询 + 取消 +
+
+
+

请输入相关信息后提交进行联网查询证书

+
+ + + 选择 +
+
+ +
+
+ +
+
+
+
+ \ No newline at end of file diff --git a/safesite/templates/safecertedit.html b/safesite/templates/safecertedit.html new file mode 100644 index 00000000..cea1d109 --- /dev/null +++ b/safesite/templates/safecertedit.html @@ -0,0 +1,117 @@ +
+
+ 提交 + 取消 +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ + \ No newline at end of file diff --git a/safesite/templates/socert.html b/safesite/templates/socert.html index 290c5f83..6c1c2ce8 100644 --- a/safesite/templates/socert.html +++ b/safesite/templates/socert.html @@ -1,19 +1,8 @@
-
-
- {% load myfilter %} - {% if request|has_permission:'b_socert_add' %} - - {% endif %} - {% if request|has_permission:'b_socert_del' %} - 删除 - {% endif %} - {% if request|has_permission:'b_socert_exportexl' %} - 导出Excel - {% endif %} -
-
+
+ +
@@ -23,6 +12,21 @@
+
+ {% load myfilter %} + {% if request|has_permission:'b_socert_add' %} + 新增 + {% endif %} + {% if request|has_permission:'b_socert_add' %} + 编辑 + {% endif %} + {% if request|has_permission:'b_socert_del' %} + 删除 + {% endif %} + {% if request|has_permission:'b_socert_exportexl' %} + 导出Excel + {% endif %} +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ + +
+
+ \ No newline at end of file diff --git a/safesite/templates/userhtml.html b/safesite/templates/userhtml.html index 4c10eb55..5e86397f 100644 --- a/safesite/templates/userhtml.html +++ b/safesite/templates/userhtml.html @@ -27,7 +27,7 @@ - + 查询
diff --git a/safesite/urls.py b/safesite/urls.py index b6c3ffc8..31e76a54 100644 --- a/safesite/urls.py +++ b/safesite/urls.py @@ -35,6 +35,7 @@ urlpatterns = [ path('rightshtml', views.rightshtml), path('socerthtml', views.socerthtml), path('socerthtml/add', views.socertadd), + path('html/socert/edit//',views.socertedit), path('html/medetail', views.medetail), path('html/suggest', views.suggest), path('html/suggest/add', views.suggestadd), @@ -71,6 +72,7 @@ urlpatterns = [ path('html/examtest/detail//', views.examtestdetail), path('html/safecert', views.safecert), path('html/safecert/add', views.safecertadd), + path('html/safecert/edit//',views.safecertedit), path('html/area', views.area), path('html/areadetail', views.areadetail), path('html/mapshow', views.mapshow), diff --git a/safesite/views.py b/safesite/views.py index 4f57b104..e26b9bb0 100644 --- a/safesite/views.py +++ b/safesite/views.py @@ -284,6 +284,8 @@ def safecert(req): def safecertadd(req): return render(req, 'safecertadd.html') +def safecertedit(req, id): + return render(req, 'safecertedit.html', {'id': id}) def examtestdetail(req, id): return render(req, 'examtestdetail.html', {'id': id}) @@ -420,6 +422,8 @@ def socerthtml(req): def socertadd(req): return render(req, 'socertadd.html') +def socertedit(req, id): + return render(req, 'socertedit.html', {'id':id}) def rightshtml(req): groupid = req.GET.get('groupid') @@ -2753,7 +2757,7 @@ def getuser(req): companyid = getcompany(userid) parts = Partment.objects.filter( partlink__contains=','+companyid+',') | Partment.objects.filter(partid=companyid) - a = User.objects.filter(ubelongpart__in=parts, deletemark=1, name__contains=req.GET.get('name')).order_by( + a = User.objects.filter(ubelongpart__in=parts, deletemark=1).filter(Q(name__contains=req.GET.get('name'))|Q(username__contains=req.GET.get('name'))).order_by( 'userid').values('userid', 'empid', 'name', 'ubelongpart__partname', 'ubelongpart__partid', 'username', 'openid') total = a.count() return HttpResponse(transjson(total, a), content_type="application/json") @@ -4042,8 +4046,7 @@ def apisocert(req): userid = req.session['userid'] companyid = getcompany(userid) startnum, endnum = fenye(req) - a = Socertificate.objects.filter(usecomp=Partment.objects.get( - partid=companyid)).order_by('id') # 无deletemark + a = Socertificate.objects.filter(user__usecomp__partid=companyid).order_by('id') # 无deletemark total = a.count() startnum, endnum = fenye(req) if req.GET.get('sort'): @@ -4062,6 +4065,35 @@ def apisocert(req): a = a.values('id', 'realname', 'gender', 'zylb', 'czxm', 'fzjg', 'ccfzrq', 'yfsrq', 'yxqkssj', 'yxqjssj', 'sjfssj', 'zszt', 'url', 'cardnum') return HttpResponse(transjson(total, a), content_type="application/json") + elif a == 'add': + postdata = json.loads(req.body.decode('utf-8')) + obj = Socertificate() + user = User.objects.get(userid = postdata['userid']) + obj.user = User.objects.get(userid = postdata['userid']) + obj.zylb = postdata['zylb'] + obj.fzjg = postdata['fzjg'] + obj.czxm = postdata['czxm'] + obj.ccfzrq = postdata['ccfzrq'] + obj.yfsrq = postdata['yfsrq'] + obj.yxqkssj = postdata['yxqkssj'] + obj.yxqjssj = postdata['yxqjssj'] + obj.zszt = guoqi(postdata['yfsrq']) + obj.usecomp = user.usecomp + obj.save() + return JsonResponse({'code':1}) + elif a == 'edit': + postdata = json.loads(req.body.decode('utf-8')) + obj = Socertificate.objects.get(id=postdata['id']) + obj.zylb = postdata['zylb'] + obj.fzjg = postdata['fzjg'] + obj.czxm = postdata['czxm'] + obj.ccfzrq = postdata['ccfzrq'] + obj.yfsrq = postdata['yfsrq'] + obj.yxqkssj = postdata['yxqkssj'] + obj.yxqjssj = postdata['yxqjssj'] + obj.zszt = guoqi(postdata['yfsrq']) + obj.save() + return JsonResponse({'code':1}) # elif a == 'addspider': # postdata = json.loads(req.body.decode('utf-8')) # userid = postdata['userid'] @@ -4186,7 +4218,7 @@ def apisocert(req): elif a == 'detail': id = req.GET.get('id') a = Socertificate.objects.filter(id=id).values( - 'id', 'realname', 'gender', 'zylb', 'czxm', 'fzjg', 'ccfzrq', 'yfsrq', 'yxqkssj', 'yxqjssj', 'sjfssj', 'user__userprofile__realname', 'user__userprofile__gender', 'user__userprofile__cardnum') + 'id', 'realname', 'gender', 'zylb', 'czxm', 'fzjg', 'ccfzrq', 'yfsrq', 'yxqkssj', 'yxqjssj', 'sjfssj', 'user__userprofile__realname', 'user__userprofile__gender', 'user__userprofile__cardnum', 'user__name') return JsonResponse(a[0]) elif a == 'getjson': cardnum = req.GET.get('cardnum') @@ -4219,8 +4251,7 @@ def apisafecert(req): userid = req.session['userid'] companyid = getcompany(userid) startnum, endnum = fenye(req) - a = Safecert.objects.filter(usecomp=Partment.objects.get( - partid=companyid)).order_by('id') # 无deletemark + a = Safecert.objects.filter(user__usecomp__partid=companyid).order_by('id') # 无deletemark total = a.count() startnum, endnum = fenye(req) if req.GET.get('sort'): @@ -4239,6 +4270,33 @@ def apisafecert(req): a = a.values('id', 'realname', 'gender', 'zglx', 'dwlx', 'fzjg', 'yfsrq', 'yxqkssj', 'yxqjssj', 'zszt', 'url', 'cardnum', 'user__userprofile__realname', 'user__userprofile__gender', 'user__userprofile__cardnum') return HttpResponse(transjson(total, a), content_type="application/json") + elif a == 'add': + postdata = json.loads(req.body.decode('utf-8')) + obj = Safecert() + user = User.objects.get(userid = postdata['userid']) + obj.user = User.objects.get(userid = postdata['userid']) + obj.zglx = postdata['zglx'] + obj.fzjg = postdata['fzjg'] + obj.dwlx = postdata['dwlx'] + obj.yfsrq = postdata['yfsrq'] + obj.yxqkssj = postdata['yxqkssj'] + obj.yxqjssj = postdata['yxqjssj'] + obj.zszt = guoqi(postdata['yfsrq']) + obj.usecomp = user.usecomp + obj.save() + return JsonResponse({'code':1}) + elif a == 'edit': + postdata = json.loads(req.body.decode('utf-8')) + obj = Safecert.objects.get(id=postdata['id']) + obj.zylb = postdata['zglx'] + obj.fzjg = postdata['fzjg'] + obj.czxm = postdata['dwlx'] + obj.yfsrq = postdata['yfsrq'] + obj.yxqkssj = postdata['yxqkssj'] + obj.yxqjssj = postdata['yxqjssj'] + obj.zszt = guoqi(postdata['yfsrq']) + obj.save() + return JsonResponse({'code':1}) # elif a == 'addspider': # postdata = json.loads(req.body.decode('utf-8')) # userid = postdata['userid'] @@ -4356,7 +4414,7 @@ def apisafecert(req): elif a == 'detail': id = req.GET.get('id') a = Safecert.objects.filter(id=id).values( - 'id', 'realname', 'gender', 'zglx', 'dwlx', 'fzjg', 'yfsrq', 'yxqkssj', 'yxqjssj', 'zszt', 'url', 'user__userprofile__realname', 'user__userprofile__gender', 'user__userprofile__cardnum') + 'id', 'realname', 'gender', 'zglx', 'dwlx', 'fzjg', 'yfsrq', 'yxqkssj', 'yxqjssj', 'zszt', 'url', 'user__userprofile__realname', 'user__userprofile__gender', 'user__userprofile__cardnum', 'user__name') return JsonResponse(a[0]) elif a == 'getjson': cardnum = req.GET.get('cardnum') @@ -5024,6 +5082,12 @@ def apitool(req): # Userprofile.objects.filter(realname='null').update(realname='') # Userprofile.objects.filter(cardnum='null').update(cardnum='') return JsonResponse({"code":1}) + elif a == 'correct_questioncat': + # print(Questioncat.objects.filter(usecomp__partid=2184).delete()) + print(Question.objects.filter(questioncat__name='冬季四防安全生产知识').count()) + # Questioncat.objects.filter(usecomp__partname='广安厂').update(parent=None, link=',', deletemark=1) + # print(Questioncat.objects.filter(name='冬季四防安全生产知识').values('usecomp__partname')) + return JsonResponse({"code":1}) @@ -6604,32 +6668,46 @@ def apiquestioncat(req): companyid = getcompany(userid) if a == 'tree1': list_items = (Questioncat.objects.filter(usecomp__partid=1, deletemark=1)).annotate( - parentId=F('parent__id')).values('id', 'parentId', 'name') + parentId=F('parent__id')).values('id', 'parentId', 'name', 'isopen') return HttpResponse(json.dumps(list(list_items)), content_type="application/json") elif a == 'tree2': list_items = (Questioncat.objects.filter(usecomp__partid=companyid, deletemark=1)).annotate( - parentId=F('parent__id')).values('id', 'parentId', 'name') + parentId=F('parent__id')).values('id', 'parentId', 'name', 'isopen') return HttpResponse(json.dumps(list(list_items)), content_type="application/json") elif a == 'tree3': + # 共享分类 groups = g_models.Groupmember.objects.filter(member__partid=companyid).values_list('group__id', flat=True) companys = g_models.Groupmember.objects.filter(group__id__in=groups).values_list('member__partid', flat=True).distinct() if companys: pass else: companys = Partment.objects.filter(partid=companyid).values_list('partid', flat=True) - list_items = (Questioncat.objects.filter(usecomp__in=companys, deletemark=1)| Questioncat.objects.filter( - usecomp__partid=1, deletemark=1)).annotate( - parentId=F('parent__id')).values('id', 'parentId', 'name') + list_items = Questioncat.objects.filter(usecomp__in=companys, deletemark=1, isopen=1).annotate( + parentId=F('parent__id')).values('id', 'parentId', 'name', 'isopen') + return HttpResponse(json.dumps(list(list_items)), content_type="application/json") + elif a == 'tree4': + # 自建+共享分类 + groups = g_models.Groupmember.objects.filter(member__partid=companyid).values_list('group__id', flat=True) + companys = g_models.Groupmember.objects.filter(group__id__in=groups).values_list('member__partid', flat=True).distinct() + if companys: + pass + else: + companys = Partment.objects.filter(partid=companyid).values_list('partid', flat=True) + list_items = (Questioncat.objects.filter(usecomp__in=companys, deletemark=1, isopen=1)| Questioncat.objects.filter( + usecomp__partid=companyid, deletemark=1)).distinct().annotate( + parentId=F('parent__id')).values('id', 'parentId', 'name', 'isopen') return HttpResponse(json.dumps(list(list_items)), content_type="application/json") elif a == 'tree': list_items = (Questioncat.objects.filter(usecomp__partid=1, deletemark=1) | Questioncat.objects.filter( - usecomp__partid=companyid, deletemark=1)).annotate(parentId=F('parent__id')).values('id', 'parentId', 'name') + usecomp__partid=companyid, deletemark=1)).annotate(parentId=F('parent__id')).values('id', 'parentId', 'name', 'isopen') return HttpResponse(json.dumps(list(list_items)), content_type="application/json") elif a == 'add': data = json.loads(req.body.decode('utf-8')) obj = Questioncat() name = data['name'] obj.name = name + if 'isopen' in data: + obj.isopen = 1 if 'parent' in data: if data['parent']: parent = data['parent'] @@ -6648,17 +6726,19 @@ def apiquestioncat(req): return JsonResponse({"code": 1}) else: return JsonResponse({"code": 0}) - return JsonResponse({"code": 1}) elif a == 'detail': id = req.GET.get('id') a = Questioncat.objects.filter(id=id).values( - 'id', 'name', 'parent__id')[0] + 'id', 'name', 'parent__id', 'isopen')[0] return JsonResponse(a) elif a == 'edit': data = json.loads(req.body.decode('utf-8')) id = data['id'] a = Questioncat.objects.get(id=id) a.name = data['name'] + a.isopen = 0 + if 'isopen' in data: + a.isopen = 1 if 'parent' in data: if data['parent']: parent = Questioncat.objects.get(id=data['parent'])