This commit is contained in:
xieshen 2021-02-02 09:20:37 +08:00
commit 40ea32f3ed
4 changed files with 80 additions and 58 deletions

View File

@ -253,7 +253,8 @@ UNQUALIFIED_MEDIA_TYPE_CHOICES = (
class UnqualifiedMedia(models.Model): class UnqualifiedMedia(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
media = models.ForeignKey(NewMedia, on_delete=models.CASCADE) media_id = models.UUIDField('media_id', on_delete=models.CASCADE)
type = models.IntegerField('Type', choices=UNQUALIFIED_MEDIA_TYPE_CHOICES, default=0)
result = models.TextField('result', null=True, blank=True) result = models.TextField('result', null=True, blank=True)
cou = models.IntegerField('count of update', default=0) cou = models.IntegerField('count of update', default=0)
dos = models.IntegerField('days of silent', default=0) dos = models.IntegerField('days of silent', default=0)

View File

@ -1,56 +1,62 @@
{% extends 'polls/base.html' %} {% extends 'polls/base.html' %} {% load static %} {% block content%}
{% load static %}
{% block content%}
<div class="flex-container"> <div class="flex-container">
<div class="row"> <div class="row">
<div class="col-xs-12"> <div class="col-xs-12">
<div id="chart1" style="width: 100%%;height:400px;margin:20px 10px;"></div> <div>
</div> {% if level == '1' or level == '9'%} {% for key, value in
compartments.items %} {% if len(key) != 0 %}
<a
class="btn {{ cities==value|yesno:"btn-primary,btn-default" }}"
href="{% url 'myview' %}?province={{province}}&cities={{value}}&district={{district}}&level={{level}}"
role="button"
>{{value}}</a
>
{% endif%} {% endfor %} {% endif %}
{% if level == '2'%}
{% for key, value in
compartments.items %}
{% if key == cities %}
<a
class="btn {{ cities==value|yesno:"btn-primary,btn-default" }}"
href="{% url 'myview' %}?province={{province}}&cities={{value}}&district={{district}}&level={{level}}"
role="button"
>{{value}}</a
>
{% endif%}
{% endfor %}
{% endif%}
</div>
<table class="table table-bordered">
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>@fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>@twitter</td>
</tr>
</tbody>
</table>
</div> </div>
</div>
</div> </div>
{% endblock%} {% endblock%} {% block add_js %} {% 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

@ -1,6 +1,8 @@
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
from polls.models import UnqualifiedMedia
from dashboard.models import Douyin, NewMedia, Qita, Toutiao, Weibo, Weixin, Userprofile from dashboard.models import Douyin, NewMedia, Qita, Toutiao, Weibo, Weixin, Userprofile
from django.db.models import Count, Sum from django.db.models import Count, Sum
@ -143,6 +145,19 @@ def monitor_result(request):
def monitor_unqualified_result(request): def monitor_unqualified_result(request):
user_id = request.user.id if request.method == 'POST':
return HttpResponse(status=405)
return render(request, 'polls/monitor_unqualified_result.html') province = request.GET.get('province')
cities = request.GET.get('cities')
district = request.GET.get('district')
version = request.GET.get('version', '0')
level = request.GET.get('level', '0')
q = UnqualifiedMedia.objects.filter(version=version)
if province:
q = q.filter(media__organization__province=province)
if cities:
q = q.filter(media__organization__cities=cities)
if district:
q = q.filter(media__organization__district=district)
return render(request, 'polls/monitor_unqualified_result.html', {'medias': q, 'level': level, 'province': province, 'cities': cities, 'district': district, 'compartments': COMPARTMENTS})

View File

@ -57,4 +57,4 @@ def organization_level(request):
level = organization.level.level level = organization.level.level
if not level: if not level:
return JsonResponse({'status': 'error', 'message': '权限错误'}) return JsonResponse({'status': 'error', 'message': '权限错误'})
return JsonResponse({'status': 'success', 'message': {'level': level, 'cities': organization.cities, 'district': organization.district}}, safe=False) return JsonResponse({'status': 'success', 'message': {'level': level, 'province':organization.province, 'cities': organization.cities, 'district': organization.district}}, safe=False)