This commit is contained in:
Bob 2020-10-27 21:38:02 +08:00
parent e244074b81
commit eedf3e06bd
5 changed files with 290 additions and 126 deletions

View File

@ -101,7 +101,6 @@ class Group_user(models.Model):
# 单位类型 # 单位类型
class Organizationtype(models.Model): class Organizationtype(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
organizationtype = models.CharField( organizationtype = models.CharField(

View File

@ -30,7 +30,10 @@ urlpatterns = [
path('user/search/by/keyword/',views.user_search_by_keyword,name='user-search-by-keyword'), path('user/search/by/keyword/',views.user_search_by_keyword,name='user-search-by-keyword'),
#新闻搜索 #新闻搜索
path('news/search/by/keyword/',views.news_search_by_keyword,name='news-search-by-keyword'), path('news/search/by/keyword/',views.news_search_by_keyword,name='news-search-by-keyword'),
#单位搜索
path('organization/search/by/keyword',views.organization_search_by_keyword,name='organization-search-by-keyword'),
#微信搜索
path('weixin/search/by/keyword',views.weixin_search_by_keyword,name='weixin-search-by-keyword'),
#导入用户数据用的 #导入用户数据用的
path('import/user',views.import_user) path('import/user',views.import_user)

View File

@ -435,30 +435,30 @@ def user_search_by_keyword(request):
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)[:30] 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)[:30] 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__province=province,
userprofile__organization__cities=cities)[:30] 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__province=province,
userprofile__organization__cities=cities)[:30] 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__province=province,
userprofile__organization__cities=cities, userprofile__organization__cities=cities,
userprofile__organization__district=district)[:30] 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__province=province,
userprofile__organization__cities=cities, userprofile__organization__cities=cities,
userprofile__organization__district=district)[:30] userprofile__organization__district=district)
elif level == 9: elif level == 9:
if keytype == '1': if keytype == '1':
userpaginator = Userprofile.objects.filter(name__contains=keyword)[:30] userpaginator = Userprofile.objects.filter(name__contains=keyword)
elif keytype == '2': elif keytype == '2':
userpaginator = Userprofile.objects.filter(organization__name__contains=keyword)[:30] userpaginator = Userprofile.objects.filter(organization__name__contains=keyword)
# paginator = Paginator(userpaginator, 6) # paginator = Paginator(userpaginator, 6)
# page = int(request.GET.get('page', 1)) # page = int(request.GET.get('page', 1))
@ -468,8 +468,9 @@ 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()
userallinfo = [] userallinfo = []
for u in userpaginator: for u in userpaginator[:30]:
o = dict() o = dict()
o['id'] = str(u.id) o['id'] = str(u.id)
if u.image: if u.image:
@ -519,7 +520,7 @@ 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}) {'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,22 +529,22 @@ 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)[:30] news = News.objects.filter(type='0',title__contains=keyword)
elif keytype == '2': elif keytype == '2':
news = News.objects.filter(type='1',title__contains=keyword)[:30] news = News.objects.filter(type='1',title__contains=keyword)
elif keytype == '3': elif keytype == '3':
news = News.objects.filter(type='2',title__contains=keyword)[:30] news = News.objects.filter(type='2',title__contains=keyword)
elif keytype == '4': elif keytype == '4':
news = News.objects.filter(type='3',title__contains=keyword)[:30] news = News.objects.filter(type='3',title__contains=keyword)
elif keytype == '5': elif keytype == '5':
news = News.objects.filter(type='4',title__contains=keyword)[:30] news = News.objects.filter(type='4',title__contains=keyword)
elif keytype == '6': elif keytype == '6':
news = News.objects.filter(type='5',title__contains=keyword)[:30] news = News.objects.filter(type='5',title__contains=keyword)
elif keytype == '7': elif keytype == '7':
news = News.objects.filter(type='6',title__contains=keyword)[:30] news = News.objects.filter(type='6',title__contains=keyword)
news_list = [] news_list = []
news_count = news.count() news_count = news.count()
for n in news: for n in news[:30]:
o = dict() o = dict()
o['id'] = str(n.id) o['id'] = str(n.id)
o['title'] = n.title o['title'] = n.title
@ -571,3 +572,164 @@ def news_search_by_keyword(request):
def organization_search_by_keyword(request): def organization_search_by_keyword(request):
keytype = request.POST.get('keytype') keytype = request.POST.get('keytype')
keyword = request.POST.get('keyword') keyword = request.POST.get('keyword')
user = request.user
o = Organization.objects.get(userprofile__user_id=user.id)
print(o)
level = o.level.level
province = o.province
cities = o.cities
district = o.district
print(level, province, cities, district)
organization = None
res = []
if level == 1:
if keytype == '1':
organization = Organization.objects.filter(province=province,name__contains=keyword).order_by('-created')
elif level == 2:
if keytype == '1':
organization = Organization.objects.filter(province=province, cities=cities,name__contains=keyword).order_by('-created')
elif level == 3:
if keytype == '1':
organization = Organization.objects.filter(province=province, cities=cities, district=district,name__contains=keyword).order_by(
'-created')
elif level == 9:
if keytype == '1':
organization = Organization.objects.filter(name__contains=keyword).order_by('-created')
organization_count = organization.count()
for i in organization[:30]:
print(i)
o = dict()
o['id'] = str(i.id)
o['name'] = i.name
o['image'] = i.image.url
if i.province and i.cities and i.district and i.town and i.village:
o['administrativedivision'] = str(Area_code_2020.objects.get(code=i.province).name) + '-' + str(
Area_code_2020.objects.get(code=i.cities).name) + '-' + str(
Area_code_2020.objects.get(code=i.district).name) + '-' + str(
Area_code_2020.objects.get(code=i.town).name) + '-' + str(
Area_code_2020.objects.get(code=i.village).name)
elif i.province and i.cities and i.district and i.town:
o['administrativedivision'] = str(Area_code_2020.objects.get(code=i.province).name) + '-' + str(
Area_code_2020.objects.get(code=i.cities).name) + '-' + str(
Area_code_2020.objects.get(code=i.district).name) + '-' + str(
Area_code_2020.objects.get(code=i.town).name)
elif i.province and i.cities and i.district:
o['administrativedivision'] = str(Area_code_2020.objects.get(code=i.province).name) + '-' + str(
Area_code_2020.objects.get(code=i.cities).name) + '-' + str(
Area_code_2020.objects.get(code=i.district).name)
elif i.province and i.cities:
o['administrativedivision'] = str(Area_code_2020.objects.get(code=i.province).name) + '-' + str(
Area_code_2020.objects.get(code=i.cities).name)
elif i.province:
o['administrativedivision'] = str(Area_code_2020.objects.get(code=i.province).name)
o['usercount'] = Userprofile.objects.filter(organization_id=i.id).count()
o['mediacount'] = Weixin.objects.filter(organization_id=i.id).count() + Weibo.objects.filter(
organization_id=i.id).count() + Toutiao.objects.filter(
organization_id=i.id).count() + Qita.objects.filter(
organization_id=i.id).count()
res.append(o)
return render(request, 'management/organization-management.html', {"organization": organization, 'res': res,'organization_count':organization_count})
@login_required
def weixin_search_by_keyword(request):
keytype = request.POST.get('keytype')
keyword = request.POST.get('keyword')
user = request.user
o = Organization.objects.get(userprofile__user_id=user.id)
level = o.level.level
province = o.province
cities = o.cities
district = o.district
weixin = None
res = []
if level == 1:
if keytype == '1':
weixin = Weixin.objects.filter(organization__province=province,code__contains=keyword).order_by('-created')
elif keytype == '2':
weixin = Weixin.objects.filter(organization__province=province, organization__name__contains=keyword).order_by('-created')
elif level == 2:
if keytype == '1':
weixin = Weixin.objects.filter(organization__province=province, organization__cities=cities,code__contains=keyword).order_by(
'-created')
elif keytype == '2':
weixin = Weixin.objects.filter(organization__province=province, organization__cities=cities, organization__name__contains=keyword).order_by(
'-created')
elif level == 3:
if keytype == '1':
weixin = Weixin.objects.filter(organization__province=province, organization__cities=cities,
organization__district=district,code__contains=keyword).order_by(
'-created')
elif keytype == '2':
weixin = Weixin.objects.filter(organization__province=province, organization__cities=cities,
organization__district=district, organization__name__contains=keyword).order_by(
'-created')
elif level == 9:
if keytype == '1':
weixin = Weixin.objects.filter(code__contains=keyword).order_by('-created')
elif keytype == '2':
weixin = Weixin.objects.filter(organization__name__contains=keyword).order_by('-created')
weixin_count = weixin.count()
for w in weixin[:30]:
o = dict()
o['id'] = str(w.id)
if w.image:
o['image'] = w.image
o['code'] = w.code
o['weixinid'] = w.weixinid
o['organization'] = w.organization.name
# o['organization_type'] = w.organization.organizationtype.organizationtype
if len(w.organization.province) > 0 and len(w.organization.cities) > 0 and len(
w.organization.district) > 0 and len(w.organization.town) > 0 and len(w.organization.village) > 0:
o['administrativedivision'] = str(
Area_code_2020.objects.get(code=w.organization.province).name) + '-' + str(
Area_code_2020.objects.get(code=w.organization.cities).name) + '-' + str(
Area_code_2020.objects.get(code=w.organization.district).name) + '-' + str(
Area_code_2020.objects.get(code=w.organization.town).name) + '-' + str(
Area_code_2020.objects.get(code=w.organization.village).name)
elif len(w.organization.province) > 0 and len(w.organization.cities) > 0 and len(
w.organization.district) > 0 and len(w.organization.town) > 0:
o['administrativedivision'] = str(
Area_code_2020.objects.get(code=w.organization.province).name) + '-' + str(
Area_code_2020.objects.get(code=w.organization.cities).name) + '-' + str(
Area_code_2020.objects.get(code=w.organization.district).name) + '-' + str(
Area_code_2020.objects.get(code=w.organization.town).name)
elif len(w.organization.province) > 0 and len(w.organization.cities) > 0 and len(
w.organization.district) > 0:
o['administrativedivision'] = str(
Area_code_2020.objects.get(code=w.organization.province).name) + '-' + str(
Area_code_2020.objects.get(code=w.organization.cities).name) + '-' + str(
Area_code_2020.objects.get(code=w.organization.district).name)
elif len(w.organization.province) > 0 and len(w.organization.cities) > 0:
o['administrativedivision'] = str(
Area_code_2020.objects.get(code=w.organization.province).name) + '-' + str(
Area_code_2020.objects.get(code=w.organization.cities).name)
elif len(w.organization.province) > 0:
o['administrativedivision'] = str(Area_code_2020.objects.get(code=w.organization.province).name)
o['status'] = w.status
res.append(o)
return render(request, 'management/newmedia-management-edit-weixin.html', {'weixin': weixin, 'res': res,'weixin_count':weixin_count})
@login_required
def weibo_search_by_keyword(request):
keytype = request.POST.get('keytype')
keyword = request.POST.get('keyword')
user = request.user
o = Organization.objects.get(userprofile__user_id=user.id)
level = o.level.level
province = o.province
cities = o.cities
district = o.district
weibo = None
res = []
if level == 1:
if keytype == '1':
weibo = Weibo.objects.filter(organization__province=province,code__contains=keyword).order_by('-created')
elif keytype == '2':
weibo = Weibo.objects.filter(organization__province=province, organization__name__contains=keyword).order_by('-created')
elif level == 2:
weibo = Weibo.objects.filter(organization__province=province, organization__cities=cities).order_by('-created')
elif level == 3:
weibo = Weibo.objects.filter(organization__province=province, organization__cities=cities,
organization__district=district).order_by('-created')
elif level == 9:
weibo = Weibo.objects.all().order_by('-created')

View File

@ -1,103 +1,103 @@
{% extends 'dashboard/base/base.html' %} {% extends 'dashboard/base/base.html' %}
{% load static %} {% load static %}
{% block css %} {% block css %}
<link href="{% static 'management/css/uikit.min.css' %}" rel="stylesheet" type="text/css" media="screen"/> <link href="{% static 'management/css/uikit.min.css' %}" rel="stylesheet" type="text/css" media="screen"/>
<link href="{% static 'management/css/nestable.min.css' %}" rel="stylesheet" type="text/css" media="screen"/> <link href="{% static 'management/css/nestable.min.css' %}" rel="stylesheet" type="text/css" media="screen"/>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<body class=" "> <body class=" ">
<div class="page-container row-fluid"> <div class="page-container row-fluid">
<div class="page-sidebar "> <div class="page-sidebar ">
{% include 'dashboard/base/left.html' %} {% include 'dashboard/base/left.html' %}
</div> </div>
<section id="main-content" class=" "> <section id="main-content" class=" ">
<section class="wrapper" style='margin-top:60px;display:inline-block;width:100%;padding:15px 0 0 15px;'> <section class="wrapper" style='margin-top:60px;display:inline-block;width:100%;padding:15px 0 0 15px;'>
<div class='col-lg-12 col-md-12 col-sm-12 col-xs-12'> <div class='col-lg-12 col-md-12 col-sm-12 col-xs-12'>
<div class="page-title"> <div class="page-title">
<div class="pull-left"> <div class="pull-left">
<h1 class="title">新媒体编辑</h1></div> <h1 class="title">新媒体编辑</h1></div>
</div> </div>
</div> </div>
<div class="clearfix"></div> <div class="clearfix"></div>
<div class="col-lg-12"> <div class="col-lg-12">
<section class="box "> <section class="box ">
<header class="panel_header"> <header class="panel_header">
<h2 class="title pull-left">微信公众号列表</h2> <h2 class="title pull-left">微信公众号列表</h2>
<form> <form method="post" action="{% url 'weixin-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="1">新媒体名称</option> <option value="1">新媒体名称</option>
<option value="2">责任主体</option> <option value="2">责任主体</option>
<option value="3">行政区划</option> {# <option value="3">行政区划</option>#}
</select> </select>
</div> </div>
<div class="col-lg-6 title"> <div class="col-lg-6 title">
<div class="input-group"> <div class="input-group">
<input type="text" class="form-control" placeholder="输入搜索关键字" name="keyword"> <input type="text" class="form-control" placeholder="输入搜索关键字" name="keyword">
<span class="input-group-btn"> <span class="input-group-btn">
<button class="btn btn-default" type="button">搜索</button> <button class="btn btn-default" type="submit">搜索</button>
</span> </span>
</div> </div>
</div> </div>
</form> </form>
<h2 class="title pull-right" style="margin-right: 30px">微信总计:{{ weixin_count }}</h2> <h2 class="title pull-right" style="margin-right: 30px">微信总计:{{ weixin_count }}</h2>
</header> </header>
<div class="content-body"> <div class="content-body">
<div class="row"> <div class="row">
<div class="col-md-12 col-sm-12 col-xs-12"> <div class="col-md-12 col-sm-12 col-xs-12">
<table class="table table-hover"> <table class="table table-hover">
<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">新媒体ID</th> <th style="text-align: center">新媒体ID</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 w in res %} {% for w in res %}
<tr> <tr>
<td style="vertical-align: middle;text-align: center">{{ forloop.counter }}</td> <td style="vertical-align: middle;text-align: center">{{ forloop.counter }}</td>
<td style="text-align: center"><img src="{{ w.image.url }}" <td style="text-align: center"><img src="{{ w.image.url }}"
style="width: 60px;height: 60px;margin: auto" style="width: 60px;height: 60px;margin: auto"
class="img-circle"></td> class="img-circle"></td>
<td style="vertical-align: middle;text-align: center">{{ w.code }}</td> <td style="vertical-align: middle;text-align: center">{{ w.code }}</td>
<td style="vertical-align: middle;text-align: center">{{ w.weixinid }}</td> <td style="vertical-align: middle;text-align: center">{{ w.weixinid }}</td>
<td style="vertical-align: middle;text-align: center">{{ w.organization }}</td> <td style="vertical-align: middle;text-align: center">{{ w.organization }}</td>
<td style="vertical-align: middle;text-align: center">{{ w.administrativedivision }}</td> <td style="vertical-align: middle;text-align: center">{{ w.administrativedivision }}</td>
<td style="vertical-align: middle;text-align: center">{{ w.status }}</td> <td style="vertical-align: middle;text-align: center">{{ w.status }}</td>
<td style="vertical-align: middle;text-align: center"> <td style="vertical-align: middle;text-align: center">
<a href="{% url 'newmedia-management-update-weixin' w.id %}" <a href="{% url 'newmedia-management-update-weixin' w.id %}"
class="btn btn-primary btn-mini">编辑</a> class="btn btn-primary btn-mini">编辑</a>
<a href="{% url 'newmedia-management-delete-weixin' w.id %}" <a href="{% url 'newmedia-management-delete-weixin' w.id %}"
class="btn btn-danger btn-mini">删除</a> class="btn btn-danger btn-mini">删除</a>
</td> </td>
</tr> </tr>
{% 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>
</section> </section>
</div> </div>
</section> </section>
</section> </section>
<div class="chatapi-windows "> <div class="chatapi-windows ">
</div> </div>
</div> </div>
</body> </body>
{% endblock %} {% endblock %}
{% block add_js %} {% block add_js %}
<script src="{% static 'management/js/uikit.min.js' %}" type="text/javascript"></script> <script src="{% static 'management/js/uikit.min.js' %}" type="text/javascript"></script>
<script src="{% static 'management/js/nestable.min.js' %}" type="text/javascript"></script> <script src="{% static 'management/js/nestable.min.js' %}" type="text/javascript"></script>
<script> <script>
</script> </script>
{% endblock %} {% endblock %}

View File

@ -42,18 +42,18 @@
<section class="box "> <section class="box ">
<header class="panel_header"> <header class="panel_header">
<h2 class="title pull-left">单位列表</h2> <h2 class="title pull-left">单位列表</h2>
<form> <form action="{% url 'organization-search-by-keyword' %}" method="post">{% 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="1">单位名称</option> <option value="1">单位名称</option>
<option value="2">行政区划</option> {# <option value="2">行政区划</option>#}
</select> </select>
</div> </div>
<div class="col-lg-6 title"> <div class="col-lg-6 title">
<div class="input-group"> <div class="input-group">
<input type="text" class="form-control" placeholder="输入搜索关键字" name="keyword"> <input type="text" class="form-control" placeholder="输入搜索关键字" name="keyword">
<span class="input-group-btn"> <span class="input-group-btn">
<button class="btn btn-default" type="button">搜索</button> <button class="btn btn-default" type="submit">搜索</button>
</span> </span>
</div> </div>
</div> </div>