From 3466b6c88b11d62da74d39be331ce7151474298c Mon Sep 17 00:00:00 2001 From: baoliang Date: Thu, 22 Oct 2020 12:05:23 +0800 Subject: [PATCH 1/2] add message --- dashboard/models.py | 45 ++++++++++++------ .../views/__pycache__/monitor.cpython-38.pyc | Bin 3186 -> 3326 bytes polls/views/monitor.py | 31 +++++++----- 3 files changed, 50 insertions(+), 26 deletions(-) diff --git a/dashboard/models.py b/dashboard/models.py index c97319c..c26b4a3 100644 --- a/dashboard/models.py +++ b/dashboard/models.py @@ -210,34 +210,39 @@ class NewMedia(models.Model): @classmethod def category_one_count(cls): t1 = Weixin.objects.exclude( + status=0, organization__province='' ).filter( organization__cities='', - organization__district='' + organization__district='', ).count() t2 = Weibo.objects.exclude( + status=0, organization__province='' ).filter( organization__cities='', - organization__district='' + organization__district='', ).count() t3 = Toutiao.objects.exclude( + status=0, organization__province='' ).filter( organization__cities='', - organization__district='' + organization__district='', ).count() t4 = Douyin.objects.exclude( + status=0, organization__province='' ).filter( organization__cities='', - organization__district='' + organization__district='', ).count() t5 = Qita.objects.exclude( + status=0, organization__province='' ).filter( organization__cities='', - organization__district='' + organization__district='', ).count() return t1 + t2 + t3 + t4 + t5 @@ -245,59 +250,69 @@ class NewMedia(models.Model): def category_two_count(cls): t1 = Weixin.objects.exclude( organization__province='', - organization__cities='' + organization__cities='', + status=0 ).filter( - organization__district='' + organization__district='', ).count() t2 = Weibo.objects.exclude( organization__province='', - organization__cities='' + organization__cities='', + status=0 ).filter( - organization__district='' + organization__district='', ).count() t3 = Toutiao.objects.exclude( organization__province='', - organization__cities='' + organization__cities='', + status=0 ).filter( - organization__district='' + organization__district='', ).count() t4 = Douyin.objects.exclude( organization__province='', - organization__cities='' + organization__cities='', + status=0 ).filter( - organization__district='' + organization__district='', ).count() t5 = Qita.objects.exclude( organization__province='', - organization__cities='' + organization__cities='', + status=0 ).filter( - organization__district='' + organization__district='', ).count() return t1 + t2 + t3 + t4 + t5 @classmethod def category_three_count(cls): t1 = Weixin.objects.exclude( + status=0, organization__province='', organization__cities='', organization__district='' ).count() t2 = Weibo.objects.exclude( + status=0, organization__province='', organization__cities='', organization__district='' ).count() t3 = Toutiao.objects.exclude( + status=0, organization__province='', organization__cities='', organization__district='' ).count() t4 = Douyin.objects.exclude( + status=0, organization__province='', organization__cities='', organization__district='' ).count() t5 = Qita.objects.exclude( + status=0, organization__province='', organization__cities='', organization__district='' diff --git a/polls/views/__pycache__/monitor.cpython-38.pyc b/polls/views/__pycache__/monitor.cpython-38.pyc index 77aeed7008c979f2f9c8dc3eee814e9b0832f98f..6e4996d00f7823bf8f511f552fe227c3589b9356 100644 GIT binary patch delta 1499 zcmb7@zi-n(6vyw*u6?!>$N51;B-AdbqV!kVnTd8mssO3#f~c&hjv}XxL(Uh89~V+o z7$XIF?cfYZz<@wvWMpSVD*r%-E=6T+xl7{EgbuDPKi~J=d;UDXyZe3pEN^ZmlRDtn z5BaVAIQzxaq(|Q+04S)y3UZ)>+Ax&5pb4ow=0S8~%p*}{%p+6vq9?c~O}DTkG33Yx zs0$%rYKWZ)21m5Qq!F#Mi4l#N9BHcUgC-u-rty09HVSpe=)%wtwvwPp$JmEXq79oG z)7C(1YrUy69+C%5gBcy@!l;T7z{*{u##~jo~G7D>nY944NjxYhY`tnPMj2 zCn=iZ*{M9>8*Z?{J5v2FwZb$%LKc5#y1|T+*~E^?tSE$K`58#D^oX`tCek#=fRkn_ zQ<%xJPUb+~mo~s`_CA69;LgHB#ivEu@Pn7idI25gYNTBB+~-B=);!zZcBxzPiOEAr zx*xB3jjCNOIc||;f3xL@Ls(g{8B?DC!({#E4&D=1)uRWp5%@XfXoFy z@owuI7XW2obmx!^t>{JyoP_9HhRV5uFvL)Sh+CaM7P8RzoIIS%#GPC1eKc;Oh`Z4% z1jDFIvJjkT8!I=(U(OB9JRcoey}sC@qpnZgZT|)L`iL8V$P!Om3f}2ci;G;3rzUu- zpV_47?YLffj|W6)h2TVgP`E6`tkyi2)`(3?eq)!u874up96T}Fv(tjJAk3051!0zj T`B!#tG#|_)Ry7+zT^7$@VSG}` delta 1304 zcmb`G&ubGw6vyYyZg*#YW}BpFpthnH)7G|n5JB;v(vv8(=uKkjgp#&N$#jYeZ^@zH zt)(#69+I1i7sWrplYc@F(tkk@f*`FkHrtXmg1>gyx9|Jr&3xv^+x^m)v+=_y@`-+4 zoZG5c`M0rWU43E^BFPf8X@{gBt*%F<-SsRv(DiKT7*92=(U!{rDW^NM13=JiyWB$P z(KcE=dH@G{w1al0CEFk=GwdagyPR!8+vi>f+JUi4p^Uh<0o>n&)I;wsd3?K-`lwS% zBn@PYf&PXVAX|3CJ~9lojxcJwI!E`JB{n}E`io%tZ)$Be{hPR%Q?yoyp}}o~X!Hj* z;$Gl3G_RX8{cGegaSvIm-yZuQUz;oYXCxJ~CpOvY9_uM2Z4R4y`47ksCy+hFYbBE1 zv&0(zXJtuQ|c&sCk=Y3MCGdkn)5R)v51zoxk4)*96^O=@K zBs_;MIv8VtCp-3rHAl*W_tj_T9)P;#o+%{yk1E5i*I2Jt>Q!Ew7lW$qzE@+c%-rg; zg_U()RkN()6m+7qQGUIB`ABu$5Yg8LT#iUM~ zQdfeJ3zv_we&&yBxf?Fj8|Au-KoS*KO8rN4FHMuG(qPn)eB2f=N mWPq4f--FHah?#%Fm`P)%jF~p(czK6l^)9^QJ)+>-=KTR6mKrhu diff --git a/polls/views/monitor.py b/polls/views/monitor.py index 6840cb3..6c3350b 100644 --- a/polls/views/monitor.py +++ b/polls/views/monitor.py @@ -26,11 +26,11 @@ COMPARTMENTS = { @csrf_exempt def monitor_statistics(request): - wbc = Weibo.objects.count() - wxc = Weixin.objects.count() - ttc = Toutiao.objects.count() - qtc = Qita.objects.count() - dyc = Douyin.objects.count() + wbc = Weibo.objects.exclude(status=0).count() + wxc = Weixin.objects.exclude(status=0).count() + ttc = Toutiao.objects.exclude(status=0).count() + qtc = Qita.objects.exclude(status=0).count() + dyc = Douyin.objects.exclude(status=0).count() total = wbc+wxc+ttc+qtc+dyc chart1_data = [] @@ -41,10 +41,12 @@ def monitor_statistics(request): chart1_data.append({'name': '其它', 'value': qtc}) results = dict() - q = Weixin.objects.exclude(organization__cities='').values('organization__cities').order_by( + q = Weixin.objects.exclude(organization__cities='', status=0).values('organization__cities').order_by( 'organization__cities').annotate(num_media=Count('organization__cities')) for row in q: code = row['organization__cities'] + if not code: + continue compartment = COMPARTMENTS[code] if code in results: nums = results[compartment] @@ -52,10 +54,12 @@ def monitor_statistics(request): else: results[compartment] = [row['num_media']] - q = Weibo.objects.exclude(organization__cities='').values('organization__cities').order_by( + q = Weibo.objects.exclude(organization__cities='', status=0).values('organization__cities').order_by( 'organization__cities').annotate(num_media=Count('organization__cities')) for row in q: code = row['organization__cities'] + if not code: + continue compartment = COMPARTMENTS[code] if compartment in results: nums = results[compartment] @@ -63,10 +67,12 @@ def monitor_statistics(request): else: results[compartment] = [row['num_media']] - q = Toutiao.objects.exclude(organization__cities='').values('organization__cities').order_by( + q = Toutiao.objects.exclude(organization__cities='', status=0).values('organization__cities').order_by( 'organization__cities').annotate(num_media=Count('organization__cities')) for row in q: code = row['organization__cities'] + if not code: + continue compartment = COMPARTMENTS[code] if compartment in results: nums = results[compartment] @@ -74,10 +80,12 @@ def monitor_statistics(request): else: results[compartment] = [row['num_media']] - q = Douyin.objects.exclude(organization__cities='').values('organization__cities').order_by( + q = Douyin.objects.exclude(organization__cities='', status=0).values('organization__cities').order_by( 'organization__cities').annotate(num_media=Count('organization__cities')) for row in q: code = row['organization__cities'] + if not code: + continue compartment = COMPARTMENTS[code] if compartment in results: nums = results[compartment] @@ -85,17 +93,18 @@ def monitor_statistics(request): else: results[compartment] = [row['num_media']] - q = Qita.objects.exclude(organization__cities='').values('organization__cities').order_by( + q = Qita.objects.exclude(organization__cities='', status=0).values('organization__cities').order_by( 'organization__cities').annotate(num_media=Count('organization__cities')) for row in q: code = row['organization__cities'] + if not code: + continue compartment = COMPARTMENTS[code] if compartment in results: nums = results[compartment] nums.append(row['num_media']) else: results[compartment] = [row['num_media']] - chart2_data = [] for k in results: From f0d89bb08a18b2153d37160a4b5004bf4bd49a87 Mon Sep 17 00:00:00 2001 From: baoliang Date: Thu, 22 Oct 2020 13:36:23 +0800 Subject: [PATCH 2/2] add message --- polls/urls.py | 1 + polls/views/__init__.py | 2 +- .../views/__pycache__/__init__.cpython-38.pyc | Bin 1478 -> 1500 bytes polls/views/__pycache__/group.cpython-38.pyc | Bin 3471 -> 3962 bytes polls/views/group.py | 19 ++++++++++++++++++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/polls/urls.py b/polls/urls.py index 4445520..c5939bb 100644 --- a/polls/urls.py +++ b/polls/urls.py @@ -45,6 +45,7 @@ urlpatterns = [ path('tasks/create_test/', views.create_test_task, name='polls_tasks_create_test'), path('groups/list/', views.groups, name='polls_groups_list'), + path('groups/pick/', views.pick_groups, name='polls_groups_pick'), path('groups/level/', views.is_level1_or_leve2, name='polls_groups_level'), path('groups/test-room/', views.room, name='polls_group_test_room'), path('groups/manager/', views.group_manager, name='polls_groups_manager'), diff --git a/polls/views/__init__.py b/polls/views/__init__.py index 03f69ff..9876443 100644 --- a/polls/views/__init__.py +++ b/polls/views/__init__.py @@ -4,7 +4,7 @@ from .media import medias, my_medias, create_media, update_media, media_detail, from .news import news_list, news_top, news_detail from .monitor import monitor_statistics, monitor_result, media_statistics, city_ranking from .task import tasks, create_task, create_test_task, get_task -from .group import groups, room, is_level1_or_leve2, group_member, group_manager, group_enter, group_leave +from .group import groups, room, is_level1_or_leve2, group_member, group_manager, group_enter, group_leave, pick_groups from .compartment import compartments from .organizations import organizations, organization_level from .message import last_messages, send_text_message, is_read_message, read_message diff --git a/polls/views/__pycache__/__init__.cpython-38.pyc b/polls/views/__pycache__/__init__.cpython-38.pyc index 9d0c3f0880127c31f0c4939393429019af0675af..7872445d8f1f0c2b2d039f89ee2eaac1f4793499 100644 GIT binary patch delta 229 zcmX@ceTSPjl$V!_0SJ4N{Y0AB1PIDLI+6P yV$V%2E>28OEz$)E>46A+5Mcl!3_*kukXXr3WDR0lPxfXl=Fni|VH9ALU<3epyf=~n delta 206 zcmcb^eTX^O9!$ScbzGg14h3nN1cLkdTZUao$WKA6p!V~}eQWsqwa zWeDbTwPZOpawe*bGD>p;-Ui@p?D*<$4k{iH_M9o1J|vVJ?^@BRu{4| z2Pv_jEIQZGVZ+^{udo6HO#~O?h`kdTA5sy2M|)o00VTepc|hy zlvIe|V?Y#jeD30!ItpsD9e-)8ea^ge4KzCt*db>0eAT;PZq9F%uqHZguxADFcVp;%0aGA}N;$|1`jA zez8TbnDh8f5MWg}X219zew+&GYEAc2O!7p-!#M|)WyCY%>O?T8panJ=(6k!%o>y^8 z+}-6~w&K;5W_^EN`e2Mf>6O_Fn;7#Ytcka#6Z?-BeqS`q0azD5%|Y-*uQjM`q4SMo nLS(Fu4*e;7j<7;lC2SJ5#JD{SY4OM&?dg<32CM55O_F~D=TE(r delta 570 zcmZwDOH0E*5CGtACDFD?t8GIcKI%cVX{~Q1QlC((ASfbUL|hXaN}vzfHow7x2bK8+ z9z6;6=H06oPsW4duTW3!G+;fL!^doxo!Oc1q09c@fh_wy{2LoMr#GSN-~f5Q&c2DI z_`XL?w1$b(6+cwUtZtuCy;QYol-doGQEHV`2n#Djg*~B=%nuE3GYW|P(#J!PieG;alWzVAr}Uc!}g1!1xCv1bGku diff --git a/polls/views/group.py b/polls/views/group.py index 28b8bb1..0bd4bdd 100644 --- a/polls/views/group.py +++ b/polls/views/group.py @@ -47,6 +47,25 @@ def groups(request): return JsonResponse({'status': 'success', 'message': results}, safe=False) +@csrf_exempt +@polls_login_required +def pick_groups(request): + if request.method == 'POST': + return HttpResponse(status=405) + user_id = request.user.id + category = request.GET.get('category') + q = Group.objects.filter(status=1, group_admin__user__id=user_id).distinct() + groups = q.filter(classify=category) if category else q + results = [] + for o in groups: + result = dict() + result['id'] = str(o.id) + print(o.id, o.name) + result['name'] = o.name + result['image'] = request.build_absolute_uri(o.image.url) + results.append(result) + return JsonResponse({'status': 'success', 'message': results}, safe=False) + @csrf_exempt @polls_login_required def group_manager(request):