diff --git a/dashboard/models.py b/dashboard/models.py
index a90b264..028dcb7 100644
--- a/dashboard/models.py
+++ b/dashboard/models.py
@@ -55,29 +55,15 @@ class Group(models.Model):
def __str__(self):
return self.name
-# 矩阵管理员
-
-class Group_admin(models.Model):
- id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
- user = models.ForeignKey(
- User, on_delete=models.CASCADE, null=True, blank=True)
- group = models.ForeignKey(
- Group, on_delete=models.CASCADE, null=True, blank=True)
- created = models.DateTimeField('创建时间', auto_now_add=True)
- updated = models.DateTimeField('更新时间', auto_now=True)
-
- def __str__(self):
- return self.group.name
# 矩阵成员
-
-
-class Group_user(models.Model):
+class GroupUser(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
user = models.ForeignKey(
User, on_delete=models.CASCADE, null=True, blank=True)
group = models.ForeignKey(
Group, on_delete=models.CASCADE, null=True, blank=True)
+ is_admin = models.BooleanField('是否管理', default=False)
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
@@ -157,7 +143,6 @@ class Userprofile(models.Model):
def level1_admin(cls):
return Userprofile.objects.filter(organization__level__level=1)
-
def __str__(self):
return self.user.username+":"+self.name
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..792a68f 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'),
diff --git a/polls/views/__init__.py b/polls/views/__init__.py
index d0ffea6..bea72a5 100644
--- a/polls/views/__init__.py
+++ b/polls/views/__init__.py
@@ -2,7 +2,7 @@ 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 .compartment import compartments
diff --git a/polls/views/__pycache__/__init__.cpython-38.pyc b/polls/views/__pycache__/__init__.cpython-38.pyc
index a013a9a..01e681a 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..a1edd34 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/group.py b/polls/views/group.py
index d62e180..0850c72 100644
--- a/polls/views/group.py
+++ b/polls/views/group.py
@@ -17,12 +17,11 @@ def room(request):
def groups(request):
if request.method == 'POST':
return HttpResponse(status=405)
- id = request.user.id
+ user_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)
+ groups = Group.objects.filter(status='1',classify=category, group_user__user__id=user_id)
results = []
for o in groups:
result = dict()
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')