#add
This commit is contained in:
parent
e244074b81
commit
eedf3e06bd
|
@ -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(
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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')
|
||||||
|
|
|
@ -23,19 +23,19 @@
|
||||||
<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>
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Reference in New Issue