add message

This commit is contained in:
baoliang 2020-09-26 12:27:19 +08:00
parent cf71d08bb2
commit 6555eb5cf8
4 changed files with 14 additions and 12 deletions

View File

@ -17,7 +17,8 @@ COMPARTMENTS = {
'621200000000': '陇南市',
'622900000000': '临夏回族自治州',
'623000000000': '甘南藏族自治州',
'620171000000': '兰州新区'
'620171000000': '兰州新区',
'': '未知',
}
@ -37,12 +38,12 @@ def monitor_statistics(request):
chart1_data.append({'name': '其它', 'value': qtc})
results = dict()
q = Weixin.objects.values('organization__cities').order_by(
q = Weixin.objects.exclude(organization__cities='').values('organization__cities').order_by(
'organization__cities').annotate(num_media=Count('organization__cities'))
for row in q:
print(row)
code = row['organization__cities']
print(code)
compartment = COMPARTMENTS[code]
if code in results:
nums = results[compartment]
@ -50,7 +51,7 @@ def monitor_statistics(request):
else:
results[compartment] = [row['num_media']]
q = Weibo.objects.values('organization__cities').order_by(
q = Weibo.objects.exclude(organization__province='', organization__cities='').values('organization__cities').order_by(
'organization__cities').annotate(num_media=Count('organization__cities'))
for row in q:
code = row['organization__cities']
@ -61,7 +62,7 @@ def monitor_statistics(request):
else:
results[compartment] = [row['num_media']]
q = Toutiao.objects.values('organization__cities').order_by(
q = Toutiao.objects.exclude(organization__province='', organization__cities='').values('organization__cities').order_by(
'organization__cities').annotate(num_media=Count('organization__cities'))
for row in q:
code = row['organization__cities']
@ -72,7 +73,7 @@ def monitor_statistics(request):
else:
results[compartment] = [row['num_media']]
q = Douyin.objects.values('organization__cities').order_by(
q = Douyin.objects.exclude(organization__province='', organization__cities='').values('organization__cities').order_by(
'organization__cities').annotate(num_media=Count('organization__cities'))
for row in q:
code = row['organization__cities']
@ -83,7 +84,7 @@ def monitor_statistics(request):
else:
results[compartment] = [row['num_media']]
q = Qita.objects.values('organization__cities').order_by(
q = Qita.objects.exclude(organization__province='', organization__cities='').values('organization__cities').order_by(
'organization__cities').annotate(num_media=Count('organization__cities'))
for row in q:
code = row['organization__cities']

View File

@ -47,6 +47,7 @@ def create_task(request):
task = Task.objects.create(created_by=user, content=content)
task.add_groups(groups)
url = request.POST.get('url')
print(groups, content, url)
file = request.FILES.get('file')
picture = request.FILES.get('picture')
if url:
@ -58,11 +59,11 @@ def create_task(request):
if picture:
pictureAddtion = TaskAddition.objects.create(
task=task, category=2, image=picture)
t = model_to_dict(task, ["id", "content"])
gs = queryset_to_list(task.groups.all(), ["id"])
channel_layer = get_channel_layer()
# async_to_sync(channel_layer.send)('test_channel', {'type': 'hello'})
async_to_sync(channel_layer.group_send)("testroom", {"type": "update_price", "content":"helo"})
# t = model_to_dict(task, ["id", "content"])
# gs = queryset_to_list(task.groups.all(), ["id"])
# channel_layer = get_channel_layer()
# # async_to_sync(channel_layer.send)('test_channel', {'type': 'hello'})
# async_to_sync(channel_layer.group_send)("testroom", {"type": "update_price", "content":"helo"})
return JsonResponse({'status': 'success'})