diff --git a/polls/models.py b/polls/models.py index 68fb71f..0d1f204 100644 --- a/polls/models.py +++ b/polls/models.py @@ -253,7 +253,8 @@ UNQUALIFIED_MEDIA_TYPE_CHOICES = ( class UnqualifiedMedia(models.Model): 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) cou = models.IntegerField('count of update', default=0) dos = models.IntegerField('days of silent', default=0) diff --git a/polls/templates/polls/monitor_unqualified_result.html b/polls/templates/polls/monitor_unqualified_result.html index 2517a33..f1689cf 100644 --- a/polls/templates/polls/monitor_unqualified_result.html +++ b/polls/templates/polls/monitor_unqualified_result.html @@ -1,56 +1,62 @@ -{% extends 'polls/base.html' %} -{% load static %} -{% block content%} +{% extends 'polls/base.html' %} {% load static %} {% block content%}
-
-
-
-
+
+
+
+ {% if level == '1' or level == '9'%} {% for key, value in + compartments.items %} {% if len(key) != 0 %} + {{value}} + {% endif%} {% endfor %} {% endif %} + {% if level == '2'%} + {% for key, value in + compartments.items %} + {% if key == cities %} + {{value}} + {% endif%} + {% endfor %} + {% endif%} +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#First NameLast NameUsername
1MarkOtto@mdo
2JacobThornton@fat
3Larrythe Bird@twitter
+
-{% endblock%} -{% block add_js %} - - -{% endblock %} \ No newline at end of file +{% endblock%} {% block add_js %} {% endblock %} diff --git a/polls/views/monitor.py b/polls/views/monitor.py index c8ad3f2..32d7dd8 100644 --- a/polls/views/monitor.py +++ b/polls/views/monitor.py @@ -1,6 +1,8 @@ from django.shortcuts import render +from django.http import HttpResponse 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 django.db.models import Count, Sum @@ -143,6 +145,19 @@ def monitor_result(request): def monitor_unqualified_result(request): - user_id = request.user.id - - return render(request, 'polls/monitor_unqualified_result.html') + if request.method == 'POST': + return HttpResponse(status=405) + 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}) diff --git a/polls/views/organizations.py b/polls/views/organizations.py index d285009..21ae449 100644 --- a/polls/views/organizations.py +++ b/polls/views/organizations.py @@ -57,4 +57,4 @@ def organization_level(request): level = organization.level.level if not level: 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)