diff --git a/polls/templates/polls/monitor_statistics.html b/polls/templates/polls/monitor_statistics.html index 3f40208..a1d6fb2 100644 --- a/polls/templates/polls/monitor_statistics.html +++ b/polls/templates/polls/monitor_statistics.html @@ -9,6 +9,9 @@
+
+
+
{% endblock%} @@ -55,7 +58,6 @@ var option2 = { title: { text: '政务新媒体区域分布', - subtext: '省直部门{{total1}},市直部门{{total2}},县区政府{{total3}}', subtextStyle: { fontSize: 16, }, @@ -87,5 +89,41 @@ ]}; myChart2.setOption(option2); + + var myChart3 = echarts.init(document.getElementById('chart3')); + var option3 = { + title: { + text: '政务新媒体省址、市州和县区分布', + subtextStyle: { + fontSize: 16, + }, + left: 'center' + }, + tooltip: { + trigger: 'item', + formatter: '{a}
{b} : {c} ({d}%)' + }, + legend: { + top: '15%', + data: ['省直各部门', '市州政府及部门', '县区政府及部门、乡镇'] + }, + series: [ + { + name: '总量', + type: 'pie', + radius: '50%', + center: ['50%', '70%'], + data: {{chart3_data|safe}}, + emphasis: { + itemStyle: { + shadowBlur: 10, + shadowOffsetX: 0, + shadowColor: 'rgba(0, 0, 0, 0.5)' + } + } + } + ]}; + + myChart3.setOption(option3); {% endblock %} \ No newline at end of file diff --git a/polls/urls.py b/polls/urls.py index 954be7c..0f01975 100644 --- a/polls/urls.py +++ b/polls/urls.py @@ -42,6 +42,8 @@ urlpatterns = [ name='polls_compartments_list'), path('organizations/list/', views.organizations, name='polls_organizations_list'), + path('organizations/level/', views.organization_level, + name='polls_organization_level'), path('messages/list/last/', views.last_messages, name='polls_messages_list_last'), path('messages/send/text/', views.send_text_message, diff --git a/polls/views/__init__.py b/polls/views/__init__.py index d1468be..aa2cf6f 100644 --- a/polls/views/__init__.py +++ b/polls/views/__init__.py @@ -6,5 +6,5 @@ from .monitor import monitor_statistics, monitor_result from .task import tasks, create_task, create_test_task from .group import groups, room from .compartment import compartments -from .organizations import organizations +from .organizations import organizations, organization_level from .message import last_messages, send_text_message \ No newline at end of file diff --git a/polls/views/__pycache__/__init__.cpython-38.pyc b/polls/views/__pycache__/__init__.cpython-38.pyc index aa0d13a..1ccd4da 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__/media.cpython-38.pyc b/polls/views/__pycache__/media.cpython-38.pyc index 65f6d53..8066143 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 cd9aa1c..d8e5142 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__/notice.cpython-38.pyc b/polls/views/__pycache__/notice.cpython-38.pyc index 2f9b6bc..6d74316 100644 Binary files a/polls/views/__pycache__/notice.cpython-38.pyc and b/polls/views/__pycache__/notice.cpython-38.pyc differ diff --git a/polls/views/__pycache__/organizations.cpython-38.pyc b/polls/views/__pycache__/organizations.cpython-38.pyc index 2e3c399..fa0a45a 100644 Binary files a/polls/views/__pycache__/organizations.cpython-38.pyc and b/polls/views/__pycache__/organizations.cpython-38.pyc differ diff --git a/polls/views/monitor.py b/polls/views/monitor.py index 54b05b6..fb73c79 100644 --- a/polls/views/monitor.py +++ b/polls/views/monitor.py @@ -102,8 +102,11 @@ def monitor_statistics(request): total1 = NewMedia.category_one_count() total2 = NewMedia.category_two_count() total3 = NewMedia.category_three_count() - - return render(request, 'polls/monitor_statistics.html', {'chart1_data': chart1_data, 'total': total, 'chart2_data': chart2_data, 'total1': total1, 'total2': total2, 'total3': total3}) + chart3_data = [] + chart3_data.append({'name': '省直各部门', 'value': total1}) + chart3_data.append({'name': '市州政府及部门', 'value': total2}) + chart3_data.append({'name': '县区政府及部门、乡镇', 'value': total3}) + return render(request, 'polls/monitor_statistics.html', {'chart1_data': chart1_data, 'total': total, 'chart2_data': chart2_data, 'chart3_data': chart3_data}) def monitor_result(request): diff --git a/polls/views/notice.py b/polls/views/notice.py index c87386d..26406d3 100644 --- a/polls/views/notice.py +++ b/polls/views/notice.py @@ -8,13 +8,14 @@ from polls.decorators import polls_login_required from polls.models import Notice from django.core.exceptions import ObjectDoesNotExist + @csrf_exempt @polls_login_required def notices(request): if request.method == 'POST': return HttpResponse(status=405) id = request.user.id - notices = Notice.objects.filter(user__id=id,is_read=False) + notices = Notice.objects.filter(user__id=id, is_read=False) results = [] for o in notices: result = dict() @@ -23,7 +24,7 @@ def notices(request): result['content'] = o.content result['added'] = o.added.strftime("%Y-%m-%d %H:%M:%S") results.append(result) - return JsonResponse({'status': 'success', 'message':results}, safe=False) + return JsonResponse({'status': 'success', 'message': results}, safe=False) @csrf_exempt @@ -32,7 +33,7 @@ def notice_top(request): if request.method == 'POST': return HttpResponse(status=405) id = request.user.id - notices = Notice.objects.filter(user__id=id,is_read=False)[:10] + notices = Notice.objects.filter(user__id=id, is_read=False)[:10] results = [] for o in notices: result = dict() @@ -41,7 +42,7 @@ def notice_top(request): result['content'] = o.content result['added'] = o.added.strftime("%Y-%m-%d %H:%M:%S") results.append(result) - return JsonResponse({'status': 'success', 'message':results}, safe=False) + return JsonResponse({'status': 'success', 'message': results}, safe=False) @csrf_exempt @@ -74,8 +75,16 @@ def detail_notice(request, notice_id): notice = Notice.objects.get(id=notice_id) results = dict() results['id'] = notice.id - - + results['category'] = notice.type + results['content'] = notice.content + results['app'] = notice.app + results['model'] = notice.model + results['field'] = notice.field + results['record_id'] = notice.record_id + results['record_pass_value'] = notice.record_pass_value + results['record_reject_value'] = notice.record_reject_value + results['added'] = notice.added.strftime("%Y-%m-%d %H:%M:%S") + result['updated'] = notice.updated.strftime("%Y-%m-%d %H:%M:%S") return JsonResponse({'status': 'success', 'message': results}) except ObjectDoesNotExist: return JsonResponse({'status': 'error', 'message': '通知ID错误'}) @@ -98,4 +107,4 @@ def reply_notice(request): m.save(update_fields=[notice.field]) return JsonResponse({'status': 'success'}) except ObjectDoesNotExist: - return JsonResponse({'status': 'error', 'message': '通知ID错误'}) \ No newline at end of file + return JsonResponse({'status': 'error', 'message': '通知ID错误'}) diff --git a/polls/views/organizations.py b/polls/views/organizations.py index d8a50b8..46d3490 100644 --- a/polls/views/organizations.py +++ b/polls/views/organizations.py @@ -42,5 +42,19 @@ def organizations(request): result['cities'] = o.cities result['district'] = o.district results.append(result) - - return JsonResponse({'status': 'success', 'message': results}, safe=False) \ No newline at end of file + return JsonResponse({'status': 'success', 'message': results}, safe=False) + + +@csrf_exempt +@polls_login_required +def organization_level(request): + profile = request.user.userprofile_set.first() + if not profile: + return JsonResponse({'status': 'error', 'message': '账户错误'}) + organization = profile.organization + if not organization: + return JsonResponse({'status': 'error', 'message': '机构错误'}) + level = organization.level.level + if not level: + return JsonResponse({'status': 'error', 'message': '权限错误'}) + return JsonResponse({'status': 'success', 'message': {'level': level, 'organization_id': organization.id}}, safe=False)