#更改数据库
This commit is contained in:
parent
7360d61a8e
commit
ee1ba062b3
|
@ -112,7 +112,6 @@ class Organizationtype(models.Model):
|
|||
def __str__(self):
|
||||
return self.organizationtype
|
||||
|
||||
|
||||
# 单位
|
||||
class Organization(models.Model):
|
||||
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('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)
|
||||
|
||||
|
|
|
@ -423,24 +423,151 @@ def import_user(request):
|
|||
return HttpResponse('ok')
|
||||
@login_required
|
||||
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')
|
||||
keyword = request.POST.get('ketword')
|
||||
userprofile = None
|
||||
if keytype == '1':
|
||||
userprofile = Userprofile.objects.filter(name__contains=keyword)
|
||||
elif keytype == '2':
|
||||
userprofile = Userprofile.objects.filter(organization__name__contains=keyword)
|
||||
paginator = Paginator(userprofile, 6)
|
||||
page = int(request.GET.get('page', 1))
|
||||
try:
|
||||
userprofile = paginator.page(page)
|
||||
except PageNotAnInteger:
|
||||
userprofile = paginator.page(1)
|
||||
except EmptyPage:
|
||||
userprofile = paginator.page(paginator.num_pages)
|
||||
for u in userprofile:
|
||||
print(keytype,keyword)
|
||||
userpaginator = None
|
||||
if level == 1:
|
||||
if keytype == '1':
|
||||
userpaginator = Userprofile.objects.filter(name__contains=keyword,userprofile__organization__province=province)[:30]
|
||||
elif keytype == '2':
|
||||
userpaginator = Userprofile.objects.filter(organization__name__contains=keyword,userprofile__organization__province=province)[:30]
|
||||
elif level == 2:
|
||||
if keytype == '1':
|
||||
userpaginator = Userprofile.objects.filter(name__contains=keyword,userprofile__organization__province=province,
|
||||
userprofile__organization__cities=cities)[:30]
|
||||
elif keytype == '2':
|
||||
userpaginator = Userprofile.objects.filter(organization__name__contains=keyword,userprofile__organization__province=province,
|
||||
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['id'] = str(u.id)
|
||||
if u.image:
|
||||
o['image'] = u.image
|
||||
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 ">
|
||||
<header class="panel_header">
|
||||
<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%">
|
||||
<select class="form-control" name="keytype">
|
||||
<option value="1">政策依据</option>
|
||||
|
@ -58,7 +58,7 @@
|
|||
<div class="input-group">
|
||||
<input type="text" class="form-control" placeholder="输入搜索关键字" name="keyword">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default" type="button">搜索</button>
|
||||
<button class="btn btn-default" type="submit">搜索</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,101 +1,101 @@
|
|||
{% extends 'dashboard/base/base.html' %}
|
||||
{% load static %}
|
||||
{% block css %}
|
||||
<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"/>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<body class=" ">
|
||||
<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;'>
|
||||
<div class='col-lg-12 col-md-12 col-sm-12 col-xs-12'>
|
||||
<div class="page-title">
|
||||
<div class="pull-left">
|
||||
<h1 class="title">用户管理</h1></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
<div class="col-lg-12">
|
||||
<section class="box ">
|
||||
<header class="panel_header">
|
||||
<h2 class="title pull-left">成员列表</h2>
|
||||
<form>
|
||||
<div class="btn-group col-md-2 title" style="display: inline-block;margin-left: 5%">
|
||||
<select class="form-control" name="keytype">
|
||||
<option value="1">姓名</option>
|
||||
<option value="2">单位</option>
|
||||
{# <option value="3">行政区划</option>#}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-lg-6 title">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" placeholder="输入搜索关键字" name="keyword">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default" type="button">搜索</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<h2 class="title pull-right" style="margin-right: 30px">成员总计:{{ user_count }}</h2>
|
||||
</header>
|
||||
<div class="content-body">
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-sm-12 col-xs-12">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<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>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for u in userallinfo %}
|
||||
<tr>
|
||||
<td style="vertical-align: middle;text-align: center">{{ forloop.counter }}</td>
|
||||
<td style="text-align: center"><img src="{{ u.image.url }}"
|
||||
style="width: 80px;height: 80px;"
|
||||
class="img-circle"></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.organization }}</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">
|
||||
<a href="{% url 'user-management-delete' u.id %}"
|
||||
class="btn btn-danger btn-mini">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="metadata-pagination">
|
||||
{% include 'dashboard/paginator/user-management-paginate.html' %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
<div class="chatapi-windows ">
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
{% endblock %}
|
||||
{% block add_js %}
|
||||
<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>
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% extends 'dashboard/base/base.html' %}
|
||||
{% load static %}
|
||||
{% block css %}
|
||||
<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"/>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<body class=" ">
|
||||
<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;'>
|
||||
<div class='col-lg-12 col-md-12 col-sm-12 col-xs-12'>
|
||||
<div class="page-title">
|
||||
<div class="pull-left">
|
||||
<h1 class="title">用户管理</h1></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
<div class="col-lg-12">
|
||||
<section class="box ">
|
||||
<header class="panel_header">
|
||||
<h2 class="title pull-left">成员列表</h2>
|
||||
<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%">
|
||||
<select class="form-control" name="keytype">
|
||||
<option value="1">姓名</option>
|
||||
<option value="2">单位</option>
|
||||
{# <option value="3">行政区划</option>#}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-lg-6 title">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" placeholder="输入搜索关键字" name="ketword">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default" type="submit">搜索</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<h2 class="title pull-right" style="margin-right: 30px">成员总计:{{ user_count }}</h2>
|
||||
</header>
|
||||
<div class="content-body">
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-sm-12 col-xs-12">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<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>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for u in userallinfo %}
|
||||
<tr>
|
||||
<td style="vertical-align: middle;text-align: center">{{ forloop.counter }}</td>
|
||||
<td style="text-align: center"><img src="{{ u.image.url }}"
|
||||
style="width: 80px;height: 80px;"
|
||||
class="img-circle"></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.organization }}</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">
|
||||
<a href="{% url 'user-management-delete' u.id %}"
|
||||
class="btn btn-danger btn-mini">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="metadata-pagination">
|
||||
{% include 'dashboard/paginator/user-management-paginate.html' %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
<div class="chatapi-windows ">
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
{% endblock %}
|
||||
{% block add_js %}
|
||||
<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>
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -47,7 +47,8 @@ def user_management(request):
|
|||
for u in userpaginator:
|
||||
o = dict()
|
||||
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['phone'] = u.username
|
||||
o['organization'] = u.userprofile_set.get(user_id=u.id).organization.name
|
||||
|
|
Loading…
Reference in New Issue