add message

This commit is contained in:
baoliang 2020-10-18 00:00:23 +08:00
parent e6e9ad93bd
commit 40f57f62d6
9 changed files with 200 additions and 25 deletions

View File

@ -6,6 +6,10 @@
<div class="col-xs-12"> <div class="col-xs-12">
<div id="chart1" style="width: 100%%;height:400px;margin:20px 10px;"></div> <div id="chart1" style="width: 100%%;height:400px;margin:20px 10px;"></div>
</div> </div>
<div class="col-xs-12">
<div id="chart2" style="width: 100%%;height:400px;margin:20px 10px;"></div>
</div>
</div> </div>
</div> </div>
{% endblock%} {% endblock%}
@ -99,7 +103,7 @@
}; };
var option = { var option = {
title: { title: {
text: '逐月累计发文量', text: '全省政务新媒体更新次数(逐月)',
subtextStyle: { subtextStyle: {
fontSize: 16, fontSize: 16,
}, },
@ -163,5 +167,158 @@
] ]
}; };
myChart.setOption(option); myChart.setOption(option);
var myChart2 = echarts.init(document.getElementById('chart2'));
var posList = [
'left', 'right', 'top', 'bottom',
'inside',
'insideTop', 'insideLeft', 'insideRight', 'insideBottom',
'insideTopLeft', 'insideTopRight', 'insideBottomLeft', 'insideBottomRight'
];
myChart2.configParameters = {
rotate: {
min: -90,
max: 90
},
align: {
options: {
left: 'left',
center: 'center',
right: 'right'
}
},
verticalAlign: {
options: {
top: 'top',
middle: 'middle',
bottom: 'bottom'
}
},
position: {
options: echarts.util.reduce(posList, function (map, pos) {
map[pos] = pos;
return map;
}, {})
},
distance: {
min: 0,
max: 100
}
};
myChart2.config = {
rotate: 90,
align: 'left',
verticalAlign: 'middle',
position: 'insideBottom',
distance: 15,
onChange: function () {
var labelOption = {
normal: {
rotate: myChart2.config.rotate,
align: myChart2.config.align,
verticalAlign: myChart2.config.verticalAlign,
position: myChart2.config.position,
distance: myChart2.config.distance
}
};
myChart2.setOption({
series: [{
label: labelOption
}, {
label: labelOption
}, {
label: labelOption
}, {
label: labelOption
}]
});
}
};
var labelOption = {
show: true,
position: myChart.config.position,
distance: myChart.config.distance,
align: myChart.config.align,
verticalAlign: myChart.config.verticalAlign,
rotate: myChart.config.rotate,
formatter: '{c} {name|{a}}',
fontSize: 8,
rich: {
name: {
textBorderColor: '#fff'
}
}
};
var option = {
title: {
text: '全省政务新媒体开设数量(逐月)',
subtextStyle: {
fontSize: 16,
},
left: 'center'
},
color: ['#003366', '#006699', '#4cabce', '#e5323e', '#ccc'],
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
legend: {
top: '10%',
data: ['微信', '微博', '头条', '抖音', '其它']
},
xAxis: [
{
type: 'category',
axisTick: {show: false},
data: ['6月','7月', '8月', '9月', '10月']
}
],
yAxis: [
{
type: 'value'
}
],
series: [
{
name: '微信',
type: 'bar',
barGap: 0,
label: labelOption,
data: [40, 80, 44, 36, 78]
},
{
name: '微博',
type: 'bar',
label: labelOption,
data: [25, 14, 41, 10, 18]
},
{
name: '头条',
type: 'bar',
label: labelOption,
data: [21, 32, 21, 14, 19]
},
{
name: '抖音',
type: 'bar',
label: labelOption,
data: [98, 77, 101, 99, 40]
},
{
name: '其他',
type: 'bar',
label: labelOption,
data: [25, 32, 46, 20, 8]
}
]
};
myChart2.setOption(option);
</script> </script>
{% endblock %} {% endblock %}

View File

@ -16,7 +16,7 @@ def last_messages(request):
return HttpResponse(status=405) return HttpResponse(status=405)
id = request.user.id id = request.user.id
group_id = request.GET.get('group_id') group_id = request.GET.get('group_id')
messages = Message.objects.filter(send_to_id=group_id) messages = Message.objects.filter(send_to_id=group_id)[:100]
results = [] results = []
for o in messages: for o in messages:
result = dict() result = dict()

View File

@ -71,6 +71,7 @@ def read_notice(request):
def detail_notice(request, notice_id): def detail_notice(request, notice_id):
if request.method == 'POST': if request.method == 'POST':
return HttpResponse(status=405) return HttpResponse(status=405)
print(notice_id, (not notice_id))
if not notice_id: if not notice_id:
return JsonResponse({'status': 'error', 'message': '通知ID错误'}) return JsonResponse({'status': 'error', 'message': '通知ID错误'})
try: try:
@ -79,23 +80,24 @@ def detail_notice(request, notice_id):
results['id'] = notice.id results['id'] = notice.id
results['category'] = notice.type results['category'] = notice.type
results['content'] = notice.content results['content'] = notice.content
ReplyModel = apps.get_model(notice.app, notice.model) if notice.type == 1:
m = ReplyModel.objects.get(pk=notice.record_id) ReplyModel = apps.get_model(notice.app, notice.model)
detail = dict() m = ReplyModel.objects.get(pk=notice.record_id)
detail['id'] = m.id detail = dict()
detail['code'] = m.code detail['id'] = m.id
if notice.model == 'Weixin': detail['code'] = m.code
detail['type'] = 'weixin' if notice.model == 'Weixin':
elif notice.model == 'Weibo': detail['type'] = 'weixin'
detail['type'] = 'weibo' elif notice.model == 'Weibo':
elif notice.model == 'Toutiao': detail['type'] = 'weibo'
detail['type'] = 'Toutiao' elif notice.model == 'Toutiao':
elif notice.model == 'Douyin': detail['type'] = 'Toutiao'
detail['type'] = 'douyin' elif notice.model == 'Douyin':
else: detail['type'] = 'douyin'
detail['type'] = 'qita' else:
detail['status'] = m.status detail['type'] = 'qita'
results['media'] = detail results['media'] = detail
detail['status'] = m.status
results['added'] = notice.added.strftime("%Y-%m-%d %H:%M:%S") results['added'] = notice.added.strftime("%Y-%m-%d %H:%M:%S")
results['updated'] = notice.updated.strftime("%Y-%m-%d %H:%M:%S") results['updated'] = notice.updated.strftime("%Y-%m-%d %H:%M:%S")
return JsonResponse({'status': 'success', 'message': results}) return JsonResponse({'status': 'success', 'message': results})

View File

@ -10,6 +10,7 @@ from polls.models import Message, Notice, Task, TaskAddition
from polls.tasks import process_task from polls.tasks import process_task
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from polls.utils import model_to_dict, queryset_to_list, parse from polls.utils import model_to_dict, queryset_to_list, parse
from dashboard.models import Group, Group_user, Userprofile
@csrf_exempt @csrf_exempt
@ -65,6 +66,13 @@ def create_task(request):
if picture: if picture:
pictureAddtion = TaskAddition.objects.create( pictureAddtion = TaskAddition.objects.create(
task=task, category=2, image=picture) task=task, category=2, image=picture)
for group in groups:
users = Group_user.objects.filter(group=group)
for u in users:
g = Group.objects.get(id=group)
content = '用户%s在群组“%s”发布了任务,请查收消息' % (profile.name, g.name)
Notice.create_normal_notice(u.user_id, content)
return JsonResponse({'status': 'success'}) return JsonResponse({'status': 'success'})
@ -88,12 +96,19 @@ def get_task(request):
result['content'] = task.content result['content'] = task.content
result['total'] = task.total() result['total'] = task.total()
result['record'] = task.record() result['record'] = task.record()
# records = task.records() result['isOwner'] = task.created_by_id == id
# n = [] records = task.records()
# for r in records: n = []
# p = dict() for r in records:
# profile = r.user.profile p = dict()
# print(profile) p['id'] = r.id
p['added'] = task.added.strftime("%Y-%m-%d %H:%M:%S")
p['status'] = r.status
profile = Userprofile.objects.filter(user_id=r.user_id).first()
p['name'] = profile.name
p['organization'] = profile.organization.name
n.append(p)
result['records'] = n
result['added'] = task.added.strftime("%Y-%m-%d %H:%M:%S") result['added'] = task.added.strftime("%Y-%m-%d %H:%M:%S")
return JsonResponse({'status': 'success', 'message': result}) return JsonResponse({'status': 'success', 'message': result})

View File

@ -156,6 +156,7 @@ def password_recover_step_one(request):
if not phone: if not phone:
return JsonResponse({'status': 'error', 'message': '手机号不正确'}) return JsonResponse({'status': 'error', 'message': '手机号不正确'})
code = request.POST.get('code') code = request.POST.get('code')
print(code)
if not code: if not code:
return JsonResponse({'status': 'error', 'message': '验证码不正确'}) return JsonResponse({'status': 'error', 'message': '验证码不正确'})
verify_code = VerifyCode.objects.filter( verify_code = VerifyCode.objects.filter(