From 40f57f62d6e2389b25d81e870d804d4425274c0a Mon Sep 17 00:00:00 2001 From: baoliang Date: Sun, 18 Oct 2020 00:00:23 +0800 Subject: [PATCH] add message --- polls/templates/polls/media_statistics.html | 159 +++++++++++++++++- .../views/__pycache__/message.cpython-38.pyc | Bin 2820 -> 2833 bytes polls/views/__pycache__/notice.cpython-38.pyc | Bin 4204 -> 4244 bytes polls/views/__pycache__/task.cpython-38.pyc | Bin 3268 -> 3883 bytes polls/views/__pycache__/user.cpython-38.pyc | Bin 5598 -> 5613 bytes polls/views/message.py | 2 +- polls/views/notice.py | 36 ++-- polls/views/task.py | 27 ++- polls/views/user.py | 1 + 9 files changed, 200 insertions(+), 25 deletions(-) diff --git a/polls/templates/polls/media_statistics.html b/polls/templates/polls/media_statistics.html index 13809de..ac5ac5e 100644 --- a/polls/templates/polls/media_statistics.html +++ b/polls/templates/polls/media_statistics.html @@ -6,6 +6,10 @@
+
+
+
+ {% endblock%} @@ -99,7 +103,7 @@ }; var option = { title: { - text: '逐月累计发文量', + text: '全省政务新媒体更新次数(逐月)', subtextStyle: { fontSize: 16, }, @@ -163,5 +167,158 @@ ] }; 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); {% endblock %} \ No newline at end of file diff --git a/polls/views/__pycache__/message.cpython-38.pyc b/polls/views/__pycache__/message.cpython-38.pyc index 18b03703d086539adbbf5eaf04ce5aeddeebabe8..3b3ae63c0077536fa0f7a967b3bfad8bf36663af 100644 GIT binary patch delta 857 zcma)&y>HV%6u^CseRe*aq)Fp8U;U!Am{O3UPH9jh6;%}y11c;PQWQ9=s(}X126ZsX z0u!nbx`72m!pa0lEKEoY%m^`ff(40x0Wt92IVge&4?q2$-@AA3-hKPAZC$pklmg%R ziHDueE9)*%8$>)ZE8;n+nM`5yfm&9?J2KlhT1u#U>5wwBr34wz@Jxs;mOLVZ>`=L9 zgoc-cY)aPU!P3$uz%tSbV3xEZSXSC3SWa3AEHBOGUqWRt1>J3LdPojb20eCJK_<&k zR+LuZzeZ)1aT%MGx$2J!HQ{LWbRBgDF)J==OHg{KHAqvu)b0>l%33+f{4V>A{7P(uo4_aF%=Ov4q~ts ziNe?c-GK$91bzTwV?!0poj^if_yw@Q58#}epaK&fK7GgM+;i?d&x|LAepA<@5_~(a zA6vKH>JN#$O!%g@%-@js&{sN=uX@TA>Gl^tm87u(+@cm@X^}mJl|~fhL6-?8uWwd1!Aq zg)zA=+t@B8az(JTuvzwVS~dGeRYv4Wqd7Y}#%t#wR!8$59TOrwsJjcc;i-21g=`n> z;(@#?nX}u0dVOb?AIeMoyZniy_y^?zN%J2{rICeYu^hrcDHjTXIsry zzqdDV+tz?}0|mh5uw)*w!0)J4==)S%A#41dIv@#tKD16YcsKNtRJlga&@vWg`9-?e zNu!=c%!r?e1mXn1jIs*4f;feUAxRFI2Y;M{FS)h~w=} JU->y&`vv(ezM=pC diff --git a/polls/views/__pycache__/notice.cpython-38.pyc b/polls/views/__pycache__/notice.cpython-38.pyc index f7346d5f97ee139367ea6fe26da49f31002b8288..1778a7f7d3eb9cdb1d852861feb87c4908d5a9af 100644 GIT binary patch delta 710 zcmZ8eyKWOf6rDS}J6`W&yzwg`u_X*j5zzobpePmv0`ZgsSP4Ojf+F1%UPFjBO98Cq z!etbZXecR?f)7CX0Yt|KK#>B`64KKk#GSE0h#l?Gx#!$_W_I@Y4yYzpZDx+7{}uR1{CO+ zK#@5VC`_OeN5n!CBT>?EKVX5BsL9r^>J%I!?K2if+F7HONISyPNUIsGOxiE3Xsu7f zE>?$jCg_~ww1E?kkuqVnD(;o=#6FNSY3lOddaB9jR%+y!TY13R%w}n&>(Tec!1Vg} z)&zS<9ZL)eXX>rQr~i>(V72j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`eGBI}mhVWp5A0zRo!g}6|mlgk>&%5ub3R|pX< z{$$q`*gWyX!aiKsl4&b=lqHc3PamzW zvR;fnj=--ZKQ`WYkFr+T(u=OljC!ujXhzAKr`|3BkGpV2Hv-ZmP1tMjal>UcqnGmU z=vKa5ausIaB-0~N>i;CdiG06NlujV{5b#A{0|kG!4n%oiIW(g0FRoOCBwt@_<0tjbl4*xPiGQc{J!l+=>P&}*T@KpxVTH0ODb#} z^;%_V;A0%I`0 mS~QO0+hyXcFw}|FLd{~BB=HM9&?J$FB&=}^?&Y6;k^BpW0*@X5 delta 1097 zcmZ8g%}*0i5bt)|-GzSA52R3_G+Nz)Qa@0PM2%>;D1xGiT$;7-fsG5r+3kUZq!GLu z@-$KLpl3-i;UDne(Rem{$H>)q(8Pl?uOQk@_P4*8c{^|B_vXFp`9!u>1%BpSoh4bSip^kg z=}AwWxHbbxTmvbBjJT@hGrdHqMAPrJSAbhCXXX3L7;R|7jS&p&(pIJlqqOoo!CCV9 zTfAPdx?s(7NYjce1yhhCt`ZC&c(J;}VF_w;RhyR`?s~zwDqx!l3aazml>&G=GP{cY zP>_Dji^qBqwcON)N@g66{Y|IurD{q^Jv3{iqGgS6PFyzb4V1{1a1xmpYIa$6E$878 zbT~8OvvD`?hwEtkr>lVuDnaV{$tOMpx`o~Ls_`blVsDj|0E>_LT#a=g(_j0g%!x_a z&4J9GPWzOr3{GRFdKh8n>FU?#?{}ZQ{I<0Pq`#>^Cw`i6h?s1KCd3Q6HP^B|4S1yn z47$Vg2MzdIdv`v5(>oRG)@w`NkDT6M-fb;DY&ff z26;z)s4ol=Jx*|fV3?pqX9JH>iadcqry$OR3qd`uz?4`HTOnCua~Q==xR~gp3e&r8#&*S$1 diff --git a/polls/views/__pycache__/user.cpython-38.pyc b/polls/views/__pycache__/user.cpython-38.pyc index 96b34c108f7af88ffe0f7caf51ebb13411f855af..e3201d2359dde26e9b169cbe919e5ed19d2a0cf4 100644 GIT binary patch delta 141 zcmcbo{Z^Ydl$V!_0SNrRb;VEJ$eSj>IB&9okfTirYYkH~BO^l%Q*lHIOA2cWXA1iq zphz%730oF>7Do+Z4O0qN3U@E_0?vgDwahilMLjjl3%C|C6!lDgDNxPGJ^2rZ6r<$i pYQaQdC6EnFT#Q_dJd7-id_a<8^IO3%CdO5pT|}lcG7B*=0svioB9{OF delta 123 zcmaE>eNUS=l$V!_0SH!wHpI7V@|!vOetI` z+`Y^TI2JP0GS@H{wbU>#;9SU1)H3;_Ks6)Rei~uDS9@_u_ diff --git a/polls/views/message.py b/polls/views/message.py index 921689c..17c607b 100644 --- a/polls/views/message.py +++ b/polls/views/message.py @@ -16,7 +16,7 @@ def last_messages(request): return HttpResponse(status=405) id = request.user.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 = [] for o in messages: result = dict() diff --git a/polls/views/notice.py b/polls/views/notice.py index 4749b35..4375358 100644 --- a/polls/views/notice.py +++ b/polls/views/notice.py @@ -71,6 +71,7 @@ def read_notice(request): def detail_notice(request, notice_id): if request.method == 'POST': return HttpResponse(status=405) + print(notice_id, (not notice_id)) if not notice_id: return JsonResponse({'status': 'error', 'message': '通知ID错误'}) try: @@ -79,23 +80,24 @@ def detail_notice(request, notice_id): results['id'] = notice.id results['category'] = notice.type results['content'] = notice.content - ReplyModel = apps.get_model(notice.app, notice.model) - m = ReplyModel.objects.get(pk=notice.record_id) - detail = dict() - detail['id'] = m.id - detail['code'] = m.code - if notice.model == 'Weixin': - detail['type'] = 'weixin' - elif notice.model == 'Weibo': - detail['type'] = 'weibo' - elif notice.model == 'Toutiao': - detail['type'] = 'Toutiao' - elif notice.model == 'Douyin': - detail['type'] = 'douyin' - else: - detail['type'] = 'qita' - detail['status'] = m.status - results['media'] = detail + if notice.type == 1: + ReplyModel = apps.get_model(notice.app, notice.model) + m = ReplyModel.objects.get(pk=notice.record_id) + detail = dict() + detail['id'] = m.id + detail['code'] = m.code + if notice.model == 'Weixin': + detail['type'] = 'weixin' + elif notice.model == 'Weibo': + detail['type'] = 'weibo' + elif notice.model == 'Toutiao': + detail['type'] = 'Toutiao' + elif notice.model == 'Douyin': + detail['type'] = 'douyin' + else: + detail['type'] = 'qita' + results['media'] = detail + detail['status'] = m.status results['added'] = notice.added.strftime("%Y-%m-%d %H:%M:%S") results['updated'] = notice.updated.strftime("%Y-%m-%d %H:%M:%S") return JsonResponse({'status': 'success', 'message': results}) diff --git a/polls/views/task.py b/polls/views/task.py index 4f7b0de..a4b1876 100644 --- a/polls/views/task.py +++ b/polls/views/task.py @@ -10,6 +10,7 @@ from polls.models import Message, Notice, Task, TaskAddition from polls.tasks import process_task from django.core.exceptions import ObjectDoesNotExist from polls.utils import model_to_dict, queryset_to_list, parse +from dashboard.models import Group, Group_user, Userprofile @csrf_exempt @@ -65,6 +66,13 @@ def create_task(request): if picture: pictureAddtion = TaskAddition.objects.create( 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'}) @@ -88,12 +96,19 @@ def get_task(request): result['content'] = task.content result['total'] = task.total() result['record'] = task.record() - # records = task.records() - # n = [] - # for r in records: - # p = dict() - # profile = r.user.profile - # print(profile) + result['isOwner'] = task.created_by_id == id + records = task.records() + n = [] + for r in records: + p = dict() + 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") return JsonResponse({'status': 'success', 'message': result}) diff --git a/polls/views/user.py b/polls/views/user.py index cd4f7d4..7ad27dd 100644 --- a/polls/views/user.py +++ b/polls/views/user.py @@ -156,6 +156,7 @@ def password_recover_step_one(request): if not phone: return JsonResponse({'status': 'error', 'message': '手机号不正确'}) code = request.POST.get('code') + print(code) if not code: return JsonResponse({'status': 'error', 'message': '验证码不正确'}) verify_code = VerifyCode.objects.filter(