Merge remote-tracking branch 'origin/master'

This commit is contained in:
Bob 2020-10-05 10:16:33 +08:00
commit e3f30f9562
11 changed files with 79 additions and 13 deletions

View File

@ -9,6 +9,9 @@
<div class="col-xs-12">
<div id="chart2" style="width: 100%%;height:400px;margin:10px;"></div>
</div>
<div class="col-xs-12">
<div id="chart3" style="width: 100%%;height:400px;margin:10px;"></div>
</div>
</div>
</div>
{% 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} <br/>{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);
</script>
{% endblock %}

View File

@ -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,

View File

@ -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

View File

@ -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):

View File

@ -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错误'})

View File

@ -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)
@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)