From 7c25ed8b691881aa486979a32b2ac853cc9251e6 Mon Sep 17 00:00:00 2001 From: Bob <1397910458@qq.com> Date: Tue, 29 Sep 2020 10:48:26 +0800 Subject: [PATCH] #qq --- dashboard/models.py | 1 + dashboard/views.py | 4 +- .../management/group-management-create.html | 10 ++ .../management/group-management-update.html | 11 ++ management/views.py | 44 ++++--- .../new-media-public-opinion-douyin.html | 110 ++++++++++++++++++ .../new-media-public-opinion-qita.html | 1 + .../new-media-public-opinion-toutiao.html | 1 + .../new-media-public-opinion-weibo.html | 1 + .../new-media-public-opinion-weixin.html | 1 + monitor/urls.py | 23 ++-- monitor/views.py | 29 ++++- 12 files changed, 200 insertions(+), 36 deletions(-) create mode 100644 monitor/templates/monitor/new-media-public-opinion-douyin.html diff --git a/dashboard/models.py b/dashboard/models.py index ee5be02..6e98ecc 100644 --- a/dashboard/models.py +++ b/dashboard/models.py @@ -112,6 +112,7 @@ class Organization(models.Model): level = models.ForeignKey( Level, on_delete=models.CASCADE, null=True, blank=True) directly = models.CharField('单位类型', max_length=256, null=True, blank=True) + status = models.CharField('状态',max_length=256,null=True,blank=True) created = models.DateTimeField('创建时间', auto_now_add=True) updated = models.DateTimeField('更新时间', auto_now=True) diff --git a/dashboard/views.py b/dashboard/views.py index 65c0cfe..bf313fa 100644 --- a/dashboard/views.py +++ b/dashboard/views.py @@ -27,7 +27,7 @@ def index(request): toutiao_count = Toutiao.objects.all().count() qita_count = Qita.objects.all().count() douyin_count = Douyin.objects.all().count() - organization_count = Organization.objects.all().count() + organization_count = Organization.objects.filter(status='1').count() # year = datetime.datetime.now().year # month = datetime.datetime.now().month # month = datetime.datetime.now().month @@ -95,7 +95,7 @@ def register(request): sex = None hash_key = CaptchaStore.generate_key() image_url = captcha_image_url(hash_key) - organization = Organization.objects.all() + organization = Organization.objects.filter(status='1') if request.method == 'POST': if not request.POST.get('organization'): messages.error(request, '请选择单位') diff --git a/management/templates/management/group-management-create.html b/management/templates/management/group-management-create.html index 829f684..1bad926 100644 --- a/management/templates/management/group-management-create.html +++ b/management/templates/management/group-management-create.html @@ -107,6 +107,16 @@ +
+ +
+ +
+
diff --git a/management/templates/management/group-management-update.html b/management/templates/management/group-management-update.html index 97a042b..1ad1515 100644 --- a/management/templates/management/group-management-update.html +++ b/management/templates/management/group-management-update.html @@ -108,6 +108,17 @@ +
+ +
+ +
+
diff --git a/management/views.py b/management/views.py index bb081e3..957d8ac 100644 --- a/management/views.py +++ b/management/views.py @@ -65,7 +65,7 @@ def user_delete(request, pk): def user_update(request, pk): user = User.objects.get(id=pk) userprofile = Userprofile.objects.get(user_id=user.id) - organization = Organization.objects.all() + organization = Organization.objects.filter(status='1') if request.method == 'POST': organization_id = request.POST.get('organization') name = request.POST.get('name') @@ -197,6 +197,10 @@ def group_update(request, pk): group_status_choices_list = [] for g in range(2): group_status_choices_list.append(g) + GROUP_CLASSIFY_CHOICES = Group.GROUP_CLASSIFY_CHOICES + g_c_c_res = [] + for g_c_c in GROUP_CLASSIFY_CHOICES: + g_c_c_res.append(list(g_c_c)[1]) group_type = Group_type.objects.all() group_admin = Group_admin.objects.filter(group_id=pk) print(pk) @@ -230,6 +234,7 @@ def group_update(request, pk): type = request.POST.get('type') status = request.POST.get('status') province = request.POST.get('province') + classify = request.POST.get('classify') print(str(province) + "66666666666666666666666666") if province != '' and province.isdigit(): province_r = Area_code_2020.objects.get(code=province).name @@ -258,7 +263,7 @@ def group_update(request, pk): if image is not None: Group.objects.filter(id=pk).update(name=name, presentation=presentation, type_id=type, status=status, province=province_r, cities=city_r, district=district_r, town=town_r, - village=village_r) + village=village_r,classify=classify) g = Group.objects.get(id=pk) g.image = image g.save() @@ -267,12 +272,12 @@ def group_update(request, pk): else: Group.objects.filter(id=pk).update(name=name, presentation=presentation, type_id=type, status=status, province=province_r, cities=city_r, district=district_r, town=town_r, - village=village_r) + village=village_r,classify=classify) messages.success(request, '修改成功') return HttpResponseRedirect('/management/group/management/init/') return render(request, 'management/group-management-update.html', {'group': group, 'group_status_choices_list': group_status_choices_list, 'group_type': group_type, - 'g_a_list': g_a_list, 'g_u_list': g_u_list}) + 'g_a_list': g_a_list, 'g_u_list': g_u_list,'g_c_c_res':g_c_c_res}) def group_create(request): @@ -281,6 +286,10 @@ def group_create(request): for g in range(2): group_status_choices_list.append(g) group_type = Group_type.objects.all() + GROUP_CLASSIFY_CHOICES = Group.GROUP_CLASSIFY_CHOICES + g_c_c_res = [] + for g_c_c in GROUP_CLASSIFY_CHOICES: + g_c_c_res.append(list(g_c_c)[1]) if request.method == 'POST': name = request.POST.get('name') presentation = request.POST.get('presentation') @@ -288,6 +297,7 @@ def group_create(request): type = request.POST.get('type') status = request.POST.get('status') province = request.POST.get('province') + classify = request.POST.get('classify') if province != '': province_r = Area_code_2020.objects.get(code=province).name else: @@ -316,7 +326,7 @@ def group_create(request): print(name, presentation, image, type, status, province, city, district, town, village) if name is not None: group = Group(name=name, presentation=presentation, image=image, type_id=type, status=status, - province=province_r, cities=city_r, district=district_r, town=town_r, village=village_r,user_id=user.id) + province=province_r, cities=city_r, district=district_r, town=town_r, village=village_r,user_id=user.id,classify=classify) group.save() messages.success(request, '添加成功') return render(request,'management/add-group-admin-and-user.html',{'group':group}) @@ -324,7 +334,7 @@ def group_create(request): messages.error(request, '矩阵名不能为空') # return HttpResponseRedirect('/management/group/management/') return render(request, 'management/group-management-create.html', - {'group_status_choices_list': group_status_choices_list, 'group_type': group_type}) + {'group_status_choices_list': group_status_choices_list, 'group_type': group_type,'g_c_c_res':g_c_c_res}) def group_admin_create(request, pk): @@ -525,7 +535,7 @@ def organization_create(request): if name is not None: organization = Organization(name=name, image=image, organizationtype_id=organizationtype, province=province, cities=city, district=district, town=town, - village=village,level_id=level_id) + village=village,level_id=level_id,status='0') organization.save() messages.success(request, '添加成功') else: @@ -542,7 +552,7 @@ def newmedia_management_create_weixin(request): weixin_status_choices_list = [] for w in range(2): weixin_status_choices_list.append(w) - organization = Organization.objects.all().order_by('-name') + organization = Organization.objects.filter(status='1').order_by('-name') if request.method == 'POST': code = request.POST.get('code') weixinid = request.POST.get('weixinid') @@ -580,7 +590,7 @@ def newmedia_management_create_weibo(request): weibo_status_choices_list = [] for w in range(2): weibo_status_choices_list.append(w) - organization = Organization.objects.all().order_by('-name') + organization = Organization.objects.filter(status='1').order_by('-name') if request.method == 'POST': code = request.POST.get('code') weiboid = request.POST.get('weiboid') @@ -619,7 +629,7 @@ def newmedia_management_create_toutiao(request): toutiao_status_choices_list = [] for w in range(2): toutiao_status_choices_list.append(w) - organization = Organization.objects.all().order_by('-name') + organization = Organization.objects.filter(status='1').order_by('-name') if request.method == 'POST': code = request.POST.get('code') toutiaoid = request.POST.get('toutiaoid') @@ -658,7 +668,7 @@ def newmedia_management_create_douyin(request): for w in range(2): douyin_status_choices_list.append(w) print(douyin_status_choices_list) - organization = Organization.objects.all().order_by('-name') + organization = Organization.objects.filter(status='1').order_by('-name') if request.method == 'POST': code = request.POST.get('code') douyinid = request.POST.get('douyinid') @@ -696,7 +706,7 @@ def newmedia_management_create_qita(request): qita_status_choices_list = [] for w in range(2): qita_status_choices_list.append(w) - organization = Organization.objects.all().order_by('-name') + organization = Organization.objects.filter(status='1').order_by('-name') if request.method == 'POST': type = request.POST.get('type') name = request.POST.get('name') @@ -1045,7 +1055,7 @@ def newmedia_management_update_weixin(request, pk): for w in range(2): weixin_status_choices_list.append(w) weixin = Weixin.objects.get(id=pk) - organization = Organization.objects.all() + organization = Organization.objects.filter(status='1') if request.method == 'POST': code = request.POST.get('code') weixinid = request.POST.get('weixinid') @@ -1087,7 +1097,7 @@ def newmedia_management_update_weibo(request, pk): for w in range(2): weibo_status_choices_list.append(w) weibo = Weibo.objects.get(id=pk) - organization = Organization.objects.all() + organization = Organization.objects.filter(status='1') if request.method == 'POST': code = request.POST.get('code') weiboid = request.POST.get('weiboid') @@ -1129,7 +1139,7 @@ def newmedia_management_update_toutiao(request, pk): for w in range(2): toutiao_status_choices_list.append(w) toutiao = Toutiao.objects.get(id=pk) - organization = Organization.objects.all() + organization = Organization.objects.filter(status='1') if request.method == 'POST': code = request.POST.get('code') toutiaoid = request.POST.get('toutiaoid') @@ -1170,7 +1180,7 @@ def newmedia_management_update_douyin(request, pk): for w in range(2): douyin_status_choices_list.append(w) douyin = Douyin.objects.get(id=pk) - organization = Organization.objects.all() + organization = Organization.objects.filter(status='1') if request.method == 'POST': code = request.POST.get('code') douyinid = request.POST.get('douyinid') @@ -1209,7 +1219,7 @@ def newmedia_management_update_qita(request, pk): qita_status_choices_list = [] for w in range(2): qita_status_choices_list.append(w) - organization = Organization.objects.all() + organization = Organization.objects.filter(status='1') qita = Qita.objects.get(id=pk) if request.method == 'POST': type = request.POST.get('type') diff --git a/monitor/templates/monitor/new-media-public-opinion-douyin.html b/monitor/templates/monitor/new-media-public-opinion-douyin.html new file mode 100644 index 0000000..e8b90c6 --- /dev/null +++ b/monitor/templates/monitor/new-media-public-opinion-douyin.html @@ -0,0 +1,110 @@ +{% extends 'dashboard/base/base.html' %} +{% load static %} +{% block content %} + + + + +
+ +
+ {% include 'dashboard/base/left.html' %} +
+
+
+ {% if messages %} + + {% endif %} + +
+
+
+
+ +
+
+
+
抖音热点
+
+
+
+ 公众号 + +
+
+ 分组 + +
+
+
+
+ + + + +
+
+ +
+
+ + + + + + + + + + + + + + + {% for r in res %} + + + + + + + + + + {% endfor %} + +
抖音号封面总发文量监测时间内发文量评论数作者回复数最近发文日期
{{ r.code }}{{ r.count }}{{ r.count_jc }}{{ r.comment }}{{ r.reply }}{{ r.date }}
+
+
+
+
+ +
+
+ +{% endblock %} diff --git a/monitor/templates/monitor/new-media-public-opinion-qita.html b/monitor/templates/monitor/new-media-public-opinion-qita.html index 0d14af2..a46dda0 100644 --- a/monitor/templates/monitor/new-media-public-opinion-qita.html +++ b/monitor/templates/monitor/new-media-public-opinion-qita.html @@ -34,6 +34,7 @@
  • 头条
  • 微博
  • +
  • 抖音
  • diff --git a/monitor/templates/monitor/new-media-public-opinion-toutiao.html b/monitor/templates/monitor/new-media-public-opinion-toutiao.html index 8ec5272..3066aad 100644 --- a/monitor/templates/monitor/new-media-public-opinion-toutiao.html +++ b/monitor/templates/monitor/new-media-public-opinion-toutiao.html @@ -32,6 +32,7 @@
  • 微信
  • 微博
  • +
  • 抖音
  • 其他
  • diff --git a/monitor/templates/monitor/new-media-public-opinion-weibo.html b/monitor/templates/monitor/new-media-public-opinion-weibo.html index f12048a..32ee65e 100644 --- a/monitor/templates/monitor/new-media-public-opinion-weibo.html +++ b/monitor/templates/monitor/new-media-public-opinion-weibo.html @@ -32,6 +32,7 @@
  • 微信
  • 头条
  • +
  • 抖音
  • 其他
  • diff --git a/monitor/templates/monitor/new-media-public-opinion-weixin.html b/monitor/templates/monitor/new-media-public-opinion-weixin.html index 2f57497..d846676 100644 --- a/monitor/templates/monitor/new-media-public-opinion-weixin.html +++ b/monitor/templates/monitor/new-media-public-opinion-weixin.html @@ -32,6 +32,7 @@
  • 头条
  • 微博
  • +
  • 抖音
  • 其他
  • diff --git a/monitor/urls.py b/monitor/urls.py index bec91b9..870212a 100644 --- a/monitor/urls.py +++ b/monitor/urls.py @@ -1,11 +1,12 @@ -from django.urls import path - -from . import views - -urlpatterns = [ - #新媒体舆情 - path('new/media/public/opinion/weixin/',views.new_media_public_opinion_weixin,name='monitor-new-media-public-opinion-weixin'), - path('new/media/public/opinion/weibo/',views.new_media_public_opinion_weibo,name='monitor-new-media-public-opinion-weibo'), - path('new/media/public/opinion/toutiao/',views.new_media_public_opinion_toutiao,name='monitor-new-media-public-opinion-toutiao'), - path('new/media/public/opinion/qita/',views.new_media_public_opinion_qita,name='monitor-new-media-public-opinion-qita'), -] +from django.urls import path + +from . import views + +urlpatterns = [ + #新媒体舆情 + path('new/media/public/opinion/weixin/',views.new_media_public_opinion_weixin,name='monitor-new-media-public-opinion-weixin'), + path('new/media/public/opinion/weibo/',views.new_media_public_opinion_weibo,name='monitor-new-media-public-opinion-weibo'), + path('new/media/public/opinion/toutiao/',views.new_media_public_opinion_toutiao,name='monitor-new-media-public-opinion-toutiao'), + path('new/media/public/opinion/douyin/',views.new_media_public_opinion_douyin,name='monitor-new-media-public-opinion-douyin'), + path('new/media/public/opinion/qita/',views.new_media_public_opinion_qita,name='monitor-new-media-public-opinion-qita'), +] diff --git a/monitor/views.py b/monitor/views.py index 3026024..df8f310 100644 --- a/monitor/views.py +++ b/monitor/views.py @@ -1,13 +1,14 @@ from django.shortcuts import render # Create your views here. -from dashboard.models import Weixin, Weixin_data, Toutiao_data, Weibo_data, Qita_jc, Group, Toutiao, Weibo, Qita +from dashboard.models import Weixin, Weixin_data, Toutiao_data, Weibo_data, Qita_jc, Group, Toutiao, Weibo, Qita, \ + Douyin, Douyin_data def new_media_public_opinion_weixin(request): weixin = Weixin.objects.all() group = Group.objects.all() - weixin_data = Weixin_data.objects.all() + weixin_data = Weixin_data.objects.all().order_by('-comment') res = [] for w in weixin_data: o = dict() @@ -26,7 +27,7 @@ def new_media_public_opinion_weixin(request): def new_media_public_opinion_toutiao(request): toutiao = Toutiao.objects.all() group = Group.objects.all() - toutiao_data = Toutiao_data.objects.all() + toutiao_data = Toutiao_data.objects.all().order_by('-count') res = [] for t in toutiao_data: o = dict() @@ -42,11 +43,27 @@ def new_media_public_opinion_toutiao(request): o['day'] = t.day res.append(o) return render(request, 'monitor/new-media-public-opinion-toutiao.html', {'res':res,'toutiao':toutiao,'group':group}) - +def new_media_public_opinion_douyin(request): + douyin = Douyin.objects.all() + group = Group.objects.all() + douyin_data = Douyin_data.objects.all().order_by('-comment') + res = [] + for d in douyin_data: + o = dict() + o['id'] = str(d.id) + o['code'] = d.newmedia.code + o['image'] = d.newmedia.image + o['count'] = d.count + o['count_jc'] = d.count_jc + o['comment'] = d.comment + o['reply'] = d.reply + o['date'] = d.date + res.append(o) + return render(request, 'monitor/new-media-public-opinion-douyin.html', {'res':res,'douyin':douyin,'group':group}) def new_media_public_opinion_weibo(request): weibo = Weibo.objects.all() group = Group.objects.all() - weibo_data = Weibo_data.objects.all() + weibo_data = Weibo_data.objects.all().order_by('-like') res = [] for w in weibo_data: o = dict() @@ -66,7 +83,7 @@ def new_media_public_opinion_weibo(request): def new_media_public_opinion_qita(request): qita = Qita.objects.all() group = Group.objects.all() - qita_jc = Qita_jc.objects.all() + qita_jc = Qita_jc.objects.all().order_by('-comment') res = [] for q in qita_jc: o = dict()