|
@@ -1,6 +1,7 @@
|
|
|
#coding=utf-8
|
|
|
'''
|
|
|
'''
|
|
|
+import collections
|
|
|
import os,re,random
|
|
|
import json,time,datetime
|
|
|
import shutil
|
|
@@ -19,7 +20,7 @@ from utils.exceltool import ExcelTool
|
|
|
from utils.jgpush import send_notification_by_registration_ids
|
|
|
import wzhifuSDK as wxpay
|
|
|
from utils.exceltool import ExcelTool
|
|
|
-from utils.qrcodetool import gen_general_qrcode_img
|
|
|
+from utils.qrcodetool import gen_general_qrcode_img,gen_cus_qrcode_img
|
|
|
from django.db.models import Q,Sum,Count
|
|
|
from PIL import Image
|
|
|
from PIL import Image,ImageDraw,ImageFont
|
|
@@ -66,6 +67,16 @@ def add_model(cls,**kwargs):
|
|
|
template = cm.Template.objects.filter(id=template_id).first()
|
|
|
widget = json.loads(template.widget) if template.widget else {}
|
|
|
kwargs["widget"] = json.dumps(widget)
|
|
|
+ if model_name == "Verifier":
|
|
|
+ conference_id = kwargs.get("conference_id")
|
|
|
+ user_id = kwargs.get("user_id")
|
|
|
+ conference_name = cm.Conference.objects.filter(id=conference_id).first().name
|
|
|
+ user = cm.UserInfo.objects.filter(id=user_id).first()
|
|
|
+ user_name = user.nickname
|
|
|
+ user_avatar = user.avatar
|
|
|
+ kwargs["conference_name"] = conference_name
|
|
|
+ kwargs["user_name"] = user_name
|
|
|
+ kwargs["user_avatar"] = user_avatar
|
|
|
obj = model.objects.create(**kwargs)
|
|
|
#生成文件分享图片
|
|
|
if model_name == "Message":
|
|
@@ -74,18 +85,37 @@ def add_model(cls,**kwargs):
|
|
|
survey_img_file = os.path.join(root,"upload/survey_bg_{}.jpg".format(obj.id))
|
|
|
img = Image.open(survey_bg)
|
|
|
survey_name = obj.name
|
|
|
- for i,lst in enumerate(split_list_by_n(survey_name,10)):
|
|
|
+ publisher = u"发布单位:"+obj.publisher
|
|
|
+ #for i,lst in enumerate(split_list_by_n(survey_name,10)):
|
|
|
+ #for i,lst in enumerate(split_list_by_n(survey_name,6)):
|
|
|
+ for i,lst in enumerate(split_list_by_n(survey_name,9)):
|
|
|
+ num = len(lst)
|
|
|
name = "".join(lst)
|
|
|
if name:
|
|
|
- addText(img,survey_bg,name,survey_img_file,(200,235+(i+1)*80),72)
|
|
|
+ #addText(img,survey_bg,name,survey_img_file,(200,235+(i+1)*80),72)
|
|
|
+ #addText(img,survey_bg,name,survey_img_file,(300,435+(i+1)*80),82)
|
|
|
+ #addText(img,survey_bg,name,survey_img_file,(300+(6-num)/2.0*81,235+(i+1)*90),82)
|
|
|
+ addText(img,survey_bg,name,survey_img_file,(300+(6-num)/2.0*81,200+(i+1)*90),82)
|
|
|
+ #添加发布单位
|
|
|
+ #addText(img,survey_bg,unicode("发布单位","utf-8"),survey_img_file,(400,1380),62)
|
|
|
+ if obj.publisher:
|
|
|
+ for i,lst in enumerate(split_list_by_n(publisher,12)):
|
|
|
+ num = len(lst)
|
|
|
+ name = "".join(lst)
|
|
|
+ if name:
|
|
|
+ #addText(img,survey_bg,name,survey_img_file,(200,235+(i+1)*80),72)
|
|
|
+ #addText(img,survey_bg,name,survey_img_file,(300,435+(i+1)*80),82)
|
|
|
+ #addText(img,survey_bg,name,survey_img_file,(340+(6-num)/2.0*61,1400+(i+1)*82),62)
|
|
|
+ addText(img,survey_bg,name,survey_img_file,(170,1400+(i+1)*82),62)
|
|
|
#
|
|
|
url = os.path.join(settings.HOST,"survey/answer.html?id={}&type={}".format(obj.id,obj.type))
|
|
|
- print url,99999
|
|
|
tmp_qrcode = "/tmp/survey_qrcode_{}.png".format(obj.id)
|
|
|
- gen_general_qrcode_img(url,tmp_qrcode)
|
|
|
+ #gen_general_qrcode_img(url,tmp_qrcode)
|
|
|
+ gen_cus_qrcode_img(url,tmp_qrcode)
|
|
|
rawimg = Image.open(survey_img_file)
|
|
|
im = Image.open(tmp_qrcode)
|
|
|
- rawimg.paste(im,(330,840))
|
|
|
+ #rawimg.paste(im,(250,840))
|
|
|
+ rawimg.paste(im,(250,740))
|
|
|
rawimg.save(survey_img_file)
|
|
|
template_qrcode = os.path.join(settings.HOST,"upload/survey_bg_{}.jpg".format(obj.id))
|
|
|
obj.template_qrcode = template_qrcode
|
|
@@ -102,8 +132,18 @@ def update_model(cls,**kwargs):
|
|
|
#拷贝模板字段
|
|
|
template_id = kwargs.get("template_id")
|
|
|
template = cm.Template.objects.filter(id=template_id).first()
|
|
|
- widget = json.loads(template.widget) if template.widget else {}
|
|
|
- kwargs["widget"] = json.dumps(widget)
|
|
|
+ if template:
|
|
|
+ widget = json.loads(template.widget) if template.widget else {}
|
|
|
+ kwargs["widget"] = json.dumps(widget)
|
|
|
+ if model_name == "Signup":
|
|
|
+ #if kwargs.get("reject_reason"):
|
|
|
+ if "reject_reason" in kwargs:
|
|
|
+ obj = model.objects.filter(id=id).first()
|
|
|
+ reason = json.loads(obj.reject_reason) if obj.reject_reason else []
|
|
|
+ cid = kwargs.pop("uid")
|
|
|
+ cname = cm.SysUserInfo.objects.filter(id=cid).first().name
|
|
|
+ reason.append({"reason":kwargs.get("reject_reason"),"ctime":ccf.get_now_str(),"cid":cid,"cname":cname})
|
|
|
+ kwargs["reject_reason"] = json.dumps(reason)
|
|
|
rst = model.objects.filter(id=id).update(**kwargs)
|
|
|
if model_name == "Message":
|
|
|
obj = model.objects.filter(id=id).first()
|
|
@@ -112,21 +152,38 @@ def update_model(cls,**kwargs):
|
|
|
survey_img_file = os.path.join(root,"upload/survey_bg_{}.jpg".format(obj.id))
|
|
|
img = Image.open(survey_bg)
|
|
|
survey_name = obj.name
|
|
|
- for i,lst in enumerate(split_list_by_n(survey_name,10)):
|
|
|
+ publisher = u"发布单位:"+obj.publisher
|
|
|
+ #for i,lst in enumerate(split_list_by_n(survey_name,10)):
|
|
|
+ #for i,lst in enumerate(split_list_by_n(survey_name,6)):
|
|
|
+ for i,lst in enumerate(split_list_by_n(survey_name,9)):
|
|
|
+ num = len(lst)
|
|
|
name = "".join(lst)
|
|
|
if name:
|
|
|
- addText(img,survey_bg,name,survey_img_file,(200,235+(i+1)*80),72)
|
|
|
+ #addText(img,survey_bg,name,survey_img_file,(200,235+(i+1)*80),72)
|
|
|
+ #addText(img,survey_bg,name,survey_img_file,(300,435+(i+1)*80),82)
|
|
|
+ #addText(img,survey_bg,name,survey_img_file,(300+(6-num)/2.0*81,235+(i+1)*90),82)
|
|
|
+ addText(img,survey_bg,name,survey_img_file,(300+(6-num)/2.0*81,200+(i+1)*90),82)
|
|
|
+ #添加发布单位
|
|
|
+ #addText(img,survey_bg,unicode("发布单位","utf-8"),survey_img_file,(400,1380),62)
|
|
|
+ if obj.publisher:
|
|
|
+ for i,lst in enumerate(split_list_by_n(publisher,12)):
|
|
|
+ num = len(lst)
|
|
|
+ name = "".join(lst)
|
|
|
+ if name:
|
|
|
+ #addText(img,survey_bg,name,survey_img_file,(200,235+(i+1)*80),72)
|
|
|
+ #addText(img,survey_bg,name,survey_img_file,(300,435+(i+1)*80),82)
|
|
|
+ #addText(img,survey_bg,name,survey_img_file,(340+(6-num)/2.0*61,1400+(i+1)*82),62)
|
|
|
+ addText(img,survey_bg,name,survey_img_file,(170,1400+(i+1)*82),62)
|
|
|
#
|
|
|
url = os.path.join(settings.HOST,"survey/answer.html?id={}&type={}".format(obj.id,obj.type))
|
|
|
- print url,99999
|
|
|
tmp_qrcode = "/tmp/survey_qrcode_{}.png".format(obj.id)
|
|
|
- gen_general_qrcode_img(url,tmp_qrcode)
|
|
|
+ #gen_general_qrcode_img(url,tmp_qrcode)
|
|
|
+ gen_cus_qrcode_img(url,tmp_qrcode)
|
|
|
rawimg = Image.open(survey_img_file)
|
|
|
im = Image.open(tmp_qrcode)
|
|
|
- rawimg.paste(im,(330,840))
|
|
|
+ rawimg.paste(im,(250,840))
|
|
|
rawimg.save(survey_img_file)
|
|
|
template_qrcode = os.path.join(settings.HOST,"upload/survey_bg_{}.jpg?t={}".format(obj.id,str(time.time())))
|
|
|
- print template_qrcode,99999999999999999999
|
|
|
obj.template_qrcode = template_qrcode
|
|
|
obj.save()
|
|
|
return rst
|
|
@@ -151,8 +208,10 @@ def delete_model(cls,**kwargs):
|
|
|
ids = str(kwargs.get("id")).split(",")
|
|
|
|
|
|
rst = model.objects.filter(id__in=ids).delete()
|
|
|
- #if model_name == "Template":
|
|
|
- # cm.Message.objects.filter(template_id__in=ids).delete()
|
|
|
+ if model_name == "Hotel":
|
|
|
+ cm.Hotel.objects.filter(id__in=ids).delete()
|
|
|
+ cm.Room.objects.filter(hotel_id__in=ids).delete()
|
|
|
+ cm.ConferenceHotel.objects.filter(hotel_id__in=ids).delete()
|
|
|
return ids
|
|
|
|
|
|
def delete_model_actual(cls,**kwargs):
|
|
@@ -187,7 +246,6 @@ def get_detail_info(cls,**kwargs):
|
|
|
if csrobj:
|
|
|
result = json.loads(csrobj.result) if csrobj.result else {}
|
|
|
if result:
|
|
|
- print widget,9999
|
|
|
for w in widget:
|
|
|
w["result"] = result.get(w["label"])
|
|
|
w[w["label"]] = result.get(w["label"])
|
|
@@ -201,8 +259,34 @@ def get_detail_info(cls,**kwargs):
|
|
|
new_viewer_ids = filter(lambda x:x["id"]!=kwargs.get("cid"),viewer_ids)
|
|
|
new_viewer_ids.append({"id":kwargs.get("cid"),"time":ccf.get_now_str()})
|
|
|
model.objects.filter(id=id).update(viewer_id=json.dumps(new_viewer_ids))
|
|
|
+ if model_name == "Conference":
|
|
|
+ rst["signup_fields"] = json.loads(rst["signup_fields"] if rst["signup_fields"] else [])
|
|
|
+ rst["speaker"] = json.loads(rst["speaker"] if rst["speaker"] else [])
|
|
|
+ if model_name == "Activity":
|
|
|
+ rst["speaker"] = json.loads(rst["speaker"] if rst["speaker"] else [])
|
|
|
+ if model_name == "Hotel":
|
|
|
+ rst["imgs"] = json.loads(rst["imgs"]) if rst["imgs"] else []
|
|
|
+ #print rst,9999
|
|
|
+ rooms = list(cm.Room.objects.filter(hotel_id=rst["id"]).values())
|
|
|
+ for r in rooms:
|
|
|
+ r["imgs"] = json.loads(r["imgs"]) if r["imgs"] else []
|
|
|
+ rst["rooms"] = rooms
|
|
|
+ if model_name == "Journal":
|
|
|
+ rst["organizer_id"] = cm.JournalOrganizer.objects.filter(journal_id=rst["id"]).first().organizer_id
|
|
|
return rst
|
|
|
|
|
|
+def get_search_list(cls,**kwargs):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ model_name = re.search(r'.*\.(\w+)SearchView',str(cls.__class__)).groups()[0]
|
|
|
+ model = getattr(cm,model_name)
|
|
|
+ qset = model.objects.all()
|
|
|
+ if kwargs.get("name"):
|
|
|
+ qset = qset.filter(name__icontains=kwargs.get("name"))
|
|
|
+ data = list(qset.values("id","name"))
|
|
|
+ return data
|
|
|
+
|
|
|
+
|
|
|
def get_list_info(cls,**kwargs):
|
|
|
"""
|
|
|
"""
|
|
@@ -214,18 +298,25 @@ def get_list_info(cls,**kwargs):
|
|
|
qset = qset.filter(type=kwargs.get("type"))
|
|
|
qset = qset.order_by("-id")
|
|
|
else:
|
|
|
- qset = qset.filter(status=1).order_by("-id")
|
|
|
+ qset = qset.order_by("-id")
|
|
|
if kwargs.get("name"):
|
|
|
qset = qset.filter(name__icontains=kwargs.get("name"))
|
|
|
if model_name == "SysUserInfo":
|
|
|
if kwargs.get("journal_id"):
|
|
|
qset = qset.filter(journal_id=kwargs.get("journal_id"))
|
|
|
+ if model_name == "Signup":
|
|
|
+ if kwargs.get("conference_id"):
|
|
|
+ qset = qset.filter(conference_id=kwargs.get("conference_id"))
|
|
|
+ if kwargs.get("hotel_id"):
|
|
|
+ qset = qset.filter(hotel_id=kwargs.get("hotel_id"))
|
|
|
+ if kwargs.get("order_status"):
|
|
|
+ qset = qset.filter(signup_status=kwargs.get("order_status"))
|
|
|
+ if model_name == "Activity":
|
|
|
+ qset = qset.filter(type=kwargs.get("type"))
|
|
|
#数据权限处理
|
|
|
if model_name in ["Notice","Message"]:
|
|
|
cid = kwargs.get("cid")
|
|
|
- print cid,4444444444444444
|
|
|
user = cm.SysUserInfo.objects.filter(id=cid).first()
|
|
|
- print user.role_id
|
|
|
if user.role_id == 2:
|
|
|
if model_name == "Notice":
|
|
|
qset = qset.filter(receiver_id__icontains=",{}]".format(cid))
|
|
@@ -285,6 +376,23 @@ def get_list_info(cls,**kwargs):
|
|
|
# d["edit"] = 1
|
|
|
d["edit"] = 1
|
|
|
|
|
|
+ if model_name == "Verifier":
|
|
|
+ for d in data:
|
|
|
+ conference_id = d["conference_id"]
|
|
|
+ user_id = d["user_id"]
|
|
|
+ d["conference_name"] = cm.Conference.objects.filter(id=conference_id).first().name
|
|
|
+ d["avatar"] = cm.UserInfo.objects.filter(id=user_id).first().name
|
|
|
+
|
|
|
+ if model_name == "Article":
|
|
|
+ for d in data:
|
|
|
+ d["journal_name"] = cm.Journal.objects.filter(id=d["journal_id"]).first().name
|
|
|
+ if model_name == "Activity":
|
|
|
+ for d in data:
|
|
|
+ d["journal_name"] = cm.Journal.objects.filter(id=d["journal_id"]).first().name
|
|
|
+ if model_name == "Organizer":
|
|
|
+ for d in data:
|
|
|
+ d["journal_num"] = cm.Journal.objects.filter(organizer_id=d["id"]).count()
|
|
|
+
|
|
|
page = int(kwargs.get("page",0))
|
|
|
page_size = int(kwargs.get("page_size",20))
|
|
|
if page and page_size:
|
|
@@ -478,7 +586,6 @@ def send_messages(request):
|
|
|
vals["sender_user_type"] = utype
|
|
|
vals["message_type"] = "notice"
|
|
|
vals["receiver_utype"] = 3
|
|
|
- print vals,999999999999999999
|
|
|
if vals.get("send_type") == 1:
|
|
|
entset = cm.EnterPrise.objects.all()
|
|
|
if vals.get("area"):
|
|
@@ -494,7 +601,6 @@ def send_messages(request):
|
|
|
enterprise_ids = str(vals.get("receiver_ids")).split(",")
|
|
|
receiver_ids = list(cm.StaffUser.objects.filter(enterprise_id__in=enterprise_ids).values_list("id",flat=True))
|
|
|
receiver_ids = ",".join([str(x) for x in receiver_ids])
|
|
|
- print receiver_ids,99999999999999999999
|
|
|
vals["enterprise_ids"] = ",".join([str(x) for x in enterprise_ids])
|
|
|
vals["receiver_ids"] = receiver_ids
|
|
|
|
|
@@ -760,11 +866,9 @@ def get_dashboard_index(**vals):
|
|
|
fxlevels = [u"重大风险",u"较大风险",u"一般风险",u"低风险"]
|
|
|
for fx in fxlevels:
|
|
|
mtset = cm.MonitTask.objects.all()
|
|
|
- print fx
|
|
|
tmp = {}
|
|
|
tmp["name"] = fx
|
|
|
mtcount = mtset.values("enterprise_id").annotate(count=Count("enterprise_id"))
|
|
|
- print mtcount,555555555555555
|
|
|
data = []
|
|
|
for mtc in mtcount:
|
|
|
enterprise_id = mtc["enterprise_id"]
|
|
@@ -784,7 +888,6 @@ def get_dashboard_index(**vals):
|
|
|
# {"name":u"低风险","data":[{"enterprise_name":u"测试企业","value":100},{"enterprise_name":u"测试企业2","value":80}]}
|
|
|
#]
|
|
|
|
|
|
- print enterprise_fx_data,99999999999999999999
|
|
|
ret["enterprise_fx_data"] = enterprise_fx_data[:5]
|
|
|
#企业隐患统计
|
|
|
enterprise_yh_data = []
|
|
@@ -865,7 +968,6 @@ def get_dashboard_index(**vals):
|
|
|
riskpoint_count_data = []
|
|
|
spset = cm.MonitTask.objects.filter(enterprise_id=uid)
|
|
|
spcount = spset.values("riskpoint_item0").annotate(count=Count("riskpoint_item0"))
|
|
|
- print spcount,66666666666666666
|
|
|
for spc in spcount:
|
|
|
riskpoint_count_data.append({"name":spc["riskpoint_item0"],"value":spc["count"]})
|
|
|
ret["riskpoint_count_data"] = [
|
|
@@ -875,7 +977,6 @@ def get_dashboard_index(**vals):
|
|
|
ret["riskpoint_count_data"] = riskpoint_count_data
|
|
|
#时间任务统计
|
|
|
dates = ccf.get_month_dates()
|
|
|
- print dates
|
|
|
time_count = []
|
|
|
for date in dates:
|
|
|
st = "{}-{}-{} 00:00:00".format(date[0:4],date[4:6],date[6:8])
|
|
@@ -941,7 +1042,6 @@ def delete_goods(request):
|
|
|
"""
|
|
|
qdata = request.json
|
|
|
_id = qdata.get("id")
|
|
|
- print _id,999999999999
|
|
|
cm.Goods.objects.filter(id=_id).update(status=0)
|
|
|
|
|
|
def get_user_journals_list(request):
|
|
@@ -1041,15 +1141,11 @@ def recurse_del(list_data):
|
|
|
continue
|
|
|
|
|
|
if not list_data[index].get("children"):
|
|
|
- print "[Deleted] ", list_data[index]
|
|
|
del list_data[index]
|
|
|
else:
|
|
|
- print "[Recurved] ", list_data[index].get("children")
|
|
|
recurse_del(list_data[index].get("children"))
|
|
|
|
|
|
if not list_data[index].get("children"):
|
|
|
- print "[Deleted] ", list_data[index]
|
|
|
- print 1111111111
|
|
|
del list_data[index]
|
|
|
else:
|
|
|
index = index + 1
|
|
@@ -1166,11 +1262,20 @@ def get_survey_analyse_list_out(**kwargs):
|
|
|
_type = kwargs.get("type")
|
|
|
|
|
|
message = cm.Message.objects.filter(id=message_id).first()
|
|
|
- #template_id = message.template_id
|
|
|
- #template = cm.Template.objects.filter(id=template_id).first()
|
|
|
- #widgets = json.loads(template.widget) if template.widget else []
|
|
|
widgets = json.loads(message.widget) if message.widget else []
|
|
|
- headers = [x["label"] for x in widgets]
|
|
|
+ #新增域组件后处理
|
|
|
+ new_widgets = []
|
|
|
+ for wdg in widgets:
|
|
|
+ if not wdg["type"] == "group":
|
|
|
+ new_widgets.append(wdg)
|
|
|
+ else:
|
|
|
+ for cwdg in wdg["children"]:
|
|
|
+ cwdg["label"] = cwdg["label"] + "("+wdg["label"]+")"
|
|
|
+ new_widgets.append(cwdg)
|
|
|
+ #headers = [x["label"] for x in widgets]
|
|
|
+ #headers = [x["label"] for x in new_widgets]
|
|
|
+ headers = [{"label":x["label"],"type":x["type"]} for x in new_widgets]
|
|
|
+
|
|
|
msrset = cm.MessageSurveyResult.objects.filter(message_id=message_id)
|
|
|
if kwargs.get("name"):
|
|
|
msrset = msrset.filter(result__icontains=kwargs.get("name"))
|
|
@@ -1179,7 +1284,8 @@ def get_survey_analyse_list_out(**kwargs):
|
|
|
for item in msrdata:
|
|
|
row = {}
|
|
|
rst = json.loads(item["result"])
|
|
|
- for label in headers:
|
|
|
+ for h in headers:
|
|
|
+ label = h["label"]
|
|
|
#row["label"] = headers
|
|
|
#row[label] = label
|
|
|
row["post_time"] = item["ctime"]
|
|
@@ -1201,9 +1307,17 @@ def get_survey_question_analyse_list(**kwargs):
|
|
|
message_id = kwargs.get("id")
|
|
|
_type = kwargs.get("type")
|
|
|
message = cm.Message.objects.filter(id=message_id).first()
|
|
|
- #template = cm.Template.objects.filter(id=message.template_id).first()
|
|
|
- #widgets = json.loads(template.widget) if template.widget else []
|
|
|
widgets = json.loads(message.widget) if message.widget else []
|
|
|
+ #新增域组件后处理
|
|
|
+ new_widgets = []
|
|
|
+ for wdg in widgets:
|
|
|
+ if not wdg["type"] == "group":
|
|
|
+ new_widgets.append(wdg)
|
|
|
+ else:
|
|
|
+ for cwdg in wdg["children"]:
|
|
|
+ cwdg["label"] = cwdg["label"] + "("+wdg["label"]+")"
|
|
|
+ new_widgets.append(cwdg)
|
|
|
+ widgets = new_widgets
|
|
|
#填报结果
|
|
|
results = cm.MessageSurveyResult.objects.filter(message_id=message_id)
|
|
|
for wd in widgets:
|
|
@@ -1227,7 +1341,7 @@ def get_survey_question_analyse_list(**kwargs):
|
|
|
item["total"] += 1
|
|
|
if value in rst.get(label):
|
|
|
item["times"] += 1
|
|
|
- item["sale"] = round(float(item["times"])/item["total"]*100,2)
|
|
|
+ item["sale"] = round(float(item["times"])/item["total"]*100,2) if item["total"] else 0.0
|
|
|
if wd["type"] == "radio":
|
|
|
items = wd["items"]
|
|
|
for item in items:
|
|
@@ -1240,6 +1354,12 @@ def get_survey_question_analyse_list(**kwargs):
|
|
|
if value == rst.get(label):
|
|
|
item["times"] += 1
|
|
|
item["sale"] = round(float(item["times"])/item["total"]*100,2)
|
|
|
+ #图片
|
|
|
+ if wd["type"] == "image":
|
|
|
+ for item in results:
|
|
|
+ rst = json.loads(item.result)
|
|
|
+ result.extend(rst.get(label))
|
|
|
+
|
|
|
wd["result"] = result
|
|
|
|
|
|
return widgets
|
|
@@ -1306,10 +1426,18 @@ def download_survey_result_out(request):
|
|
|
_type = qdata.get("type")
|
|
|
|
|
|
message = cm.Message.objects.filter(id=message_id).first()
|
|
|
- #template_id = message.template_id
|
|
|
- #template = cm.Template.objects.filter(id=template_id).first()
|
|
|
- #widgets = json.loads(template.widget) if template.widget else []
|
|
|
widgets = json.loads(message.widget) if message.widget else []
|
|
|
+ #新增域组件后处理
|
|
|
+ new_widgets = []
|
|
|
+ for wdg in widgets:
|
|
|
+ if not wdg["type"] == "group":
|
|
|
+ new_widgets.append(wdg)
|
|
|
+ else:
|
|
|
+ for cwdg in wdg["children"]:
|
|
|
+ cwdg["label"] = cwdg["label"] + "("+wdg["label"]+")"
|
|
|
+ new_widgets.append(cwdg)
|
|
|
+ widgets = new_widgets
|
|
|
+
|
|
|
headers = [x["label"] for x in widgets]
|
|
|
msrset = cm.MessageSurveyResult.objects.filter(message_id=message_id)
|
|
|
msrdata = list(msrset.values())
|
|
@@ -1318,7 +1446,11 @@ def download_survey_result_out(request):
|
|
|
row = []
|
|
|
rst = json.loads(item["result"])
|
|
|
for label in headers:
|
|
|
- row.append(rst.get(label))
|
|
|
+ #row.append(rst.get(label))
|
|
|
+ ans = rst.get(label)
|
|
|
+ if isinstance(ans,type([])):
|
|
|
+ ans = ",".join(ans)
|
|
|
+ row.append(ans)
|
|
|
row.append(ccf.datetime_to_str(item["ctime"]))
|
|
|
data.append(row)
|
|
|
exceltool = ExcelTool("/tmp/demo.xls")
|
|
@@ -1340,10 +1472,17 @@ def download_survey_result_all(request):
|
|
|
_type = qdata.get("type")
|
|
|
|
|
|
message = cm.Message.objects.filter(id=message_id).first()
|
|
|
- #template_id = message.template_id
|
|
|
- #template = cm.Template.objects.filter(id=template_id).first()
|
|
|
- #widgets = json.loads(template.widget) if template.widget else []
|
|
|
widgets = json.loads(message.widget) if message.widget else []
|
|
|
+ #新增域组件后处理
|
|
|
+ new_widgets = []
|
|
|
+ for wdg in widgets:
|
|
|
+ if not wdg["type"] == "group":
|
|
|
+ new_widgets.append(wdg)
|
|
|
+ else:
|
|
|
+ for cwdg in wdg["children"]:
|
|
|
+ cwdg["label"] = cwdg["label"] + "("+wdg["label"]+")"
|
|
|
+ new_widgets.append(cwdg)
|
|
|
+ widgets = new_widgets
|
|
|
headers = [x["label"] for x in widgets]
|
|
|
msrset = cm.MessageSurveyResult.objects.filter(message_id=message_id)
|
|
|
msrdata = list(msrset.values())
|
|
@@ -1357,7 +1496,11 @@ def download_survey_result_all(request):
|
|
|
row = [realname,journal_name]
|
|
|
rst = json.loads(item["result"])
|
|
|
for label in headers:
|
|
|
- row.append(rst.get(label))
|
|
|
+ #row.append(rst.get(label))
|
|
|
+ ans = rst.get(label)
|
|
|
+ if isinstance(ans,type([])):
|
|
|
+ ans = ",".join(ans)
|
|
|
+ row.append(ans)
|
|
|
row.append(ccf.datetime_to_str(item["ctime"]))
|
|
|
data.append(row)
|
|
|
headers = [u"管理员姓名",u"所属期刊"]+headers
|
|
@@ -1366,7 +1509,11 @@ def download_survey_result_all(request):
|
|
|
row = []
|
|
|
rst = json.loads(item["result"])
|
|
|
for label in headers:
|
|
|
- row.append(rst.get(label))
|
|
|
+ #row.append(rst.get(label))
|
|
|
+ ans = rst.get(label)
|
|
|
+ if isinstance(ans,type([])):
|
|
|
+ ans = ",".join(ans)
|
|
|
+ row.append(ans)
|
|
|
row.append(ccf.datetime_to_str(item["ctime"]))
|
|
|
data.append(row)
|
|
|
exceltool = ExcelTool("/tmp/demo.xls")
|
|
@@ -1389,10 +1536,17 @@ def download_survey_result_item(request):
|
|
|
item = qdata.get("item")
|
|
|
|
|
|
message = cm.Message.objects.filter(id=message_id).first()
|
|
|
- #template_id = message.template_id
|
|
|
- #template = cm.Template.objects.filter(id=template_id).first()
|
|
|
- #widgets = json.loads(template.widget) if template.widget else []
|
|
|
widgets = json.loads(message.widget) if message.widget else []
|
|
|
+ #新增域组件后处理
|
|
|
+ new_widgets = []
|
|
|
+ for wdg in widgets:
|
|
|
+ if not wdg["type"] == "group":
|
|
|
+ new_widgets.append(wdg)
|
|
|
+ else:
|
|
|
+ for cwdg in wdg["children"]:
|
|
|
+ cwdg["label"] = cwdg["label"] + "("+wdg["label"]+")"
|
|
|
+ new_widgets.append(cwdg)
|
|
|
+ widgets = new_widgets
|
|
|
if item:
|
|
|
widgets = filter(lambda x:x["label"]==item,widgets)
|
|
|
headers = [x["label"] for x in widgets]
|
|
@@ -1408,7 +1562,11 @@ def download_survey_result_item(request):
|
|
|
row = [realname,journal_name]
|
|
|
rst = json.loads(item["result"])
|
|
|
for label in headers:
|
|
|
- row.append(rst.get(label))
|
|
|
+ #row.append(rst.get(label))
|
|
|
+ ans = rst.get(label)
|
|
|
+ if isinstance(ans,type([])):
|
|
|
+ ans = ",".join(ans)
|
|
|
+ row.append(ans)
|
|
|
row.append(ccf.datetime_to_str(item["ctime"]))
|
|
|
data.append(row)
|
|
|
headers = [u"管理员姓名",u"所属期刊"]+headers
|
|
@@ -1417,7 +1575,10 @@ def download_survey_result_item(request):
|
|
|
row = []
|
|
|
rst = json.loads(item["result"])
|
|
|
for label in headers:
|
|
|
- row.append(rst.get(label))
|
|
|
+ ans = rst.get(label)
|
|
|
+ if isinstance(ans,type([])):
|
|
|
+ ans = ",".join(ans)
|
|
|
+ row.append(ans)
|
|
|
row.append(ccf.datetime_to_str(item["ctime"]))
|
|
|
data.append(row)
|
|
|
exceltool = ExcelTool("/tmp/demo.xls")
|
|
@@ -1426,6 +1587,75 @@ def download_survey_result_item(request):
|
|
|
return xlsdata
|
|
|
|
|
|
|
|
|
+def show_survey_result_item(request):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ qdata = request.json
|
|
|
+ need_params = ["message_id"]
|
|
|
+ mse = ccf.check_params(*need_params,**qdata)
|
|
|
+ if mse:
|
|
|
+ raise ce.TipException(mse)
|
|
|
+
|
|
|
+ message_id = qdata.get("message_id")
|
|
|
+ _type = qdata.get("type")
|
|
|
+ item = qdata.get("item")
|
|
|
+ curitem = qdata.get("item")
|
|
|
+ name = qdata.get("name")
|
|
|
+
|
|
|
+ message = cm.Message.objects.filter(id=message_id).first()
|
|
|
+ widgets = json.loads(message.widget) if message.widget else []
|
|
|
+ #新增域组件后处理
|
|
|
+ new_widgets = []
|
|
|
+ for wdg in widgets:
|
|
|
+ if not wdg["type"] == "group":
|
|
|
+ new_widgets.append(wdg)
|
|
|
+ else:
|
|
|
+ for cwdg in wdg["children"]:
|
|
|
+ cwdg["label"] = cwdg["label"] + "("+wdg["label"]+")"
|
|
|
+ new_widgets.append(cwdg)
|
|
|
+ widgets = new_widgets
|
|
|
+ if item:
|
|
|
+ widgets = filter(lambda x:x["label"]==item,widgets)
|
|
|
+ headers = [x["label"] for x in widgets]
|
|
|
+ #headers = [{"type":x["type"],"label":x["label"]} for x in widgets]
|
|
|
+ msrset = cm.MessageSurveyResult.objects.filter(message_id=message_id)
|
|
|
+ msrdata = list(msrset.values())
|
|
|
+ data = []
|
|
|
+ if int(_type) == 0:
|
|
|
+ for item in msrdata:
|
|
|
+ cid = item["cid"]
|
|
|
+ cuser = cm.SysUserInfo.objects.filter(id=cid).first()
|
|
|
+ realname = cuser.realname
|
|
|
+ journal_name = cm.Journal.objects.filter(id=cuser.journal_id).first().name
|
|
|
+ row = collections.OrderedDict()
|
|
|
+ #row.update({"realname":realname,"journal_name":journal_name,"ctime":ccf.datetime_to_str(item["ctime"])})
|
|
|
+ row[u"姓名"]=realname
|
|
|
+ row[u"所属期刊"]=journal_name
|
|
|
+ rst = json.loads(item["result"])
|
|
|
+ for label in headers:
|
|
|
+ #row.append({label:rst.get(label)})
|
|
|
+ #row.update({label:rst.get(label)})
|
|
|
+ row[label] = rst.get(label)
|
|
|
+ row["填报时间"]=ccf.datetime_to_str(item["ctime"])
|
|
|
+ #row.append(ccf.datetime_to_str(item["ctime"]))
|
|
|
+ data.append(row)
|
|
|
+ headers = [u"管理员姓名",u"所属期刊"]+headers
|
|
|
+ else:
|
|
|
+ for item in msrdata:
|
|
|
+ row = collections.OrderedDict()
|
|
|
+ #row.update({"ctime":ccf.datetime_to_str(item["ctime"])})
|
|
|
+ rst = json.loads(item["result"])
|
|
|
+ print headers
|
|
|
+ for label in headers:
|
|
|
+ row[label] = rst.get(label)
|
|
|
+ #row.append(ccf.datetime_to_str(item["ctime"]))
|
|
|
+ row["填报时间"]=ccf.datetime_to_str(item["ctime"])
|
|
|
+ data.append(row)
|
|
|
+ if name:
|
|
|
+ data = filter(lambda x:name in x[curitem],data)
|
|
|
+ return data
|
|
|
+
|
|
|
+
|
|
|
def get_notice_analyse(**kwargs):
|
|
|
"""获取内部消息分析统计
|
|
|
"""
|
|
@@ -1527,3 +1757,321 @@ def get_message_out_info(**kwargs):
|
|
|
#rst["widget"] = json.loads(tpl["widget"]) if tpl else []
|
|
|
rst["widget"] = json.loads(rst["widget"]) if rst["widget"] else []
|
|
|
return rst
|
|
|
+
|
|
|
+
|
|
|
+def add_hotel(**kwargs):
|
|
|
+ """添加酒店
|
|
|
+ """
|
|
|
+ if "id" in kwargs:
|
|
|
+ kwargs.pop("id")
|
|
|
+ kwargs["imgs"] = json.dumps(kwargs["imgs"])
|
|
|
+ rooms = kwargs.pop("rooms")
|
|
|
+ hobj = cm.Hotel.objects.create(**kwargs)
|
|
|
+ for room in rooms:
|
|
|
+ if "id" in room:
|
|
|
+ room.pop("id")
|
|
|
+ room["imgs"] = json.dumps(room["imgs"])
|
|
|
+ room["hotel_id"] = hobj.id
|
|
|
+ cm.Room.objects.create(**room)
|
|
|
+ return hobj.id
|
|
|
+
|
|
|
+def update_hotel(**kwargs):
|
|
|
+ """修改酒店
|
|
|
+ """
|
|
|
+ id = kwargs.pop("id")
|
|
|
+ rooms = kwargs.pop("rooms")
|
|
|
+ cm.Hotel.objects.filter(id=id).update(**kwargs)
|
|
|
+ for room in rooms:
|
|
|
+ room["hotel_id"] = id
|
|
|
+ room["imgs"] = json.dumps(room["imgs"])
|
|
|
+ if "id" in room:
|
|
|
+ rid = room.pop("id")
|
|
|
+ cm.Room.objects.filter(id=rid).update(**room)
|
|
|
+ else:
|
|
|
+ cm.Room.objects.create(**room)
|
|
|
+
|
|
|
+def delete_hotel(**kwargs):
|
|
|
+ """删除酒店
|
|
|
+ """
|
|
|
+
|
|
|
+
|
|
|
+def add_conference_hotel(**kwargs):
|
|
|
+ """为会议添加酒店
|
|
|
+ """
|
|
|
+ conference_id = kwargs.pop("conference_id")
|
|
|
+ hid = add_hotel(**kwargs)
|
|
|
+ obj = cm.ConferenceHotel.objects.create(
|
|
|
+ conference_id=conference_id,hotel_id=hid)
|
|
|
+ obj.order = obj.id
|
|
|
+ obj.save()
|
|
|
+
|
|
|
+
|
|
|
+def get_conference_hotels(**kwargs):
|
|
|
+ """获取会议酒店信息
|
|
|
+ """
|
|
|
+ conference_id = kwargs.pop("conference_id")
|
|
|
+ hotel_ids = cm.ConferenceHotel.objects.filter(conference_id=conference_id)\
|
|
|
+ .order_by("-order").values_list("hotel_id",flat=True)
|
|
|
+ hotels = []
|
|
|
+ for hid in hotel_ids:
|
|
|
+ ht = cm.Hotel.objects.filter(id=hid).values().first()
|
|
|
+ ht["imgs"] = json.loads(ht["imgs"]) if ht["imgs"] else []
|
|
|
+ rooms = list(cm.Room.objects.filter(hotel_id=ht["id"]).values())
|
|
|
+ for r in rooms:
|
|
|
+ r["imgs"] = json.loads(r["imgs"]) if r["imgs"] else []
|
|
|
+ ht["rooms"] = rooms
|
|
|
+ hotels.append(ht)
|
|
|
+ return hotels
|
|
|
+
|
|
|
+
|
|
|
+def delete_conference_hotel(**kwargs):
|
|
|
+ """删除会议酒店
|
|
|
+ """
|
|
|
+ conference_id = kwargs.pop("conference_id")
|
|
|
+ hotel_id = kwargs.pop("hotel_id")
|
|
|
+ cm.ConferenceHotel.objects.filter(
|
|
|
+ conference_id=conference_id,hotel_id=hotel_id).delete()
|
|
|
+ if cm.Signup.objects.filter(hotel_id=hotel_id).exists():
|
|
|
+ raise ce.TipException(u"该酒店已经有人预定不能删除!")
|
|
|
+ cm.Hotel.objects.filter(id=hotel_id).delete()
|
|
|
+ cm.Room.objects.filter(hotel_id=hotel_id).delete()
|
|
|
+
|
|
|
+
|
|
|
+def rank_conference_hotels(**kwargs):
|
|
|
+ """会议酒店信息排序
|
|
|
+ """
|
|
|
+ conference_id = kwargs.pop("conference_id")
|
|
|
+ hotel_id = kwargs.pop("hotel_id")
|
|
|
+ rank = kwargs.pop("rank")
|
|
|
+ chset = cm.ConferenceHotel.objects.all().order_by("order")
|
|
|
+ src_rank_list = list(chset.values_list("order",flat=True))
|
|
|
+ src_rank_list.sort()
|
|
|
+ cur_obj = cm.ConferenceHotel.objects.filter(conference_id=conference_id,
|
|
|
+ hotel_id=hotel_id).first()
|
|
|
+ cur_rank = cur_obj.order
|
|
|
+ cur_index = src_rank_list.index(cur_rank)
|
|
|
+ if rank == "down" and cur_index == 0:
|
|
|
+ raise ce.TipException(u"已经在最后面无法下移!")
|
|
|
+ if rank == "up" and cur_index == len(src_rank_list)-1:
|
|
|
+ raise ce.TipException(u"已经在最前面无法上移!")
|
|
|
+ if rank == "down":
|
|
|
+ cur_obj.order = chset[cur_index-1].order
|
|
|
+ chset.filter(order=chset[cur_index-1].order).update(order=cur_rank)
|
|
|
+ cur_obj.save()
|
|
|
+ if rank == "up":
|
|
|
+ cur_obj.order = chset[cur_index+1].order
|
|
|
+ chset.filter(order=chset[cur_index].order).update(order=cur_rank)
|
|
|
+ cur_obj.save()
|
|
|
+
|
|
|
+
|
|
|
+def show_journal_info(**kwargs):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ id = kwargs.get("id")
|
|
|
+ data = list(cm.Journal.objects.filter(id=id).values())
|
|
|
+ rst = data[0] if data else {}
|
|
|
+ #活动回顾
|
|
|
+ #old_activity = list(cm.Activity.objects.filter(journal_id=id,type=1).values()[:3])
|
|
|
+ old_activity = list(cm.Activity.objects.filter(type=1).values()[:3])
|
|
|
+ #活动预告
|
|
|
+ #new_activity = list(cm.Activity.objects.filter(journal_id=id,type=0).values()[:3])
|
|
|
+ new_activity = list(cm.Activity.objects.filter(type=0).values()[:3])
|
|
|
+ #精品文章
|
|
|
+ #good_article = list(cm.Article.objects.filter(journal_id=id).values()[:3])
|
|
|
+ good_article = list(cm.Article.objects.filter().values()[:3])
|
|
|
+ rst["old_activity"] = old_activity
|
|
|
+ rst["new_activity"] = new_activity
|
|
|
+ rst["good_article"] = good_article
|
|
|
+ return rst
|
|
|
+
|
|
|
+
|
|
|
+def get_index_data(**kwargs):
|
|
|
+ """获取首页数据统计
|
|
|
+ """
|
|
|
+ ret = {}
|
|
|
+ journal_total = cm.Journal.objects.all().count()
|
|
|
+ article_total = cm.Article.objects.all().count()
|
|
|
+ activity_total = cm.Activity.objects.all().count()
|
|
|
+ conference_total = cm.Conference.objects.all().count()
|
|
|
+ signup_total = cm.Signup.objects.all().count()
|
|
|
+ article_readnum = cm.Article.objects.aggregate(total=Sum("read_num")).get("total")
|
|
|
+ article_forwardnum = cm.Article.objects.aggregate(total=Sum("forward_num")).get("total")
|
|
|
+ #学科期刊分布
|
|
|
+ subject_journal = cm.Journal.objects.values("subject_id").annotate(count=Count("subject_id")).order_by("-count")[:10]
|
|
|
+ for sj in subject_journal:
|
|
|
+ sj["name"] = cm.Subject.objects.filter(id=sj["subject_id"]).first().name
|
|
|
+ sj["value"] = sj["count"]
|
|
|
+ #单位期刊分布
|
|
|
+ organizer_journal = cm.Journal.objects.values("organizer_id").annotate(count=Count("organizer_id")).order_by("-count")[:10]
|
|
|
+ for oj in organizer_journal:
|
|
|
+ oj["name"] = cm.Organizer.objects.filter(id=oj["organizer_id"]).first().name
|
|
|
+ oj["value"] = oj["count"]
|
|
|
+ #期刊文章分布
|
|
|
+ journal_article = cm.Article.objects.values("journal_id").annotate(count=Count("journal_id")).order_by("-count")[:10]
|
|
|
+ for ja in journal_article:
|
|
|
+ ja["journal_name"] = cm.Journal.objects.filter(id=ja["journal_id"]).first().name
|
|
|
+ ja["name"] = ja["journal_name"]
|
|
|
+ ja["value"] = ja["count"]
|
|
|
+ #文章发布时间统计
|
|
|
+ sql = "select id,count(id) as count,DATE(publish_time) as publish_time from ted_article GROUP BY DATE(publish_time) ORDER BY publish_time"
|
|
|
+ artset = cm.Article.objects.raw(sql)
|
|
|
+ pubtime_article = []
|
|
|
+ for art in artset:
|
|
|
+ pubtime_article.append({"publish_time":art.publish_time,"count":art.count})
|
|
|
+ #文章阅读量统计top5
|
|
|
+ article_readnum_top5 = cm.Article.objects.order_by("-read_num")[:5].values("name","read_num")
|
|
|
+ #会议主办方统计
|
|
|
+ organizer_conference = cm.Conference.objects.values("organizer_id").annotate(count=Count("organizer_id")).order_by("-count")[:10]
|
|
|
+ for oc in organizer_conference:
|
|
|
+ oc["organizer_name"] = cm.Organizer.objects.filter(id=oc["organizer_id"]).first().name
|
|
|
+ #会议时间统计
|
|
|
+ sql = "select id,count(id) as count,DATE(ctime) as ctime from ted_conference GROUP BY DATE(ctime) ORDER BY ctime"
|
|
|
+ conset = cm.Conference.objects.raw(sql)
|
|
|
+ pubtime_conference = []
|
|
|
+ for con in conset:
|
|
|
+ pubtime_conference.append({"publish_time":con.ctime,"count":con.count})
|
|
|
+ #搜索热词
|
|
|
+ search_hot_word = [
|
|
|
+ {"name":u"物理","value":10},
|
|
|
+ {"name":u"激光","value":2},
|
|
|
+ {"name":u"科技","value":5},
|
|
|
+ {"name":u"研究所","value":6}
|
|
|
+ ]
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ ret["journal_total"] = journal_total
|
|
|
+ ret["article_total"] = article_total
|
|
|
+ ret["activity_total"] = activity_total
|
|
|
+ ret["conference_total"] = conference_total
|
|
|
+ ret["signup_total"] = signup_total
|
|
|
+ ret["article_readnum"] = article_readnum
|
|
|
+ ret["article_forwardnum"] = article_forwardnum
|
|
|
+ ret["subject_journal"] = list(subject_journal)
|
|
|
+ ret["organizer_journal"] = list(organizer_journal)
|
|
|
+ ret["journal_article"] = list(journal_article)
|
|
|
+ ret["journal_article_top5"] = list(journal_article[:5])
|
|
|
+ ret["pubtime_article"] = list(pubtime_article)
|
|
|
+ ret["article_readnum_top5"] = list(article_readnum_top5)
|
|
|
+ ret["organizer_conference"] = list(organizer_conference)
|
|
|
+ ret["pubtime_conference"] = list(pubtime_conference)
|
|
|
+ ret["search_hot_word"] = search_hot_word
|
|
|
+
|
|
|
+ return ret
|
|
|
+
|
|
|
+
|
|
|
+def download_journal(request):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ qdata = request.json
|
|
|
+
|
|
|
+ header = [u"期刊id",u"期刊名称",u"中文名称",u"外文名称"]
|
|
|
+ data = []
|
|
|
+ jouset = cm.Journal.objects.all()
|
|
|
+ for js in jouset:
|
|
|
+ data.append([
|
|
|
+ js.journal_id,
|
|
|
+ js.name,
|
|
|
+ js.cname,
|
|
|
+ js.ename
|
|
|
+ ])
|
|
|
+
|
|
|
+ exceltool = ExcelTool("/tmp/demo.xls")
|
|
|
+ xlsdata = exceltool.save_data(u"期刊数据表",header,data)
|
|
|
+ return xlsdata
|
|
|
+
|
|
|
+
|
|
|
+def download_organizer(request):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ qdata = request.json
|
|
|
+
|
|
|
+ header = [u"单位名称",u"单位简介"]
|
|
|
+ data = []
|
|
|
+ qset = cm.Organizer.objects.all()
|
|
|
+ for obj in qset:
|
|
|
+ data.append([
|
|
|
+ obj.name,
|
|
|
+ obj.desc
|
|
|
+ ])
|
|
|
+
|
|
|
+ exceltool = ExcelTool("/tmp/demo.xls")
|
|
|
+ xlsdata = exceltool.save_data(u"主办单位数据表",header,data)
|
|
|
+ return xlsdata
|
|
|
+
|
|
|
+
|
|
|
+def download_subject(request):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ qdata = request.json
|
|
|
+
|
|
|
+ header = [u"学科名称",u"学科简介"]
|
|
|
+ data = []
|
|
|
+ qset = cm.Subject.objects.all()
|
|
|
+ for obj in qset:
|
|
|
+ data.append([
|
|
|
+ obj.name,
|
|
|
+ obj.desc
|
|
|
+ ])
|
|
|
+
|
|
|
+ exceltool = ExcelTool("/tmp/demo.xls")
|
|
|
+ xlsdata = exceltool.save_data(u"学科数据表",header,data)
|
|
|
+ return xlsdata
|
|
|
+
|
|
|
+
|
|
|
+def download_signup(request):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ qdata = request.json
|
|
|
+
|
|
|
+ header = [u"会议名称",u"真实姓名"]
|
|
|
+ data = []
|
|
|
+ qset = cm.Signup.objects.all()
|
|
|
+ for obj in qset:
|
|
|
+ data.append([
|
|
|
+ obj.conference_name,
|
|
|
+ obj.name
|
|
|
+ ])
|
|
|
+
|
|
|
+ exceltool = ExcelTool("/tmp/demo.xls")
|
|
|
+ xlsdata = exceltool.save_data(u"报名数据表",header,data)
|
|
|
+ return xlsdata
|
|
|
+
|
|
|
+
|
|
|
+def download_verifier(request):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ qdata = request.json
|
|
|
+
|
|
|
+ header = [u"核销员昵称",u"所属会议","创建时间"]
|
|
|
+ data = []
|
|
|
+ qset = cm.Verifier.objects.all()
|
|
|
+ for obj in qset:
|
|
|
+ data.append([
|
|
|
+ obj.conference_name,
|
|
|
+ obj.user_name,
|
|
|
+ obj.ctime
|
|
|
+ ])
|
|
|
+
|
|
|
+ exceltool = ExcelTool("/tmp/demo.xls")
|
|
|
+ xlsdata = exceltool.save_data(u"核销员",header,data)
|
|
|
+ return xlsdata
|
|
|
+
|
|
|
+
|
|
|
+def download_hotel(request):
|
|
|
+ """
|
|
|
+ """
|
|
|
+ qdata = request.json
|
|
|
+
|
|
|
+ header = [u"酒店名称",u"创建时间"]
|
|
|
+ data = []
|
|
|
+ qset = cm.Hotel.objects.all()
|
|
|
+ for obj in qset:
|
|
|
+ data.append([
|
|
|
+ obj.name,
|
|
|
+ obj.ctime
|
|
|
+ ])
|
|
|
+
|
|
|
+ exceltool = ExcelTool("/tmp/demo.xls")
|
|
|
+ xlsdata = exceltool.save_data(u"酒店",header,data)
|
|
|
+ return xlsdata
|