diff --git a/polls/templates/polls/city_ranking.html b/polls/templates/polls/city_ranking.html
new file mode 100644
index 0000000..a3cb014
--- /dev/null
+++ b/polls/templates/polls/city_ranking.html
@@ -0,0 +1,131 @@
+{% extends 'polls/base.html' %}
+{% block content%}
+
+
市州合格率排行榜
+
+
+
+ 市 |
+ 不合格 |
+ 合格 |
+ 数量 |
+ 合格率 |
+
+
+
+
+ 武威市 |
+ 0 |
+ 4 |
+ 4 |
+ 100.0% |
+
+
+ 天水市 |
+ 0 |
+ 13 |
+ 13 |
+ 100.0% |
+
+
+ 金昌市 |
+ 2 |
+ 53 |
+ 55 |
+ 96.4% |
+
+
+ 嘉峪关市 |
+ 3 |
+ 44 |
+ 47 |
+ 93.6% |
+
+
+ 甘肃省 |
+ 20 |
+ 132 |
+ 152 |
+ 86.8% |
+
+
+ 兰州市 |
+ 4 |
+ 25 |
+ 29 |
+ 86.2% |
+
+
+ 平凉市 |
+ 5 |
+ 29 |
+ 34 |
+ 85.3% |
+
+
+ 庆阳市 |
+ 27 |
+ 137 |
+ 164 |
+ 83.5% |
+
+
+ 白银市 |
+ 3 |
+ 15 |
+ 18 |
+ 83.3% |
+
+
+ 临夏州 |
+ 2 |
+ 7 |
+ 9 |
+ 77.8% |
+
+
+ 兰州新区 |
+ 12 |
+ 39 |
+ 51 |
+ 76.5% |
+
+
+ 甘南州 |
+ 2 |
+ 6 |
+ 8 |
+ 75.0% |
+
+
+ 定西市 |
+ 3 |
+ 8 |
+ 11 |
+ 72.7% |
+
+
+ 酒泉市 |
+ 3 |
+ 6 |
+ 9 |
+ 66.7% |
+
+
+ 陇南市 |
+ 12 |
+ 17 |
+ 29 |
+ 58.6% |
+
+
+ 张掖市 |
+ 3 |
+ 4 |
+ 7 |
+ 57.1% |
+
+
+
+
+{% endblock%}
diff --git a/polls/templates/polls/media_statistics.html b/polls/templates/polls/media_statistics.html
new file mode 100644
index 0000000..13809de
--- /dev/null
+++ b/polls/templates/polls/media_statistics.html
@@ -0,0 +1,167 @@
+{% extends 'polls/base.html' %}
+{% load static %}
+{% block content%}
+
+{% endblock%}
+{% block add_js %}
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/polls/urls.py b/polls/urls.py
index eb774da..deb467c 100644
--- a/polls/urls.py
+++ b/polls/urls.py
@@ -19,7 +19,8 @@ urlpatterns = [
path('notices/read/', views.read_notice, name='polls_read_notice'),
path('notices/pass/', views.pass_notice, name='polls_pass_notice'),
path('notices/reject/', views.reject_notice, name='polls_reject_notice'),
- path('notices/detail//', views.detail_notice, name='polls_detail_notice'),
+ path('notices/detail//',
+ views.detail_notice, name='polls_detail_notice'),
path('medias/create/', views.create_media, name='polls_add_media'),
path('medias/update/', views.update_media, name='polls_update_media'),
path('medias/list/', views.medias, name='polls_medias'),
@@ -33,6 +34,9 @@ urlpatterns = [
views.news_detail, name='polls_news_detail'),
path('monitor/statistics/', views.monitor_statistics,
name='polls_monitor_statistics'),
+ path('monitor/media/statistics/', views.media_statistics,
+ name='polls_media_statistics'),
+ path('monitor/city/ranking/', views.city_ranking, name='polls_city_ranking'),
path('monitor/result/', views.monitor_result,
name='polls_monitor_result'),
path('tasks/list/', views.tasks, name='polls_tasks_list'),
@@ -40,7 +44,10 @@ 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/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'),
+ path('groups/member/', views.group_member, name='polls_groups_member'),
path('compartments/list/', views.compartments,
name='polls_compartments_list'),
path('organizations/list/', views.organizations,
diff --git a/polls/views/__init__.py b/polls/views/__init__.py
index d0ffea6..f32fd58 100644
--- a/polls/views/__init__.py
+++ b/polls/views/__init__.py
@@ -2,9 +2,9 @@ from .user import index, status_500, status_401, polls_login, send_code, registe
from .notice import notices, notice_top, read_notice, pass_notice, reject_notice, detail_notice
from .media import medias, my_medias, create_media, update_media, media_detail, delete_media
from .news import news_list, news_top, news_detail
-from .monitor import monitor_statistics, monitor_result
+from .monitor import monitor_statistics, monitor_result, media_statistics, city_ranking
from .task import tasks, create_task, create_test_task
-from .group import groups, room
+from .group import groups, room, is_level1_or_leve2, group_member, group_manager
from .compartment import compartments
from .organizations import organizations, organization_level
from .message import last_messages, send_text_message
diff --git a/polls/views/__pycache__/__init__.cpython-38.pyc b/polls/views/__pycache__/__init__.cpython-38.pyc
index a013a9a..9b1b001 100644
Binary files a/polls/views/__pycache__/__init__.cpython-38.pyc and b/polls/views/__pycache__/__init__.cpython-38.pyc differ
diff --git a/polls/views/__pycache__/group.cpython-38.pyc b/polls/views/__pycache__/group.cpython-38.pyc
index 077da0f..86c2390 100644
Binary files a/polls/views/__pycache__/group.cpython-38.pyc and b/polls/views/__pycache__/group.cpython-38.pyc differ
diff --git a/polls/views/__pycache__/media.cpython-38.pyc b/polls/views/__pycache__/media.cpython-38.pyc
index 26d5a0d..507844a 100644
Binary files a/polls/views/__pycache__/media.cpython-38.pyc and b/polls/views/__pycache__/media.cpython-38.pyc differ
diff --git a/polls/views/__pycache__/monitor.cpython-38.pyc b/polls/views/__pycache__/monitor.cpython-38.pyc
index d8e5142..5ef1c90 100644
Binary files a/polls/views/__pycache__/monitor.cpython-38.pyc and b/polls/views/__pycache__/monitor.cpython-38.pyc differ
diff --git a/polls/views/__pycache__/user.cpython-38.pyc b/polls/views/__pycache__/user.cpython-38.pyc
index b7c7613..96b34c1 100644
Binary files a/polls/views/__pycache__/user.cpython-38.pyc and b/polls/views/__pycache__/user.cpython-38.pyc differ
diff --git a/polls/views/group.py b/polls/views/group.py
index d62e180..e63ad01 100644
--- a/polls/views/group.py
+++ b/polls/views/group.py
@@ -2,27 +2,39 @@ from django.shortcuts import render
from django.http import HttpResponse, JsonResponse
from django.views.decorators.csrf import csrf_exempt
import datetime
+from django.db.models import Q
from polls.decorators import polls_login_required
from django.core.exceptions import ObjectDoesNotExist
-from dashboard.models import Group
+from dashboard.models import Group, Userprofile
def room(request):
return render(request, 'polls/chat_text.html')
+@csrf_exempt
+@polls_login_required
+def is_level1_or_leve2(request):
+ if request.method == 'POST':
+ return HttpResponse(status=405)
+ user = request.user
+ profile = user.userprofile_set.first()
+ result = dict()
+ result['admin'] = profile.is_level1() or profile.is_level2()
+ return JsonResponse({'status': 'success', 'message': result}, safe=False)
+
+
@csrf_exempt
@polls_login_required
def groups(request):
if request.method == 'POST':
return HttpResponse(status=405)
- id = request.user.id
- category = request.GET.get('category', '0')
- if not category:
- return JsonResponse({'status': 'error', 'message': '参数错误'})
-
- groups = Group.objects.filter(status='1',classify=category)
+ user_id = request.user.id
+ category = request.GET.get('category')
+ q = Group.objects.filter(Q(status=1), Q(
+ group_user__user__id=user_id) | Q(group_admin__user__id=user_id))
+ groups = q.filter(classify=category) if category else q
results = []
for o in groups:
result = dict()
@@ -31,3 +43,45 @@ def groups(request):
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):
+ if request.method == 'POST':
+ return HttpResponse(status=405)
+ group_id = request.GET.get('group_id')
+ if not group_id:
+ return JsonResponse({'status': 'error', 'message': '参数错误'})
+ managers = Userprofile.objects.filter(user__group_admin__group_id=group_id)
+ results = []
+ for m in managers:
+ result = dict()
+ result['id'] = m.user.id
+ result['name'] = m.name
+ result['thumbnail'] = request.build_absolute_uri(
+ m.image.url) if m.image else None
+ result['organization'] = m.organization.name
+ results.append(result)
+ return JsonResponse({'status': 'success', 'message': results}, safe=False)
+
+
+@csrf_exempt
+@polls_login_required
+def group_member(request):
+ if request.method == 'POST':
+ return HttpResponse(status=405)
+ group_id = request.GET.get('group_id')
+ if not group_id:
+ return JsonResponse({'status': 'error', 'message': '参数错误'})
+ managers = Userprofile.objects.filter(user__group_user__group_id=group_id)
+ results = []
+ for m in managers:
+ result = dict()
+ result['id'] = m.user.id
+ result['name'] = m.name
+ result['thumbnail'] = request.build_absolute_uri(
+ m.image.url) if m.image else None
+ result['organization'] = m.organization.name
+ results.append(result)
+ return JsonResponse({'status': 'success', 'message': results}, safe=False)
diff --git a/polls/views/media.py b/polls/views/media.py
index 14f9a08..9406e6d 100644
--- a/polls/views/media.py
+++ b/polls/views/media.py
@@ -52,33 +52,42 @@ def create_media(request):
attention = request.POST.get('attention', '')
remark = request.POST.get('remark', '')
model_name = ''
+ status = 2 if o.directly == '省直部门' else 1
+
if category == 'weixin':
model_name = 'Weixin'
instance = Weixin(code=code, weixinid=media_id, alias=alias,
- image=f, status=1, organization=o, attention=attention, remark=remark)
+ image=f, status=status, organization=o, attention=attention, remark=remark)
elif category == 'weibo':
model_name = 'Weibo'
instance = Weibo(code=code, weiboid=media_id, alias=alias,
- image=f, status=1, organization=o, attention=attention, remark=remark)
+ image=f, status=status, organization=o, attention=attention, remark=remark)
elif category == 'toutiao':
model_name = 'Toutiao'
instance = Toutiao(code=code, toutiaoid=media_id, alias=alias,
- image=f, status=1, organization=o, attention=attention, remark=remark)
+ image=f, status=status, organization=o, attention=attention, remark=remark)
elif category == 'douyin':
model_name = 'Douyin'
instance = Douyin(code=code, douyinid=media_id, alias=alias,
- image=f, status=1, organization=o, attention=attention, remark=remark)
+ image=f, status=status, organization=o, attention=attention, remark=remark)
else:
model_name = 'Qita'
type = request.POST.get('type')
instance = Qita(code=code, qitaid=media_id, alias=alias,
- image=f, status=1, organization=o, attention=attention, remark=remark)
+ image=f, status=status, organization=o, attention=attention, remark=remark)
instance.save()
- admins = Userprofile.level2_admin(instance.organization.cities)
- for a in admins:
- content = '用户%s创建了新媒体,请审核' % (profile.name,)
- Notice.create_reply_notice(
- a.user.id, content, 'dashboard', model_name, 'status', instance.id, '2', '0')
+ if o.directly == '省直部门':
+ admins = Userprofile.level1_admin()
+ for a in admins:
+ content = '用户%s创建了新媒体,请审核' % (profile.name,)
+ Notice.create_reply_notice(
+ a.user.id, content, 'dashboard', model_name, 'status', instance.id, '3', '0')
+ else:
+ admins = Userprofile.level2_admin(instance.organization.cities)
+ for a in admins:
+ content = '用户%s创建了新媒体,请审核' % (profile.name,)
+ Notice.create_reply_notice(
+ a.user.id, content, 'dashboard', model_name, 'status', instance.id, '2', '0')
return JsonResponse({'status': 'success'})
@@ -212,13 +221,23 @@ def delete_media(request):
model_name = 'Qita'
instance = Qita.objects.get(pk=media_id)
result['media_id'] = instance.qitaid
- instance.status = 4
- instance.save()
- admins = Userprofile.level2_admin(instance.organization.cities)
- for a in admins:
- content = '用户%s申请注销新媒体,请审核' % (profile.name,)
- Notice.create_reply_notice(
- a.user.id, content, 'dashboard', model_name, 'status', instance.id, '5', '3')
+
+ if o.directly == '省直部门':
+ instance.status = 5
+ instance.save()
+ managers = Userprofile.level1_admin()
+ for a in managers:
+ content = '用户%s申请注销新媒体,请审核' % (profile.name,)
+ Notice.create_reply_notice(
+ a.user.id, content, 'dashboard', model_name, 'status', instance.id, '0', '3')
+ else:
+ instance.status = 4
+ instance.save()
+ managers = Userprofile.level2_admin(instance.organization.cities)
+ for a in managers:
+ content = '用户%s申请注销新媒体,请审核' % (profile.name,)
+ Notice.create_reply_notice(
+ a.user.id, content, 'dashboard', model_name, 'status', instance.id, '5', '3')
admins = []
for admin in instance.organization.userprofile_set.all():
diff --git a/polls/views/monitor.py b/polls/views/monitor.py
index fb73c79..5f02232 100644
--- a/polls/views/monitor.py
+++ b/polls/views/monitor.py
@@ -1,4 +1,6 @@
from django.shortcuts import render
+from django.views.decorators.csrf import csrf_exempt
+
from dashboard.models import Douyin, NewMedia, Qita, Toutiao, Weibo, Weixin
from django.db.models import Count, Sum
@@ -22,6 +24,7 @@ COMPARTMENTS = {
}
+@csrf_exempt
def monitor_statistics(request):
wbc = Weibo.objects.count()
wxc = Weixin.objects.count()
@@ -109,5 +112,15 @@ def monitor_statistics(request):
return render(request, 'polls/monitor_statistics.html', {'chart1_data': chart1_data, 'total': total, 'chart2_data': chart2_data, 'chart3_data': chart3_data})
+@csrf_exempt
+def media_statistics(request):
+ return render(request, 'polls/media_statistics.html')
+
+
+@csrf_exempt
+def city_ranking(request):
+ return render(request, 'polls/city_ranking.html')
+
+
def monitor_result(request):
- return render(request, 'polls/monitor_result.html')
\ No newline at end of file
+ return render(request, 'polls/monitor_result.html')