#add message

This commit is contained in:
xieshen 2020-11-18 15:48:17 +08:00
parent bfe195b0cc
commit f86836919b
24 changed files with 627 additions and 229 deletions

View File

@ -0,0 +1,60 @@
{% extends 'dashboard/base/base.html' %}
{% load static %}
{% block content %}
<body class=" ">
<!-- START TOPBAR -->
<!-- START CONTAINER -->
<div class="page-container row-fluid">
<div class="page-sidebar ">
{% include 'dashboard/base/left.html' %}
</div>
<section id="main-content" class=" ">
<section class="wrapper" style='margin-top:60px;display:inline-block;width:100%;padding:15px 0 0 15px;'>
{% if messages %}
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert">
<span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
</button>
{% for message in messages %}
{{ message }}.<br/>
{% endfor %}
</div>
{% endif %}
</section>
<div class="chatapi-windows "></div>
<div class="panel panel-default">
<div class="panel-body">
<div class="panel panel-default">
<div class="panel-heading">评论数据录入</div>
<div class="panel panel-default">
<!-- Default panel contents -->
<form action="{% url 'backstage-comment' %}" method="post"
enctype="multipart/form-data">{% csrf_token %}
{# <div class="form-group col-md-4">#}
{# <label for="date">时间</label>#}
{# <input type="date" class="form-control" id="source"#}
{# name="date">#}
{# </div>#}
<div class="form-group">
<label for="exampleInputFile">点击上传文件</label>
<input type="file" id="exampleInputFile" name="file">
<p class="help-block">请上传csv文件(文件表头依次为评论、回复、新媒体名称、标题、时间、文章链接。时间格式为2020/11/17)</p>
</div>
<button type="submit" class="btn btn-success">点击上传</button>
</form>
</div>
</div>
</div>
</div>
</section>
</div>
</body>
{% endblock %}

View File

@ -0,0 +1,60 @@
{% extends 'dashboard/base/base.html' %}
{% load static %}
{% block content %}
<body class=" ">
<!-- START TOPBAR -->
<!-- START CONTAINER -->
<div class="page-container row-fluid">
<div class="page-sidebar ">
{% include 'dashboard/base/left.html' %}
</div>
<section id="main-content" class=" ">
<section class="wrapper" style='margin-top:60px;display:inline-block;width:100%;padding:15px 0 0 15px;'>
{% if messages %}
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert">
<span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
</button>
{% for message in messages %}
{{ message }}.<br/>
{% endfor %}
</div>
{% endif %}
</section>
<div class="chatapi-windows "></div>
<div class="panel panel-default">
<div class="panel-body">
<div class="panel panel-default">
<div class="panel-heading">错别字数据录入</div>
<div class="panel panel-default">
<!-- Default panel contents -->
<form action="{% url 'backstage-error' %}" method="post"
enctype="multipart/form-data">{% csrf_token %}
{# <div class="form-group col-md-4">#}
{# <label for="date">时间</label>#}
{# <input type="date" class="form-control" id="source"#}
{# name="date">#}
{# </div>#}
<div class="form-group">
<label for="exampleInputFile">点击上传文件</label>
<input type="file" id="exampleInputFile" name="file">
<p class="help-block">请上传csv文件(文件表头依次为错误、建议、定位、新媒体类型、账号、发文时间、标题、市、监测时间。时间格式为2020/11/17)</p>
</div>
<button type="submit" class="btn btn-success">点击上传</button>
</form>
</div>
</div>
</div>
</div>
</section>
</div>
</body>
{% endblock %}

View File

@ -6,4 +6,5 @@ from backstage import views
urlpatterns = [ urlpatterns = [
path('backstage/newmedia/public/opinion/',views.backstage_new_media_public_opinion,name='backstage-new-media-public-opinion'), path('backstage/newmedia/public/opinion/',views.backstage_new_media_public_opinion,name='backstage-new-media-public-opinion'),
path('backstage/error/',views.backstage_error,name='backstage-error'), path('backstage/error/',views.backstage_error,name='backstage-error'),
path('backstage/comment/',views.backstage_comment,name='backstage-comment'),
] ]

View File

@ -9,7 +9,7 @@ from django.shortcuts import render
# Create your views here. # Create your views here.
from NewMediaMonitoring import settings from NewMediaMonitoring import settings
from dashboard.models import TimelinessMonitoring from dashboard.models import TimelinessMonitoring, Wrongly, Comment
def backstage_new_media_public_opinion(request): def backstage_new_media_public_opinion(request):
@ -20,7 +20,7 @@ def backstage_new_media_public_opinion(request):
if not os.path.exists(settings.MEDIA_ROOT): if not os.path.exists(settings.MEDIA_ROOT):
os.makedirs(settings.MEDIA_ROOT) os.makedirs(settings.MEDIA_ROOT)
if filename is None: if filename is None:
messages.error(request,'请选择要上传的文件!!!') messages.error(request, '请选择要上传的文件!!!')
return HttpResponseRedirect('/backstage/backstage/newmedia/public/opinion/') return HttpResponseRedirect('/backstage/backstage/newmedia/public/opinion/')
if str(filename).split('.')[1] == 'csv': if str(filename).split('.')[1] == 'csv':
data = filename.read().decode("utf-8") data = filename.read().decode("utf-8")
@ -40,7 +40,6 @@ def backstage_new_media_public_opinion(request):
# messages.error(request, '请上传正确的时间格式!!!') # messages.error(request, '请上传正确的时间格式!!!')
# return HttpResponseRedirect('/backstage/backstage/newmedia/public/opinion/') # return HttpResponseRedirect('/backstage/backstage/newmedia/public/opinion/')
try: try:
if v[8] != '更新次数': if v[8] != '更新次数':
# if v[8].isdigit(): # if v[8].isdigit():
@ -76,5 +75,74 @@ def backstage_new_media_public_opinion(request):
return render(request, 'backstage/backstage_new_media_public_opinion.html') return render(request, 'backstage/backstage_new_media_public_opinion.html')
def backstage_error(resquest):
pass def backstage_error(request):
if request.method == 'POST':
filename = request.FILES.get('file')
if not os.path.exists(settings.MEDIA_ROOT):
os.makedirs(settings.MEDIA_ROOT)
if filename is None:
messages.error(request, '请选择要上传的文件!!!')
return HttpResponseRedirect('/backstage/backstage/error/')
if str(filename).split('.')[1] == 'csv':
data = filename.read().decode("utf-8")
line = str(data).split('\n')
for l in line:
v = l.split(',')
try:
if v[0] != '错误':
print(v[0])
error = v[0]
idea = v[1]
site = v[2]
n_type = v[3]
n_name = v[4]
date = v[5]
title = v[6]
city = v[7]
jc_date = v[8]
wrongly = Wrongly(error=error, idea=idea, site=site, n_type=n_type, n_name=n_name, date=date,
title=title, city=city, jc_date=jc_date)
wrongly.save()
except:
print(v)
else:
messages.error(request, '请上传正确的文件类型!!!')
return HttpResponseRedirect('/backstage/backstage/error/')
return render(request, 'backstage/backstage-error.html')
def backstage_comment(request):
if request.method == 'POST':
filename = request.FILES.get('file')
if not os.path.exists(settings.MEDIA_ROOT):
os.makedirs(settings.MEDIA_ROOT)
if filename is None:
messages.error(request, '请选择要上传的文件!!!')
return HttpResponseRedirect('/backstage/backstage/comment/')
if str(filename).split('.')[1] == 'csv':
data = filename.read().decode("utf-8")
line = str(data).split('\n')
for l in line:
v = l.split(',')
try:
if v[0] != '评论':
print(v[0])
comment = v[0]
reply = v[1]
name = v[2]
title = v[3]
date = v[4]
url = v[5]
comment = Comment(comment=comment, reply=reply, name=name, title=title, date=date, url=url)
comment.save()
except:
print(v)
else:
messages.error(request, '请上传正确的文件类型!!!')
return HttpResponseRedirect('/backstage/backstage/comment/')
return render(request, 'backstage/backstage-comment.html')

View File

@ -762,10 +762,25 @@ class Wrongly(models.Model):
n_name = models.CharField('新媒体名称', max_length=256, null=True, blank=True) n_name = models.CharField('新媒体名称', max_length=256, null=True, blank=True)
date = models.CharField('发布时间', max_length=256, null=True, blank=True) date = models.CharField('发布时间', max_length=256, null=True, blank=True)
title = models.CharField('标题', max_length=256, null=True, blank=True) title = models.CharField('标题', max_length=256, null=True, blank=True)
url = models.CharField('URL', max_length=256, null=True, blank=True) city = models.CharField('', max_length=256, null=True, blank=True)
jc_date = models.CharField('监测时间', max_length=256, null=True, blank=True)
def __str__(self): def __str__(self):
return self.title return self.title
#时效性监测文件存储表 #评论临时表
class Comment(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
comment = models.TextField('评论', null=True, blank=True)
user = models.CharField('用户', max_length=256, null=True, blank=True)
reply = models.TextField('回复', null=True, blank=True)
name = models.CharField('新媒体名称',max_length=256, null=True, blank=True)
title = models.CharField('标题',max_length=256, null=True, blank=True)
date = models.CharField('时间',max_length=256, null=True, blank=True)
url = models.CharField('文章链接',max_length=256, null=True, blank=True)
created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True)
def __str__(self):
return self.user

View File

@ -165,30 +165,31 @@
<span class="title">系统设置</span> <span class="title">系统设置</span>
</a> </a>
</li> </li>
<li {% if url_name|startswith:'backstag' %}class="open" {% endif %}> {% for u in user.userprofile_set.all %}
<a href="javascript:;"> {% if u.organization.level.level == 9 %}
<i class="fa fa-sliders"></i> <li {% if url_name|startswith:'backstag' %}class="open" {% endif %}>
<span class="title">后台管理</span> <a href="javascript:;">
<span class="arrow "></span> <i class="fa fa-sliders"></i>
</a> <span class="title">后台管理</span>
<ul class="sub-menu"> <span class="arrow "></span>
<li> </a>
<a {% if url_name == 'backstage-new-media-public-opinion' %} class="active" {% endif %} <ul class="sub-menu">
href="{% url 'backstage-new-media-public-opinion' %}">时效性监测</a> <li>
<a {% if url_name == 'backstage-new-media-public-opinion' %} class="active" {% endif %}
href="{% url 'backstage-new-media-public-opinion' %}">时效性监测</a>
</li>
<li>
<a {% if url_name == 'backstage-error' %} class="active" {% endif %}
href="{% url 'backstage-error' %}">错别字</a>
</li>
<li>
<a {% if url_name == 'backstage-comment' %} class="active" {% endif %}
href="{% url 'backstage-comment' %}">评论</a>
</li>
</ul>
</li> </li>
{# <li>#} {% endif %}
{# <a {% if url_name == 'group-management-management-init' %} class="active" {% endif %}#} {% endfor %}
{# href="{% url 'group-management-management-init' %}">错别字</a>#}
{# </li>#}
{# <li>#}
{# <a {% if url_name == 'group-management-management-init' %} class="active" {% endif %}#}
{# href="{% url 'group-management-management-init' %}">时效性监测</a>#}
{# </li>#}
{# <li>#}
{# <a class="" href="">搜索添加单位</a>#}
{# </li>#}
</ul>
</li>
{# <li class="">#} {# <li class="">#}
{# <a href="javascript:;">#} {# <a href="javascript:;">#}
{# <i class="fa fa-columns"></i>#} {# <i class="fa fa-columns"></i>#}

View File

@ -165,28 +165,28 @@
<div class="col-lg-6 col-md-6 col-sm-7 col-xs-12"> <div class="col-lg-6 col-md-6 col-sm-7 col-xs-12">
{# <div class="r1_graph1 db_box">#} {# <div class="r1_graph1 db_box">#}
{# <span class='bold'>时间/更新篇数</span>#} {# <span class='bold'>时间/更新篇数</span>#}
{# <span class='pull-right'><small>SERVER UP</small></span>#} {# <span class='pull-right'><small>SERVER UP</small></span>#}
{# <div class="clearfix"></div>#} {# <div class="clearfix"></div>#}
{# <span class="db_dynamicbar">Loading...</span>#} {# <span class="db_dynamicbar">Loading...</span>#}
{# </div>#} {# </div>#}
<div class="r1_graph2 db_box"> <div class="r1_graph2 db_box">
<span class='bold'>新媒体数量/时间</span> <span class='bold'>新媒体数量/时间</span>
<div id="left2" style="width: 100%;height:150px;background-color: white"></div> <div id="left2" style="width: 100%;height:150px;background-color: white"></div>
{# <span class='pull-right'><small>USERS ONLINE</small></span>#} {# <span class='pull-right'><small>USERS ONLINE</small></span>#}
{# <div class="clearfix"></div>#} {# <div class="clearfix"></div>#}
</div> </div>
<div class="r1_graph3 db_box"> <div class="r1_graph3 db_box">
<span class='bold'>预警次数/时间</span> <span class='bold'>预警次数/时间</span>
<div id="left3" style="width: 100%;height:140px;background-color: white"></div> <div id="left3" style="width: 100%;height:140px;background-color: white"></div>
{# <span class='pull-right'><small>ORDERS / SALES</small></span>#} {# <span class='pull-right'><small>ORDERS / SALES</small></span>#}
{# <div class="clearfix"></div>#} {# <div class="clearfix"></div>#}
</div> </div>
</div> </div>
@ -237,7 +237,7 @@
<script src="{% static 'js/jquery-jvectormap-world-mill-en.js' %}" type="text/javascript"></script> <script src="{% static 'js/jquery-jvectormap-world-mill-en.js' %}" type="text/javascript"></script>
<script src="{% static 'js/gauge.min.js' %}" type="text/javascript"></script> <script src="{% static 'js/gauge.min.js' %}" type="text/javascript"></script>
<script src="{% static 'js/icheck.min.js' %}" type="text/javascript"></script> <script src="{% static 'js/icheck.min.js' %}" type="text/javascript"></script>
{# <script src="{% static 'js/dashboard.js' %}" type="text/javascript"></script>#} {# <script src="{% static 'js/dashboard.js' %}" type="text/javascript"></script>#}
<script src="{% static 'js/echarts.min.js' %}" type="text/javascript"></script> <script src="{% static 'js/echarts.min.js' %}" type="text/javascript"></script>
<script src="{% static 'js/chart-sparkline.js' %}" type="text/javascript"></script> <script src="{% static 'js/chart-sparkline.js' %}" type="text/javascript"></script>
<script src="{% static 'leaflet/leaflet.js' %}" type="text/javascript"></script> <script src="{% static 'leaflet/leaflet.js' %}" type="text/javascript"></script>
@ -372,6 +372,36 @@
$.getJSON('/monitor/index/newmedia/count/', function (res) { $.getJSON('/monitor/index/newmedia/count/', function (res) {
// 基于准备好的dom初始化echarts实例 // 基于准备好的dom初始化echarts实例
var myChart = echarts.init(document.getElementById('left2')); var myChart = echarts.init(document.getElementById('left2'));
var weixin = res.weixin
for (var i = 0; i < weixin.length; i++) {
if (weixin[i] != '3099') {
weixin[i] = 3099 + weixin[i]
}
}
var weibo = res.weibo
for (var i = 0; i < weibo.length; i++) {
if (weibo[i] != '774') {
weibo[i] = 774 + weibo[i]
}
}
var toutiao = res.toutiao
for (var i = 0; i < toutiao.length; i++) {
if (toutiao[i] != '615') {
toutiao[i] = 615 + toutiao[i]
}
}
var douyin = res.douyin
for (var i = 0; i < douyin.length; i++) {
if (douyin[i] != '451') {
douyin[i] = 451 + douyin[i]
}
}
var qita = res.qita
for (var i = 0; i < qita.length; i++) {
if (qita[i] != '295') {
qita[i] = 295 + qita[i]
}
}
option = { option = {
{#title: {#} {#title: {#}
{# text: '新媒体数量/时间',#} {# text: '新媒体数量/时间',#}
@ -407,31 +437,31 @@
name: '微信', name: '微信',
type: 'line', type: 'line',
stack: '总量', stack: '总量',
data: res.weixin data: weixin
}, },
{ {
name: '微博', name: '微博',
type: 'line', type: 'line',
stack: '总量', stack: '总量',
data: res.weibo data: weibo
}, },
{ {
name: '今日头条', name: '今日头条',
type: 'line', type: 'line',
stack: '总量', stack: '总量',
data: res.toutiao data: toutiao
}, },
{ {
name: '抖音', name: '抖音',
type: 'line', type: 'line',
stack: '总量', stack: '总量',
data: res.douyin data: douyin
}, },
{ {
name: '其他', name: '其他',
type: 'line', type: 'line',
stack: '总量', stack: '总量',
data: res.qita data: qita
} }
] ]
}; };
@ -441,45 +471,118 @@
$.getJSON('/monitor/index/warning/count/', function (res) { $.getJSON('/monitor/index/warning/count/', function (res) {
// 基于准备好的dom初始化echarts实例 // 基于准备好的dom初始化echarts实例
var myChart = echarts.init(document.getElementById('left3')); var myChart = echarts.init(document.getElementById('left3'));
{#option = {#}
{#title: {#}
{# text: '新媒体数量/时间',#}
{# },#}
{# tooltip: {#}
{# trigger: 'axis'#}
{# },#}
{# legend: {#}
{# data: ['预警']#}
{# },#}
{# grid: {#}
{# left: '3%',#}
{# right: '6%',#}
{# bottom: '1%',#}
{# top: '20px',#}
{# containLabel: true#}
{# },#}
{# toolbox: {#}
{# feature: {#}
{# saveAsImage: {}#}
{# }#}
{# },#}
{# xAxis: {#}
{# type: 'category',#}
{# boundaryGap: false,#}
{# data: res.date_list#}
{# },#}
{# yAxis: {#}
{# type: 'value'#}
{# },#}
{# series: [#}
{# {#}
{# name: '预警',#}
{# type: 'line',#}
{# stack: '总量',#}
{# data: res.data#}
{# }#}
{# ]#}
{# };#}
option = { option = {
{#title: {#}
{# text: '新媒体数量/时间',#}
{# },#}
tooltip: { tooltip: {
trigger: 'axis' trigger: 'axis',
axisPointer: {
type: 'cross',
crossStyle: {
color: '#999'
}
}
},
toolbox: {
feature: {
{#dataView: {show: true, readOnly: false},#}
magicType: {show: true, type: ['line', 'bar']},
{#restore: {show: true},#}
{#saveAsImage: {show: true}#}
}
}, },
legend: { legend: {
data: ['预警'] data: ['监测报告', '预警账号']
}, },
grid: { grid: {
left: '3%', left: '3%',
right: '6%', right: '6%',
bottom: '1%', bottom: '1%',
top: '20px', top: '17px',
containLabel: true containLabel: true
}, },
toolbox: { xAxis: [
feature: { {
saveAsImage: {} type: 'category',
data: res.date_list,
axisPointer: {
type: 'shadow'
}
} }
}, ],
xAxis: { yAxis: [
type: 'category', {
boundaryGap: false, type: 'value',
data: res.date_list name: '监测报告',
}, min: 0,
yAxis: { max: 1,
type: 'value' interval: 1,
}, {#axisLabel: {#}
{# formatter: '{value} ml'#}
{# }#}
},
{
type: 'value',
name: '预警账号',
min: 0,
max: 25,
interval: 25
{#axisLabel: {#}
{# formatter: '{value} °C'#}
{# }#}
}
],
series: [ series: [
{ {
name: '预警', name: '监测报告',
type: 'line', type: 'bar',
stack: '总量', data: res.data
},
{
name: '预警账号',
type: 'bar',
data: res.data data: res.data
} }
] ]
}; };
// 使用刚指定的配置项和数据显示图表。 // 使用刚指定的配置项和数据显示图表。
myChart.setOption(option); myChart.setOption(option);
}) })

View File

@ -0,0 +1,18 @@
<div id="pages" class="text-center">
<nav>
<ul class="pagination">
<li class="step-links">
{% if comment.has_previous %}
<a class='active' href="?page={{ comment.previous_page_number }}">上一页</a>
{% endif %}
<span class="current">
第{{ comment.number }}页 共{{ comment.paginator.num_pages }}页</span>
{% if comment.has_next %}
<a class='active' href="?page={{ comment.next_page_number }}">下一页</a>
{% endif %}
</li>
</ul>
</nav>
</div>

View File

@ -35,8 +35,11 @@ def refresh_captcha(request):
to_json_response['new_cptch_image'] = captcha_image_url(to_json_response['new_cptch_key']) to_json_response['new_cptch_image'] = captcha_image_url(to_json_response['new_cptch_key'])
return JsonResponse(to_json_response) return JsonResponse(to_json_response)
def home(request): def home(request):
return render(request,'dashboard/home.html') return render(request, 'dashboard/home.html')
def index(request): def index(request):
weixin_count = Weixin.objects.all().count() weixin_count = Weixin.objects.all().count()
weibo_count = Weibo.objects.all().count() weibo_count = Weibo.objects.all().count()
@ -146,15 +149,15 @@ def improve_personal_information(request, pk):
if Organization.objects.get(name=o): if Organization.objects.get(name=o):
o_id = Organization.objects.get(name=o).id o_id = Organization.objects.get(name=o).id
else: else:
messages.error(request,'您填写的单位不存在!!!') messages.error(request, '您填写的单位不存在!!!')
if request.POST.get('name'): if request.POST.get('name'):
name = request.POST.get('name') name = request.POST.get('name')
else: else:
messages.error(request,'请输入您的姓名!!!') messages.error(request, '请输入您的姓名!!!')
if request.POST.get('email'): if request.POST.get('email'):
email = request.POST.get('email') email = request.POST.get('email')
else: else:
messages.error(request,'请输入您的邮箱!!!') messages.error(request, '请输入您的邮箱!!!')
if request.FILES.get('image'): if request.FILES.get('image'):
image = request.POST.get('image') image = request.POST.get('image')
else: else:
@ -162,14 +165,14 @@ def improve_personal_information(request, pk):
if request.POST.get('password'): if request.POST.get('password'):
password = request.POST.get('password') password = request.POST.get('password')
else: else:
messages.error(request,'请输入密码') messages.error(request, '请输入密码')
confirm_password = request.POST.get('confirm_password') confirm_password = request.POST.get('confirm_password')
if password is not None and confirm_password is not None: if password is not None and confirm_password is not None:
if password == confirm_password: if password == confirm_password:
User.objects.filter(id=pk).update(email=email,password=make_password(password)) User.objects.filter(id=pk).update(email=email, password=make_password(password))
userprofile=Userprofile(name=name,image=image,organization_id=o_id,user_id=user.id) userprofile = Userprofile(name=name, image=image, organization_id=o_id, user_id=user.id)
userprofile.save() userprofile.save()
messages.success(request,'修改成功') messages.success(request, '修改成功')
return render(request, 'dashboard/user-improve-personal-information.html', {'usee': user}) return render(request, 'dashboard/user-improve-personal-information.html', {'usee': user})
@ -251,7 +254,7 @@ def register(request):
if res > 0: if res > 0:
user_organization = Organization.objects.get(name=o).id user_organization = Organization.objects.get(name=o).id
else: else:
messages.error(request,'您填写的单位不存在') messages.error(request, '您填写的单位不存在')
if not request.POST.get('name'): if not request.POST.get('name'):
messages.error(request, '请输入姓名') messages.error(request, '请输入姓名')
else: else:
@ -274,7 +277,7 @@ def register(request):
else: else:
confirm_password = request.POST.get('confirm_password') confirm_password = request.POST.get('confirm_password')
if not request.FILES.get('image'): if not request.FILES.get('image'):
image='/profile/user_default.jpg' image = '/profile/user_default.jpg'
else: else:
image = request.FILES.get('image') image = request.FILES.get('image')
print(str(image) + "1111111111111111111111111111111111111111111") print(str(image) + "1111111111111111111111111111111111111111111")
@ -419,6 +422,8 @@ def import_user(request):
except: except:
print(phone) print(phone)
return HttpResponse('ok') return HttpResponse('ok')
@login_required @login_required
def user_search_by_keyword(request): def user_search_by_keyword(request):
user = request.user user = request.user
@ -429,29 +434,35 @@ def user_search_by_keyword(request):
district = o.district district = o.district
keytype = request.POST.get('keytype') keytype = request.POST.get('keytype')
keyword = request.POST.get('ketword') keyword = request.POST.get('ketword')
print(keytype,keyword) print(keytype, keyword)
userpaginator = None userpaginator = None
if level == 1: if level == 1:
if keytype == '1': if keytype == '1':
userpaginator = Userprofile.objects.filter(name__contains=keyword,userprofile__organization__province=province) userpaginator = Userprofile.objects.filter(name__contains=keyword,
userprofile__organization__province=province)
elif keytype == '2': elif keytype == '2':
userpaginator = Userprofile.objects.filter(organization__name__contains=keyword,userprofile__organization__province=province) userpaginator = Userprofile.objects.filter(organization__name__contains=keyword,
userprofile__organization__province=province)
elif level == 2: elif level == 2:
if keytype == '1': if keytype == '1':
userpaginator = Userprofile.objects.filter(name__contains=keyword,userprofile__organization__province=province, userpaginator = Userprofile.objects.filter(name__contains=keyword,
userprofile__organization__cities=cities) userprofile__organization__province=province,
userprofile__organization__cities=cities)
elif keytype == '2': elif keytype == '2':
userpaginator = Userprofile.objects.filter(organization__name__contains=keyword,userprofile__organization__province=province, userpaginator = Userprofile.objects.filter(organization__name__contains=keyword,
userprofile__organization__cities=cities) userprofile__organization__province=province,
userprofile__organization__cities=cities)
elif level == 3: elif level == 3:
if keytype == '1': if keytype == '1':
userpaginator = Userprofile.objects.filter(name__contains=keyword,userprofile__organization__province=province, userpaginator = Userprofile.objects.filter(name__contains=keyword,
userprofile__organization__cities=cities, userprofile__organization__province=province,
userprofile__organization__district=district) userprofile__organization__cities=cities,
userprofile__organization__district=district)
elif keytype == '2': elif keytype == '2':
userpaginator = Userprofile.objects.filter(organization__name__contains=keyword,userprofile__organization__province=province, userpaginator = Userprofile.objects.filter(organization__name__contains=keyword,
userprofile__organization__cities=cities, userprofile__organization__province=province,
userprofile__organization__district=district) userprofile__organization__cities=cities,
userprofile__organization__district=district)
elif level == 9: elif level == 9:
if keytype == '1': if keytype == '1':
userpaginator = Userprofile.objects.filter(name__contains=keyword) userpaginator = Userprofile.objects.filter(name__contains=keyword)
@ -466,7 +477,8 @@ def user_search_by_keyword(request):
# userpaginator = paginator.page(1) # userpaginator = paginator.page(1)
# except EmptyPage: # except EmptyPage:
# userpaginator = paginator.page(paginator.num_pages) # userpaginator = paginator.page(paginator.num_pages)
user_count = userpaginator.count() if userpaginator:
user_count = userpaginator.count()
userallinfo = [] userallinfo = []
for u in userpaginator[:30]: for u in userpaginator[:30]:
o = dict() o = dict()
@ -519,7 +531,8 @@ def user_search_by_keyword(request):
userallinfo.append(o) userallinfo.append(o)
print(userallinfo) print(userallinfo)
return render(request, 'management/user-management.html', return render(request, 'management/user-management.html',
{'userallinfo': userallinfo, 'userpaginator': userpaginator,'user_count':user_count}) {'userallinfo': userallinfo, 'userpaginator': userpaginator, 'user_count': user_count})
@login_required @login_required
def news_search_by_keyword(request): def news_search_by_keyword(request):
@ -528,19 +541,21 @@ def news_search_by_keyword(request):
print(keytype, keyword) print(keytype, keyword)
news = None news = None
if keytype == '1': if keytype == '1':
news = News.objects.filter(type='0',title__contains=keyword) news = News.objects.filter(type='0', title__contains=keyword)
elif keytype == '2': elif keytype == '2':
news = News.objects.filter(type='1',title__contains=keyword) news = News.objects.filter(type='1', title__contains=keyword)
elif keytype == '3': elif keytype == '3':
news = News.objects.filter(type='2',title__contains=keyword) news = News.objects.filter(type='2', title__contains=keyword)
elif keytype == '4': elif keytype == '4':
news = News.objects.filter(type='3',title__contains=keyword) news = News.objects.filter(type='3', title__contains=keyword)
elif keytype == '5': elif keytype == '5':
news = News.objects.filter(type='4',title__contains=keyword) news = News.objects.filter(type='4', title__contains=keyword)
elif keytype == '6': elif keytype == '6':
news = News.objects.filter(type='5',title__contains=keyword) news = News.objects.filter(type='5', title__contains=keyword)
elif keytype == '7': elif keytype == '7':
news = News.objects.filter(type='6',title__contains=keyword) news = News.objects.filter(type='6', title__contains=keyword)
elif keytype == '0':
news = News.objects.filter(title__contains=keyword)
news_list = [] news_list = []
news_count = news.count() news_count = news.count()
for n in news[:30]: for n in news[:30]:
@ -567,6 +582,7 @@ def news_search_by_keyword(request):
return render(request, 'management/news-management.html', return render(request, 'management/news-management.html',
{'news': news_list, 'new': news, 'news_count': news_count}) {'news': news_list, 'new': news, 'news_count': news_count})
@login_required @login_required
def organization_search_by_keyword(request): def organization_search_by_keyword(request):
keytype = request.POST.get('keytype') keytype = request.POST.get('keytype')
@ -583,14 +599,16 @@ def organization_search_by_keyword(request):
res = [] res = []
if level == 1: if level == 1:
if keytype == '1': if keytype == '1':
organization = Organization.objects.filter(province=province,name__contains=keyword).order_by('-created') organization = Organization.objects.filter(province=province, name__contains=keyword).order_by('-created')
elif level == 2: elif level == 2:
if keytype == '1': if keytype == '1':
organization = Organization.objects.filter(province=province, cities=cities,name__contains=keyword).order_by('-created') organization = Organization.objects.filter(province=province, cities=cities,
name__contains=keyword).order_by('-created')
elif level == 3: elif level == 3:
if keytype == '1': if keytype == '1':
organization = Organization.objects.filter(province=province, cities=cities, district=district,name__contains=keyword).order_by( organization = Organization.objects.filter(province=province, cities=cities, district=district,
'-created') name__contains=keyword).order_by(
'-created')
elif level == 9: elif level == 9:
if keytype == '1': if keytype == '1':
organization = Organization.objects.filter(name__contains=keyword).order_by('-created') organization = Organization.objects.filter(name__contains=keyword).order_by('-created')
@ -628,7 +646,9 @@ def organization_search_by_keyword(request):
organization_id=i.id).count() organization_id=i.id).count()
res.append(o) res.append(o)
return render(request, 'management/organization-management.html', {"organization": organization, 'res': res,'organization_count':organization_count}) return render(request, 'management/organization-management.html',
{"organization": organization, 'res': res, 'organization_count': organization_count})
@login_required @login_required
def weixin_search_by_keyword(request): def weixin_search_by_keyword(request):
@ -644,24 +664,28 @@ def weixin_search_by_keyword(request):
res = [] res = []
if level == 1: if level == 1:
if keytype == '1': if keytype == '1':
weixin = Weixin.objects.filter(organization__province=province,code__contains=keyword).order_by('-created') weixin = Weixin.objects.filter(organization__province=province, code__contains=keyword).order_by('-created')
elif keytype == '2': elif keytype == '2':
weixin = Weixin.objects.filter(organization__province=province, organization__name__contains=keyword).order_by('-created') weixin = Weixin.objects.filter(organization__province=province,
organization__name__contains=keyword).order_by('-created')
elif level == 2: elif level == 2:
if keytype == '1': if keytype == '1':
weixin = Weixin.objects.filter(organization__province=province, organization__cities=cities,code__contains=keyword).order_by( weixin = Weixin.objects.filter(organization__province=province, organization__cities=cities,
'-created') code__contains=keyword).order_by(
'-created')
elif keytype == '2': elif keytype == '2':
weixin = Weixin.objects.filter(organization__province=province, organization__cities=cities, organization__name__contains=keyword).order_by( weixin = Weixin.objects.filter(organization__province=province, organization__cities=cities,
organization__name__contains=keyword).order_by(
'-created') '-created')
elif level == 3: elif level == 3:
if keytype == '1': if keytype == '1':
weixin = Weixin.objects.filter(organization__province=province, organization__cities=cities, weixin = Weixin.objects.filter(organization__province=province, organization__cities=cities,
organization__district=district,code__contains=keyword).order_by( organization__district=district, code__contains=keyword).order_by(
'-created') '-created')
elif keytype == '2': elif keytype == '2':
weixin = Weixin.objects.filter(organization__province=province, organization__cities=cities, weixin = Weixin.objects.filter(organization__province=province, organization__cities=cities,
organization__district=district, organization__name__contains=keyword).order_by( organization__district=district,
organization__name__contains=keyword).order_by(
'-created') '-created')
elif level == 9: elif level == 9:
if keytype == '1': if keytype == '1':
@ -707,7 +731,10 @@ def weixin_search_by_keyword(request):
o['administrativedivision'] = str(Area_code_2020.objects.get(code=w.organization.province).name) o['administrativedivision'] = str(Area_code_2020.objects.get(code=w.organization.province).name)
o['status'] = w.status o['status'] = w.status
res.append(o) res.append(o)
return render(request, 'management/newmedia-management-edit-weixin.html', {'weixin': weixin, 'res': res,'weixin_count':weixin_count}) return render(request, 'management/newmedia-management-edit-weixin.html',
{'weixin': weixin, 'res': res, 'weixin_count': weixin_count})
@login_required @login_required
def weibo_search_by_keyword(request): def weibo_search_by_keyword(request):
keytype = request.POST.get('keytype') keytype = request.POST.get('keytype')
@ -722,21 +749,25 @@ def weibo_search_by_keyword(request):
res = [] res = []
if level == 1: if level == 1:
if keytype == '1': if keytype == '1':
weibo = Weibo.objects.filter(organization__province=province,code__contains=keyword).order_by('-created') weibo = Weibo.objects.filter(organization__province=province, code__contains=keyword).order_by('-created')
elif keytype == '2': elif keytype == '2':
weibo = Weibo.objects.filter(organization__province=province, organization__name__contains=keyword).order_by('-created') weibo = Weibo.objects.filter(organization__province=province,
organization__name__contains=keyword).order_by('-created')
elif level == 2: elif level == 2:
if keytype == '1': if keytype == '1':
weibo = Weibo.objects.filter(organization__province=province, organization__cities=cities,code__contains=keyword).order_by('-created') weibo = Weibo.objects.filter(organization__province=province, organization__cities=cities,
code__contains=keyword).order_by('-created')
elif keytype == '2': elif keytype == '2':
weibo = Weibo.objects.filter(organization__province=province, organization__cities=cities,organization__name__contains=keyword).order_by('-created') weibo = Weibo.objects.filter(organization__province=province, organization__cities=cities,
organization__name__contains=keyword).order_by('-created')
elif level == 3: elif level == 3:
if keytype == '1': if keytype == '1':
weibo = Weibo.objects.filter(organization__province=province, organization__cities=cities, weibo = Weibo.objects.filter(organization__province=province, organization__cities=cities,
organization__district=district,code__contains=keyword).order_by('-created') organization__district=district, code__contains=keyword).order_by('-created')
elif keytype == '2': elif keytype == '2':
weibo = Weibo.objects.filter(organization__province=province, organization__cities=cities, weibo = Weibo.objects.filter(organization__province=province, organization__cities=cities,
organization__district=district,organization__name__contains=keyword).order_by('-created') organization__district=district,
organization__name__contains=keyword).order_by('-created')
elif level == 9: elif level == 9:
if keytype == '1': if keytype == '1':
weibo = Weibo.objects.filter(code__contains=keyword).order_by('-created') weibo = Weibo.objects.filter(code__contains=keyword).order_by('-created')
@ -780,7 +811,9 @@ def weibo_search_by_keyword(request):
o['administrativedivision'] = str(Area_code_2020.objects.get(code=w.organization.province).name) o['administrativedivision'] = str(Area_code_2020.objects.get(code=w.organization.province).name)
o['status'] = w.status o['status'] = w.status
res.append(o) res.append(o)
return render(request, 'management/newmedia-management-edit-weibo.html', {'weibo': weibo, 'res': res,'weibo_count':weibo_count}) return render(request, 'management/newmedia-management-edit-weibo.html',
{'weibo': weibo, 'res': res, 'weibo_count': weibo_count})
@login_required @login_required
def toutiao_search_by_keyword(request): def toutiao_search_by_keyword(request):
@ -796,25 +829,27 @@ def toutiao_search_by_keyword(request):
res = [] res = []
if level == 1: if level == 1:
if keytype == '1': if keytype == '1':
toutiao = Toutiao.objects.filter(organization__province=province, code__contains=keyword).order_by('-created') toutiao = Toutiao.objects.filter(organization__province=province, code__contains=keyword).order_by(
'-created')
elif keytype == '2': elif keytype == '2':
toutiao = Toutiao.objects.filter(organization__province=province, toutiao = Toutiao.objects.filter(organization__province=province,
organization__name__contains=keyword).order_by('-created') organization__name__contains=keyword).order_by('-created')
elif level == 2: elif level == 2:
if keytype == '1': if keytype == '1':
toutiao = Toutiao.objects.filter(organization__province=province, organization__cities=cities, toutiao = Toutiao.objects.filter(organization__province=province, organization__cities=cities,
code__contains=keyword).order_by('-created') code__contains=keyword).order_by('-created')
elif keytype == '2': elif keytype == '2':
toutiao = Toutiao.objects.filter(organization__province=province, organization__cities=cities, toutiao = Toutiao.objects.filter(organization__province=province, organization__cities=cities,
organization__name__contains=keyword).order_by('-created') organization__name__contains=keyword).order_by('-created')
elif level == 3: elif level == 3:
if keytype == '1': if keytype == '1':
toutiao = Toutiao.objects.filter(organization__province=province, organization__cities=cities, toutiao = Toutiao.objects.filter(organization__province=province, organization__cities=cities,
organization__district=district, code__contains=keyword).order_by('-created') organization__district=district, code__contains=keyword).order_by(
'-created')
elif keytype == '2': elif keytype == '2':
toutiao = Toutiao.objects.filter(organization__province=province, organization__cities=cities, toutiao = Toutiao.objects.filter(organization__province=province, organization__cities=cities,
organization__district=district, organization__district=district,
organization__name__contains=keyword).order_by('-created') organization__name__contains=keyword).order_by('-created')
elif level == 9: elif level == 9:
if keytype == '1': if keytype == '1':
toutiao = Toutiao.objects.filter(code__contains=keyword).order_by('-created') toutiao = Toutiao.objects.filter(code__contains=keyword).order_by('-created')
@ -858,7 +893,9 @@ def toutiao_search_by_keyword(request):
o['administrativedivision'] = str(Area_code_2020.objects.get(code=w.organization.province).name) o['administrativedivision'] = str(Area_code_2020.objects.get(code=w.organization.province).name)
o['status'] = w.status o['status'] = w.status
res.append(o) res.append(o)
return render(request, 'management/newmedia-management-edit-toutiao.html', {'toutiao': toutiao, 'res': res,'toutiao_count':toutiao_count}) return render(request, 'management/newmedia-management-edit-toutiao.html',
{'toutiao': toutiao, 'res': res, 'toutiao_count': toutiao_count})
@login_required @login_required
def douyin_search_by_keyword(request): def douyin_search_by_keyword(request):
@ -877,22 +914,22 @@ def douyin_search_by_keyword(request):
douyin = Douyin.objects.filter(organization__province=province, code__contains=keyword).order_by('-created') douyin = Douyin.objects.filter(organization__province=province, code__contains=keyword).order_by('-created')
elif keytype == '2': elif keytype == '2':
douyin = Douyin.objects.filter(organization__province=province, douyin = Douyin.objects.filter(organization__province=province,
organization__name__contains=keyword).order_by('-created') organization__name__contains=keyword).order_by('-created')
elif level == 2: elif level == 2:
if keytype == '1': if keytype == '1':
douyin = Douyin.objects.filter(organization__province=province, organization__cities=cities, douyin = Douyin.objects.filter(organization__province=province, organization__cities=cities,
code__contains=keyword).order_by('-created') code__contains=keyword).order_by('-created')
elif keytype == '2': elif keytype == '2':
douyin = Douyin.objects.filter(organization__province=province, organization__cities=cities, douyin = Douyin.objects.filter(organization__province=province, organization__cities=cities,
organization__name__contains=keyword).order_by('-created') organization__name__contains=keyword).order_by('-created')
elif level == 3: elif level == 3:
if keytype == '1': if keytype == '1':
douyin = Douyin.objects.filter(organization__province=province, organization__cities=cities, douyin = Douyin.objects.filter(organization__province=province, organization__cities=cities,
organization__district=district, code__contains=keyword).order_by('-created') organization__district=district, code__contains=keyword).order_by('-created')
elif keytype == '2': elif keytype == '2':
douyin = Douyin.objects.filter(organization__province=province, organization__cities=cities, douyin = Douyin.objects.filter(organization__province=province, organization__cities=cities,
organization__district=district, organization__district=district,
organization__name__contains=keyword).order_by('-created') organization__name__contains=keyword).order_by('-created')
elif level == 9: elif level == 9:
if keytype == '1': if keytype == '1':
douyin = Douyin.objects.filter(code__contains=keyword).order_by('-created') douyin = Douyin.objects.filter(code__contains=keyword).order_by('-created')
@ -939,6 +976,7 @@ def douyin_search_by_keyword(request):
return render(request, 'management/newmedia-management-edit-douyin.html', return render(request, 'management/newmedia-management-edit-douyin.html',
{'douyin': douyin, 'res': res, 'douyin_count': douyin_count}) {'douyin': douyin, 'res': res, 'douyin_count': douyin_count})
@login_required @login_required
def qita_search_by_keyword(request): def qita_search_by_keyword(request):
keytype = request.POST.get('keytype') keytype = request.POST.get('keytype')
@ -953,22 +991,26 @@ def qita_search_by_keyword(request):
res = [] res = []
if level == 1: if level == 1:
if keytype == '1': if keytype == '1':
qita = Qita.objects.filter(organization__province=province,code__contains=keyword).order_by('-created') qita = Qita.objects.filter(organization__province=province, code__contains=keyword).order_by('-created')
elif keytype == '2': elif keytype == '2':
qita = Qita.objects.filter(organization__province=province,organization__name__contains=keyword).order_by('-created') qita = Qita.objects.filter(organization__province=province, organization__name__contains=keyword).order_by(
'-created')
elif level == 2: elif level == 2:
if keytype == '1': if keytype == '1':
qita = Qita.objects.filter(organization__province=province, organization__cities=cities,code__contains=keyword).order_by('-created') qita = Qita.objects.filter(organization__province=province, organization__cities=cities,
code__contains=keyword).order_by('-created')
elif keytype == '2': elif keytype == '2':
qita = Qita.objects.filter(organization__province=province, organization__cities=cities,organization__name__contains=keyword).order_by( qita = Qita.objects.filter(organization__province=province, organization__cities=cities,
organization__name__contains=keyword).order_by(
'-created') '-created')
elif level == 3: elif level == 3:
if keytype == '1': if keytype == '1':
qita = Qita.objects.filter(organization__province=province, organization__cities=cities, qita = Qita.objects.filter(organization__province=province, organization__cities=cities,
organization__district=district,code__contains=keyword).order_by('-created') organization__district=district, code__contains=keyword).order_by('-created')
elif keytype == '2': elif keytype == '2':
qita = Qita.objects.filter(organization__province=province, organization__cities=cities, qita = Qita.objects.filter(organization__province=province, organization__cities=cities,
organization__district=district,organization__name__contains=keyword).order_by('-created') organization__district=district, organization__name__contains=keyword).order_by(
'-created')
elif level == 9: elif level == 9:
if keytype == '1': if keytype == '1':
qita = Qita.objects.filter(code__contains=keyword).order_by('-created') qita = Qita.objects.filter(code__contains=keyword).order_by('-created')
@ -1013,7 +1055,9 @@ def qita_search_by_keyword(request):
o['administrativedivision'] = str(Area_code_2020.objects.get(code=w.organization.province).name) o['administrativedivision'] = str(Area_code_2020.objects.get(code=w.organization.province).name)
o['status'] = w.status o['status'] = w.status
res.append(o) res.append(o)
return render(request, 'management/newmedia-management-edit-qita.html', {'qita': qita, 'res': res,'qita_count':qita_count}) return render(request, 'management/newmedia-management-edit-qita.html',
{'qita': qita, 'res': res, 'qita_count': qita_count})
@login_required @login_required
def group_init_search_by_keyword(request): def group_init_search_by_keyword(request):
@ -1023,9 +1067,9 @@ def group_init_search_by_keyword(request):
user = request.user user = request.user
level = Userprofile.objects.get(user_id=user.id).organization.level.level level = Userprofile.objects.get(user_id=user.id).organization.level.level
if keytype == '1': if keytype == '1':
group_initer = Group.objects.filter(user_id=user.id,name__contains=keyword).order_by('-created') group_initer = Group.objects.filter(user_id=user.id, name__contains=keyword).order_by('-created')
elif keytype == '2': elif keytype == '2':
group_initer = Group.objects.filter(user_id=user.id,type__type__contains=keyword).order_by('-created') group_initer = Group.objects.filter(user_id=user.id, type__type__contains=keyword).order_by('-created')
print(group_initer) print(group_initer)
res_g_i = [] res_g_i = []
init_count = group_initer.count() init_count = group_initer.count()
@ -1042,6 +1086,7 @@ def group_init_search_by_keyword(request):
return render(request, 'management/group-management-init.html', return render(request, 'management/group-management-init.html',
{'group': group_initer, 'res_g_i': res_g_i, 'init_count': init_count, 'level': level}) {'group': group_initer, 'res_g_i': res_g_i, 'init_count': init_count, 'level': level})
@login_required @login_required
def group_admin_search_by_keyword(request): def group_admin_search_by_keyword(request):
keytype = request.POST.get('keytype') keytype = request.POST.get('keytype')
@ -1051,9 +1096,9 @@ def group_admin_search_by_keyword(request):
group_admin_list = [] group_admin_list = []
g = None g = None
if keytype == '1': if keytype == '1':
g = Group_admin.objects.filter(user_id=user.id,group__name__contains=keyword).order_by('-created') g = Group_admin.objects.filter(user_id=user.id, group__name__contains=keyword).order_by('-created')
elif keytype == '2': elif keytype == '2':
g = Group_admin.objects.filter(user_id=user.id,group__type__type__contains=keyword).order_by('-created') g = Group_admin.objects.filter(user_id=user.id, group__type__type__contains=keyword).order_by('-created')
for g_a in g: for g_a in g:
group_admin = Group.objects.get(id=g_a.group_id) group_admin = Group.objects.get(id=g_a.group_id)
group_admin_list.append(group_admin) group_admin_list.append(group_admin)
@ -1072,6 +1117,7 @@ def group_admin_search_by_keyword(request):
return render(request, 'management/group-management-admin.html', return render(request, 'management/group-management-admin.html',
{'group': group_admin_list, 'res_g_a': res_g_a, 'admin_count': admin_count, 'level': level}) {'group': group_admin_list, 'res_g_a': res_g_a, 'admin_count': admin_count, 'level': level})
@login_required @login_required
def group_user_search_by_keyword(request): def group_user_search_by_keyword(request):
keytype = request.POST.get('keytype') keytype = request.POST.get('keytype')
@ -1080,9 +1126,9 @@ def group_user_search_by_keyword(request):
level = Userprofile.objects.get(user_id=user.id).organization.level.level level = Userprofile.objects.get(user_id=user.id).organization.level.level
group_user_list = [] group_user_list = []
if keytype == '1': if keytype == '1':
g = Group_user.objects.filter(user_id=user.id,group__name__contains=keyword).order_by('-created') g = Group_user.objects.filter(user_id=user.id, group__name__contains=keyword).order_by('-created')
elif keytype == '2': elif keytype == '2':
g = Group_user.objects.filter(user_id=user.id,group__type__type__contains=keyword).order_by('-created') g = Group_user.objects.filter(user_id=user.id, group__type__type__contains=keyword).order_by('-created')
for g_u in g: for g_u in g:
group_user = Group.objects.get(id=g_u.group_id) group_user = Group.objects.get(id=g_u.group_id)
group_user_list.append(group_user) group_user_list.append(group_user)
@ -1101,6 +1147,7 @@ def group_user_search_by_keyword(request):
return render(request, 'management/group-management-user.html', return render(request, 'management/group-management-user.html',
{'group': group_user_list, 'res_g_u': res_g_u, 'user_count': user_count, 'level': level}) {'group': group_user_list, 'res_g_u': res_g_u, 'user_count': user_count, 'level': level})
@login_required @login_required
def group_super_search_by_keyword(request): def group_super_search_by_keyword(request):
keytype = request.POST.get('keytype') keytype = request.POST.get('keytype')
@ -1127,9 +1174,10 @@ def group_super_search_by_keyword(request):
return render(request, 'management/group-management-superuser.html', return render(request, 'management/group-management-superuser.html',
{'group': group, 'res_g_i': res_g_i, 'count': count, 'level': level}) {'group': group, 'res_g_i': res_g_i, 'count': count, 'level': level})
def app_download(request): def app_download(request):
file = open('/var/www/p3/newmediamonitoring/media/app-10.apk', 'rb') file = open('/var/www/p3/newmediamonitoring/media/app-10.apk', 'rb')
response = HttpResponse(file) response = HttpResponse(file)
response['Content-Type'] = 'application/octet-stream' response['Content-Type'] = 'application/octet-stream'
response['Content-Disposition'] = 'attachment;filename="app.apk"' response['Content-Disposition'] = 'attachment;filename="app.apk"'
return response return response

View File

@ -113,9 +113,9 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="metadata-pagination"> {# <div class="metadata-pagination">#}
{% include 'dashboard/paginator/group-management-paginate.html' %} {# {% include 'dashboard/paginator/group-management-paginate.html' %}#}
</div> {# </div>#}
</div> </div>
</div> </div>
</div> </div>

View File

@ -113,9 +113,9 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="metadata-pagination"> {# <div class="metadata-pagination">#}
{% include 'dashboard/paginator/group-management-paginate.html' %} {# {% include 'dashboard/paginator/group-management-paginate.html' %}#}
</div> {# </div>#}
</div> </div>
</div> </div>
</div> </div>

View File

@ -113,9 +113,9 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="metadata-pagination"> {# <div class="metadata-pagination">#}
{% include 'dashboard/paginator/group-management-paginate.html' %} {# {% include 'dashboard/paginator/group-management-paginate.html' %}#}
</div> {# </div>#}
</div> </div>
</div> </div>
</div> </div>

View File

@ -106,9 +106,9 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="metadata-pagination"> {# <div class="metadata-pagination">#}
{% include 'dashboard/paginator/group-management-paginate.html' %} {# {% include 'dashboard/paginator/group-management-paginate.html' %}#}
</div> {# </div>#}
</div> </div>
</div> </div>
</div> </div>

View File

@ -82,9 +82,9 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="metadata-pagination"> {# <div class="metadata-pagination">#}
{% include 'dashboard/paginator/douyin-management-paginate.html' %} {# {% include 'dashboard/paginator/douyin-management-paginate.html' %}#}
</div> {# </div>#}
</div> </div>
</div> </div>
</div> </div>

View File

@ -85,9 +85,9 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="metadata-pagination"> {# <div class="metadata-pagination">#}
{% include 'dashboard/paginator/qita-management-paginate.html' %} {# {% include 'dashboard/paginator/qita-management-paginate.html' %}#}
</div> {# </div>#}
</div> </div>
</div> </div>
</div> </div>

View File

@ -82,9 +82,9 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="metadata-pagination"> {# <div class="metadata-pagination">#}
{% include 'dashboard/paginator/toutiao-management-paginate.html' %} {# {% include 'dashboard/paginator/toutiao-management-paginate.html' %}#}
</div> {# </div>#}
</div> </div>
</div> </div>
</div> </div>

View File

@ -83,9 +83,9 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="metadata-pagination"> {# <div class="metadata-pagination">#}
{% include 'dashboard/paginator/weibo-management-paginate.html' %} {# {% include 'dashboard/paginator/weibo-management-paginate.html' %}#}
</div> {# </div>#}
</div> </div>
</div> </div>
</div> </div>

View File

@ -82,9 +82,9 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="metadata-pagination"> {# <div class="metadata-pagination">#}
{% include 'dashboard/paginator/weixin-management-paginate.html' %} {# {% include 'dashboard/paginator/weixin-management-paginate.html' %}#}
</div> {# </div>#}
</div> </div>
</div> </div>
</div> </div>

View File

@ -45,6 +45,7 @@
<form method="post" action="{% url 'news-search-by-keyword' %}">{% csrf_token %} <form method="post" action="{% url 'news-search-by-keyword' %}">{% csrf_token %}
<div class="btn-group col-md-2 title" style="display: inline-block;margin-left: 5%"> <div class="btn-group col-md-2 title" style="display: inline-block;margin-left: 5%">
<select class="form-control" name="keytype"> <select class="form-control" name="keytype">
<option value="0">全部</option>
<option value="1">政策依据</option> <option value="1">政策依据</option>
<option value="2">基层动态</option> <option value="2">基层动态</option>
<option value="3">外省动态</option> <option value="3">外省动态</option>
@ -106,9 +107,9 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="metadata-pagination"> {# <div class="metadata-pagination">#}
{% include 'dashboard/paginator/news-management-paginate.html' %} {# {% include 'dashboard/paginator/news-management-paginate.html' %}#}
</div> {# </div>#}
</div> </div>
</div> </div>
</div> </div>

View File

@ -105,9 +105,9 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="metadata-pagination"> {# <div class="metadata-pagination">#}
{% include 'dashboard/paginator/organization-management-paginate.html' %} {# {% include 'dashboard/paginator/organization-management-paginate.html' %}#}
</div> {# </div>#}
</div> </div>
</div> </div>
</div> </div>

View File

@ -78,9 +78,9 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<div class="metadata-pagination"> {# <div class="metadata-pagination">#}
{% include 'dashboard/paginator/user-management-paginate.html' %} {# {% include 'dashboard/paginator/user-management-paginate.html' %}#}
</div> {# </div>#}
</div> </div>
</div> </div>
</div> </div>

View File

@ -35,23 +35,30 @@
<table class="table table-hover" style="font-size: 14px"> <table class="table table-hover" style="font-size: 14px">
<thead> <thead>
<tr> <tr>
<th style="text-align: center">新媒体类型</th> <th style="text-align: center">评论</th>
<th style="text-align: center">账号名</th> {# <th style="text-align: center">回复</th>#}
<th style="text-align: center">账号</th>
<th style="text-align: center">标题</th> <th style="text-align: center">标题</th>
<th style="text-align: center">时间</th> <th style="text-align: center">时间</th>
<th style="text-align: center">评论数</th> <th style="text-align: center">文章链接</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for c in comment %}
<tr> <tr>
<td style="vertical-align: middle;text-align: center">{{ r.date }}</td> <td style="vertical-align: middle;text-align: center">{{ c.comment }}</td>
<td style="vertical-align: middle;text-align: center">{{ r.date }}</td> {# <td style="vertical-align: middle;text-align: center">{{ c.reply }}</td>#}
<td style="vertical-align: middle;text-align: center">{{ r.date }}</td> <td style="vertical-align: middle;text-align: center">{{ c.name }}</td>
<td style="vertical-align: middle;text-align: center">{{ r.date }}</td> <td style="vertical-align: middle;text-align: center">{{ c.title }}</td>
<td style="vertical-align: middle;text-align: center">{{ r.date }}</td> <td style="vertical-align: middle;text-align: center">{{ c.date }}</td>
<td style="vertical-align: middle;text-align: center">{{ c.url }}</td>
</tr> </tr>
{% endfor %}
</tbody> </tbody>
</table> </table>
<div class="metadata-pagination">
{% include 'dashboard/paginator/comment-management-paginate.html' %}
</div>
</div> </div>
</div> </div>
@ -65,35 +72,35 @@
</div> </div>
</div> </div>
{# <div class="panel-body">#} {# <div class="panel-body">#}
{# <div class="panel panel-default">#} {# <div class="panel panel-default">#}
{# <div class="panel-heading">热点评论</div>#} {# <div class="panel-heading">热点评论</div>#}
{# <div class="panel panel-default">#} {# <div class="panel panel-default">#}
{# <!-- Default panel contents -->#} {# <!-- Default panel contents -->#}
{# <table class="table table-hover" style="font-size: 14px">#} {# <table class="table table-hover" style="font-size: 14px">#}
{# <thead>#} {# <thead>#}
{# <tr>#} {# <tr>#}
{# <th style="text-align: center">新媒体类型</th>#} {# <th style="text-align: center">新媒体类型</th>#}
{# <th style="text-align: center">账号名</th>#} {# <th style="text-align: center">账号名</th>#}
{# <th style="text-align: center">评论内容</th>#} {# <th style="text-align: center">评论内容</th>#}
{# <th style="text-align: center">时间</th>#} {# <th style="text-align: center">时间</th>#}
{# <th style="text-align: center">跟评数</th>#} {# <th style="text-align: center">跟评数</th>#}
{# </tr>#} {# </tr>#}
{# </thead>#} {# </thead>#}
{# <tbody>#} {# <tbody>#}
{# <tr>#} {# <tr>#}
{# <td style="vertical-align: middle;text-align: center">{{ r.date }}</td>#} {# <td style="vertical-align: middle;text-align: center">{{ r.date }}</td>#}
{# <td style="vertical-align: middle;text-align: center">{{ r.date }}</td>#} {# <td style="vertical-align: middle;text-align: center">{{ r.date }}</td>#}
{# <td style="vertical-align: middle;text-align: center">{{ r.date }}</td>#} {# <td style="vertical-align: middle;text-align: center">{{ r.date }}</td>#}
{# <td style="vertical-align: middle;text-align: center">{{ r.date }}</td>#} {# <td style="vertical-align: middle;text-align: center">{{ r.date }}</td>#}
{# <td style="vertical-align: middle;text-align: center">{{ r.date }}</td>#} {# <td style="vertical-align: middle;text-align: center">{{ r.date }}</td>#}
{# </tr>#} {# </tr>#}
{# </tbody>#} {# </tbody>#}
{# </table>#} {# </table>#}
{# </div>#} {# </div>#}
{##} {##}
{# </div>#} {# </div>#}
{# </div>#} {# </div>#}
</div> </div>
</section> </section>

View File

@ -127,12 +127,12 @@
legend: { legend: {
orient: 'vertical', orient: 'vertical',
left: 10, left: 10,
data: ['预警数'] data: ['预警账号数']
}, },
color: ['orange'], color: ['orange'],
series: [ series: [
{ {
name: '预警数', name: '预警账号数',
type: 'pie', type: 'pie',
radius: ['60%', '70%'], radius: ['60%', '70%'],
avoidLabelOverlap: false, avoidLabelOverlap: false,
@ -151,7 +151,7 @@
show: false show: false
}, },
data: [ data: [
{value: 1, name: '预警数6'}, {value: 1, name: '预警账号数6'},
] ]
} }
] ]

View File

@ -14,7 +14,7 @@ from datetime import timedelta
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
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, News, TimelinessMonitoring, Organization, Wrongly, NewMedia Douyin, Douyin_data, News, TimelinessMonitoring, Organization, Wrongly, NewMedia, Comment
from monitor.models import Test from monitor.models import Test
import pandas as pd import pandas as pd
@ -519,14 +519,23 @@ def sensitive_word_monitoring(request):
@login_required @login_required
def comment_on_interactive_monitoring(request): def comment_on_interactive_monitoring(request):
return render(request, 'monitor/comment-on-interactive-monitoring.html') comment = Comment.objects.all().order_by('-date')
paginator = Paginator(comment, 8)
page = int(request.GET.get('page', 1))
try:
comment = paginator.page(page)
except PageNotAnInteger:
comment = paginator.page(1)
except EmptyPage:
comment = paginator.page(paginator.num_pages)
return render(request, 'monitor/comment-on-interactive-monitoring.html',{"comment":comment})
@login_required @login_required
def comment_on_interactive_monitoring_json(request): def comment_on_interactive_monitoring_json(request):
data = Test.objects.all()[:100] data = Comment.objects.all()
r = [] r = []
for d in data: for d in data:
content = d.content content = d.comment
r.append(content) r.append(content)
# result = jieba.analyse.textrank(content, topK=400, withWeight=True) # result = jieba.analyse.textrank(content, topK=400, withWeight=True)
seg_list = jieba.cut(str(r)) # 对文本进行分词 seg_list = jieba.cut(str(r)) # 对文本进行分词
@ -535,7 +544,7 @@ def comment_on_interactive_monitoring_json(request):
if len(x) > 1 and x != '\r\n': if len(x) > 1 and x != '\r\n':
c[x] += 1 c[x] += 1
res = [] res = []
for (k, v) in c.most_common(200): # 遍历输出高频词 for (k, v) in c.most_common(250): # 遍历输出高频词
# print('%s%s %s %d' % (' ' * (5 - len(k)), k, '*', v)) # print('%s%s %s %d' % (' ' * (5 - len(k)), k, '*', v))
# 剔除不是汉字的值 # 剔除不是汉字的值
if all(map(lambda c: '\u4e00' <= c <= '\u9fa5', k)): if all(map(lambda c: '\u4e00' <= c <= '\u9fa5', k)):
@ -1160,6 +1169,13 @@ def index_warning_count(request):
news = News.objects.filter(type='3',date=d).count() news = News.objects.filter(type='3',date=d).count()
data.append(news) data.append(news)
print(str(data)+"6666666666666666666666666666666") print(str(data)+"6666666666666666666666666666666")
# date = News.objects.distinct('date')
# data = []
# date_list = []
# for d in date:
# date_list.append(d.date)
# news = News.objects.filter(type='3', date=d).count()
# data.append(news)
return HttpResponse(json.dumps({ return HttpResponse(json.dumps({
"status":"1", "status":"1",
"data":data, "data":data,