Merge remote-tracking branch 'origin/master'

This commit is contained in:
Bob 2020-09-26 18:24:54 +08:00
commit 91339e20ea
11 changed files with 75 additions and 8 deletions

View File

@ -0,0 +1,56 @@
{% extends 'polls/base.html' %}
{% load static %}
{% block content%}
<div class="flex-container">
<div class="row">
<div class="col-xs-12">
<div id="chart1" style="width: 100%%;height:400px;margin:20px 10px;"></div>
</div>
</div>
</div>
{% endblock%}
{% block add_js %}
<script src="{% static 'polls/js/echarts.min.js' %}"></script>
<script type="text/javascript">
var myChart = echarts.init(document.getElementById('chart1'));
var option = {
title: {
text: '政务新媒体存在问题占比',
left: 'center',
subtextStyle: {
fontSize: 16,
}
},
tooltip: {
trigger: 'item',
formatter: '{a} <br/>{b} : {c} ({d}%)'
},
legend: {
top: '15%',
data: ['账号不存在', '账号已关闭', '监测期间无更新', '两周无更新', '名称变更']
},
series: [
{
name: '总量',
type: 'pie',
radius: '55%',
center: ['50%', '60%'],
data: [
{name: '账号不存在', value:27},
{name: '账号已关闭', vlaue:1},
{name: '监测期间无更新', value:6},
{name: '两周无更新', value:46},
{name: '名称变更', value:25},
],
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]};
myChart.setOption(option);
</script>
{% endblock %}

View File

@ -55,7 +55,7 @@
var option2 = { var option2 = {
title: { title: {
text: '政务新媒体区域分布', text: '政务新媒体区域分布',
subtext: '省直部门{{total1}},市直部门{{total2}},县区政府{{total3}}', subtext: '省直部门{{total1}},市直部门{{total2}},县区政府{{total3}}',
subtextStyle: { subtextStyle: {
fontSize: 16, fontSize: 16,
}, },

View File

@ -30,6 +30,8 @@ urlpatterns = [
views.news_detail, name='polls_news_detail'), views.news_detail, name='polls_news_detail'),
path('monitor/statistics/', views.monitor_statistics, path('monitor/statistics/', views.monitor_statistics,
name='polls_monitor_statistics'), name='polls_monitor_statistics'),
path('monitor/result/', views.monitor_result,
name='polls_monitor_result'),
path('tasks/list/', views.tasks, name='polls_tasks_list'), path('tasks/list/', views.tasks, name='polls_tasks_list'),
path('tasks/create/', views.create_task, name='polls_tasks_create'), path('tasks/create/', views.create_task, name='polls_tasks_create'),
path('tasks/create_test/', views.create_test_task, path('tasks/create_test/', views.create_test_task,

View File

@ -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, reply_notice from .notice import notices, notice_top, read_notice, reply_notice
from .media import medias, my_medias, create_media, update_media, media_detail from .media import medias, my_medias, create_media, update_media, media_detail
from .news import news_list, news_top, news_detail from .news import news_list, news_top, news_detail
from .monitor import monitor_statistics from .monitor import monitor_statistics, monitor_result
from .task import tasks, create_task, create_test_task from .task import tasks, create_task, create_test_task
from .group import groups, room from .group import groups, room
from .compartment import compartments from .compartment import compartments

View File

@ -6,6 +6,7 @@ import datetime
from polls.decorators import polls_login_required from polls.decorators import polls_login_required
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from polls.models import Message from polls.models import Message
from dashboard.models import Userprofile
@csrf_exempt @csrf_exempt
@ -21,16 +22,19 @@ def last_messages(request):
result = dict() result = dict()
result['id'] = str(o.id) result['id'] = str(o.id)
result['type'] = o.type result['type'] = o.type
result['user_name'] = o.send_from.username profile = Userprofile.objects.filter(user_id=o.send_from_id).first()
result['user_name'] = profile.name
result['content'] = o.content result['content'] = o.content
result['page_title'] = o.page_title result['page_title'] = o.page_title
result['page_description'] = o.page_description result['page_description'] = o.page_description
result['page_image'] = o.page_image result['page_image'] = o.page_image
result['url'] = o.url result['url'] = o.url
result['file_title'] = o.file_title result['file_title'] = o.file_title
result['file'] = request.build_absolute_uri(o.file.uri) if o.file else '' result['file'] = request.build_absolute_uri(
o.file.uri) if o.file else ''
result['image_title'] = o.image_title result['image_title'] = o.image_title
result['picture'] = request.build_absolute_uri(o.picture.uri) if o.picture else '' result['picture'] = request.build_absolute_uri(
o.picture.uri) if o.picture else ''
result['added'] = o.added.strftime("%Y-%m-%d %H:%M:%S") result['added'] = o.added.strftime("%Y-%m-%d %H:%M:%S")
results.append(result) results.append(result)
return JsonResponse({'status': 'success', 'message': results}, safe=False) return JsonResponse({'status': 'success', 'message': results}, safe=False)

View File

@ -104,3 +104,7 @@ def monitor_statistics(request):
total3 = NewMedia.category_three_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}) return render(request, 'polls/monitor_statistics.html', {'chart1_data': chart1_data, 'total': total, 'chart2_data': chart2_data, 'total1': total1, 'total2': total2, 'total3': total3})
def monitor_result(request):
return render(request, 'polls/monitor_result.html')

View File

@ -24,13 +24,14 @@ def tasks(request):
result = dict() result = dict()
result['id'] = o.id result['id'] = o.id
m = [] m = []
for g in o.groups: for g in o.groups.all():
n = model_to_dict(g, ['id', 'name']) n = model_to_dict(g, ['id', 'name'])
m.append(n) m.append(n)
result['groups'] = m result['groups'] = m
result['content'] = o.content
result['added'] = o.added.strftime("%Y-%m-%d %H:%M:%S") result['added'] = o.added.strftime("%Y-%m-%d %H:%M:%S")
results.append(result) results.append(result)
return JsonResponse(results, safe=False) return JsonResponse({'status': 'success', 'message':results}, safe=False)
@csrf_exempt @csrf_exempt
@ -65,7 +66,7 @@ def create_task(request):
normalMessage = Message.objects.create( normalMessage = Message.objects.create(
type=4, send_from_id=user.id, send_to_id=group, task=task, content=content) type=4, send_from_id=user.id, send_to_id=group, task=task, content=content)
content = '用户%s发布了任务,请查收消息' % (profile.name,) content = '用户%s发布了任务,请查收消息' % (profile.name,)
Notice.create_normal_notice(user.id, content, 'dashboard') Notice.create_normal_notice(user.id, content)
return JsonResponse({'status': 'success'}) return JsonResponse({'status': 'success'})