Merge branch 'master' of http://git.eanbo.cn/xieshen/newmediamonitoring
This commit is contained in:
commit
6ee8a2f1f8
|
@ -112,7 +112,6 @@ class Organizationtype(models.Model):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.organizationtype
|
return self.organizationtype
|
||||||
|
|
||||||
|
|
||||||
# 单位
|
# 单位
|
||||||
class Organization(models.Model):
|
class Organization(models.Model):
|
||||||
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
|
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
|
||||||
|
|
|
@ -25,6 +25,13 @@ urlpatterns = [
|
||||||
#单位搜索
|
#单位搜索
|
||||||
path('get/organization/',views.get_organization,name='get-organization'),
|
path('get/organization/',views.get_organization,name='get-organization'),
|
||||||
path('tencent13722515905013783955.txt', views.wechat_verify, name='wechat-verify'),
|
path('tencent13722515905013783955.txt', views.wechat_verify, name='wechat-verify'),
|
||||||
|
|
||||||
|
#用户搜索
|
||||||
|
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('import/user',views.import_user)
|
path('import/user',views.import_user)
|
||||||
|
|
||||||
|
|
|
@ -423,24 +423,151 @@ def import_user(request):
|
||||||
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
|
||||||
|
o = Organization.objects.get(userprofile__user_id=user.id)
|
||||||
|
level = o.level.level
|
||||||
|
province = o.province
|
||||||
|
cities = o.cities
|
||||||
|
district = o.district
|
||||||
keytype = request.POST.get('keytype')
|
keytype = request.POST.get('keytype')
|
||||||
keyword = request.POST.get('ketword')
|
keyword = request.POST.get('ketword')
|
||||||
userprofile = None
|
print(keytype,keyword)
|
||||||
if keytype == '1':
|
userpaginator = None
|
||||||
userprofile = Userprofile.objects.filter(name__contains=keyword)
|
if level == 1:
|
||||||
elif keytype == '2':
|
if keytype == '1':
|
||||||
userprofile = Userprofile.objects.filter(organization__name__contains=keyword)
|
userpaginator = Userprofile.objects.filter(name__contains=keyword,userprofile__organization__province=province)[:30]
|
||||||
paginator = Paginator(userprofile, 6)
|
elif keytype == '2':
|
||||||
page = int(request.GET.get('page', 1))
|
userpaginator = Userprofile.objects.filter(organization__name__contains=keyword,userprofile__organization__province=province)[:30]
|
||||||
try:
|
elif level == 2:
|
||||||
userprofile = paginator.page(page)
|
if keytype == '1':
|
||||||
except PageNotAnInteger:
|
userpaginator = Userprofile.objects.filter(name__contains=keyword,userprofile__organization__province=province,
|
||||||
userprofile = paginator.page(1)
|
userprofile__organization__cities=cities)[:30]
|
||||||
except EmptyPage:
|
elif keytype == '2':
|
||||||
userprofile = paginator.page(paginator.num_pages)
|
userpaginator = Userprofile.objects.filter(organization__name__contains=keyword,userprofile__organization__province=province,
|
||||||
for u in userprofile:
|
userprofile__organization__cities=cities)[:30]
|
||||||
|
elif level == 3:
|
||||||
|
if keytype == '1':
|
||||||
|
userpaginator = Userprofile.objects.filter(name__contains=keyword,userprofile__organization__province=province,
|
||||||
|
userprofile__organization__cities=cities,
|
||||||
|
userprofile__organization__district=district)[:30]
|
||||||
|
elif keytype == '2':
|
||||||
|
userpaginator = Userprofile.objects.filter(organization__name__contains=keyword,userprofile__organization__province=province,
|
||||||
|
userprofile__organization__cities=cities,
|
||||||
|
userprofile__organization__district=district)[:30]
|
||||||
|
elif level == 9:
|
||||||
|
if keytype == '1':
|
||||||
|
userpaginator = Userprofile.objects.filter(name__contains=keyword)[:30]
|
||||||
|
elif keytype == '2':
|
||||||
|
userpaginator = Userprofile.objects.filter(organization__name__contains=keyword)[:30]
|
||||||
|
|
||||||
|
# paginator = Paginator(userpaginator, 6)
|
||||||
|
# page = int(request.GET.get('page', 1))
|
||||||
|
# try:
|
||||||
|
# userpaginator = paginator.page(page)
|
||||||
|
# except PageNotAnInteger:
|
||||||
|
# userpaginator = paginator.page(1)
|
||||||
|
# except EmptyPage:
|
||||||
|
# userpaginator = paginator.page(paginator.num_pages)
|
||||||
|
userallinfo = []
|
||||||
|
for u in userpaginator:
|
||||||
o = dict()
|
o = dict()
|
||||||
o['id'] = str(u.id)
|
o['id'] = str(u.id)
|
||||||
|
if u.image:
|
||||||
|
o['image'] = u.image
|
||||||
o['name'] = u.name
|
o['name'] = u.name
|
||||||
o['image'] = u.image.url
|
o['phone'] = User.objects.get(id=u.user_id).username
|
||||||
|
o['organization'] = u.organization.name
|
||||||
|
organization_id = u.organization_id
|
||||||
|
print(organization_id)
|
||||||
|
if Organization.objects.get(id=organization_id).province and Organization.objects.get(
|
||||||
|
id=organization_id).cities and Organization.objects.get(
|
||||||
|
id=organization_id).district and Organization.objects.get(
|
||||||
|
id=organization_id).town and Organization.objects.get(id=organization_id).village:
|
||||||
|
o['administrativedivision'] = str(str(
|
||||||
|
Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province)) + '-' + str(
|
||||||
|
Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).cities)) + '-' + str(
|
||||||
|
Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).district)) + '-' + str(
|
||||||
|
Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).town)) + '-' + str(
|
||||||
|
Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).village))).replace(
|
||||||
|
'None', '')
|
||||||
|
elif Organization.objects.get(id=organization_id).province and Organization.objects.get(
|
||||||
|
id=organization_id).cities and Organization.objects.get(
|
||||||
|
id=organization_id).district and Organization.objects.get(id=organization_id).town:
|
||||||
|
o['administrativedivision'] = str(str(
|
||||||
|
Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province)) + '-' + str(
|
||||||
|
Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).cities)) + '-' + str(
|
||||||
|
Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).district)) + '-' + str(
|
||||||
|
Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).town))).replace('None',
|
||||||
|
'')
|
||||||
|
elif Organization.objects.get(id=organization_id).province and Organization.objects.get(
|
||||||
|
id=organization_id).cities and Organization.objects.get(id=organization_id).district:
|
||||||
|
o['administrativedivision'] = str(str(
|
||||||
|
Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province)) + '-' + str(
|
||||||
|
Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).cities)) + '-' + str(
|
||||||
|
Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).district))).replace(
|
||||||
|
'None', '')
|
||||||
|
elif Organization.objects.get(id=organization_id).province and Organization.objects.get(
|
||||||
|
id=organization_id).cities:
|
||||||
|
o['administrativedivision'] = str(str(
|
||||||
|
Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province)) + '-' + str(
|
||||||
|
Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).cities))).replace(
|
||||||
|
'None', '')
|
||||||
|
elif Organization.objects.get(id=organization_id).province:
|
||||||
|
o['administrativedivision'] = str(str(
|
||||||
|
Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province))).replace(
|
||||||
|
'None', '')
|
||||||
|
userallinfo.append(o)
|
||||||
|
print(userallinfo)
|
||||||
|
return render(request, 'management/user-management.html',
|
||||||
|
{'userallinfo': userallinfo, 'userpaginator': userpaginator})
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def news_search_by_keyword(request):
|
||||||
|
keytype = request.POST.get('keytype')
|
||||||
|
keyword = request.POST.get('keyword')
|
||||||
|
print(keytype, keyword)
|
||||||
|
news = None
|
||||||
|
if keytype == '1':
|
||||||
|
news = News.objects.filter(type='0',title__contains=keyword)[:30]
|
||||||
|
elif keytype == '2':
|
||||||
|
news = News.objects.filter(type='1',title__contains=keyword)[:30]
|
||||||
|
elif keytype == '3':
|
||||||
|
news = News.objects.filter(type='2',title__contains=keyword)[:30]
|
||||||
|
elif keytype == '4':
|
||||||
|
news = News.objects.filter(type='3',title__contains=keyword)[:30]
|
||||||
|
elif keytype == '5':
|
||||||
|
news = News.objects.filter(type='4',title__contains=keyword)[:30]
|
||||||
|
elif keytype == '6':
|
||||||
|
news = News.objects.filter(type='5',title__contains=keyword)[:30]
|
||||||
|
elif keytype == '7':
|
||||||
|
news = News.objects.filter(type='6',title__contains=keyword)[:30]
|
||||||
|
news_list = []
|
||||||
|
news_count = news.count()
|
||||||
|
for n in news:
|
||||||
|
o = dict()
|
||||||
|
o['id'] = str(n.id)
|
||||||
|
o['title'] = n.title
|
||||||
|
o['date'] = n.date
|
||||||
|
o['author'] = n.author
|
||||||
|
if n.type == '0':
|
||||||
|
o['type'] = '政策依据'
|
||||||
|
elif n.type == '1':
|
||||||
|
o['type'] = '基层动态'
|
||||||
|
elif n.type == '2':
|
||||||
|
o['type'] = '外省动态'
|
||||||
|
elif n.type == '3':
|
||||||
|
o['type'] = '监测通报'
|
||||||
|
elif n.type == '4':
|
||||||
|
o['type'] = '舆情热点'
|
||||||
|
elif n.type == '5':
|
||||||
|
o['type'] = '通知'
|
||||||
|
elif n.type == '6':
|
||||||
|
o['type'] = '重点新闻'
|
||||||
|
news_list.append(o)
|
||||||
|
return render(request, 'management/news-management.html',
|
||||||
|
{'news': news_list, 'new': news, 'news_count': news_count})
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def organization_search_by_keyword(request):
|
||||||
|
keytype = request.POST.get('keytype')
|
||||||
|
keyword = request.POST.get('keyword')
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
<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 '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="1">政策依据</option>
|
<option value="1">政策依据</option>
|
||||||
|
@ -58,7 +58,7 @@
|
||||||
<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>
|
||||||
|
|
|
@ -1,101 +1,101 @@
|
||||||
{% 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 action="{% url 'user-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>
|
||||||
{# <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="ketword">
|
||||||
<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">成员总计:{{ user_count }}</h2>
|
<h2 class="title pull-right" style="margin-right: 30px">成员总计:{{ user_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">电话</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 u in userallinfo %}
|
{% for u in userallinfo %}
|
||||||
<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="{{ u.image.url }}"
|
<td style="text-align: center"><img src="{{ u.image.url }}"
|
||||||
style="width: 80px;height: 80px;"
|
style="width: 80px;height: 80px;"
|
||||||
class="img-circle"></td>
|
class="img-circle"></td>
|
||||||
<td style="vertical-align: middle;text-align: center">{{ u.name }}</td>
|
<td style="vertical-align: middle;text-align: center">{{ u.name }}</td>
|
||||||
<td style="vertical-align: middle;text-align: center">{{ u.phone }}</td>
|
<td style="vertical-align: middle;text-align: center">{{ u.phone }}</td>
|
||||||
<td style="vertical-align: middle;text-align: center">{{ u.organization }}</td>
|
<td style="vertical-align: middle;text-align: center">{{ u.organization }}</td>
|
||||||
{# <td style="vertical-align: middle;text-align: center">{{ u.type }}</td>#}
|
{# <td style="vertical-align: middle;text-align: center">{{ u.type }}</td>#}
|
||||||
<td style="vertical-align: middle;text-align: center">{{ u.administrativedivision }}</td>
|
<td style="vertical-align: middle;text-align: center">{{ u.administrativedivision }}</td>
|
||||||
<td style="vertical-align: middle;text-align: center">
|
<td style="vertical-align: middle;text-align: center">
|
||||||
<a href="{% url 'user-management-delete' u.id %}"
|
<a href="{% url 'user-management-delete' u.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/user-management-paginate.html' %}
|
{% include 'dashboard/paginator/user-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 %}
|
||||||
|
|
|
@ -47,7 +47,8 @@ def user_management(request):
|
||||||
for u in userpaginator:
|
for u in userpaginator:
|
||||||
o = dict()
|
o = dict()
|
||||||
o['id'] = str(u.id)
|
o['id'] = str(u.id)
|
||||||
o['image'] = u.userprofile_set.get(user_id=u.id).image
|
if u.userprofile_set.get(user_id=u.id).image:
|
||||||
|
o['image'] = u.userprofile_set.get(user_id=u.id).image
|
||||||
o['name'] = u.userprofile_set.get(user_id=u.id).name
|
o['name'] = u.userprofile_set.get(user_id=u.id).name
|
||||||
o['phone'] = u.username
|
o['phone'] = u.username
|
||||||
o['organization'] = u.userprofile_set.get(user_id=u.id).organization.name
|
o['organization'] = u.userprofile_set.get(user_id=u.id).organization.name
|
||||||
|
|
Loading…
Reference in New Issue