#功能修改

This commit is contained in:
xieshen 2020-10-10 15:54:36 +08:00
parent de6670e3ab
commit 8f50a5cd32
13 changed files with 504 additions and 348 deletions

View File

@ -14,7 +14,7 @@
<li class="">
<a href="#" data-toggle="dropdown" class="toggle">
<i class="fa fa-envelope"></i>
<span class="badge badge-primary">7</span>
<span class="badge badge-primary">0</span>
</a>
<ul class="dropdown-menu messages animated fadeIn">
@ -181,7 +181,7 @@
<li class="">
<a href="#" data-toggle="dropdown" class="toggle">
<i class="fa fa-bell"></i>
<span class="badge badge-orange">3</span>
<span class="badge badge-orange">0</span>
</a>
<ul class="dropdown-menu notifications animated fadeIn">
<li class="total">

View File

@ -1,3 +1,5 @@
{% load startswith %}
{% with request.resolver_match.url_name as url_name %}
<div class="page-sidebar-wrapper" id="main-menu-wrapper" style="min-height: 1000px">
<!-- USER INFO - START -->
<div class="profile-info row">
@ -29,53 +31,53 @@
<ul class='wraplist'>
<li class="">
<li {% if url_name == 'monitor-new-media-public-opinion-weixin' %} class="open" {% endif %} >
<a href="{% url 'monitor-new-media-public-opinion-weixin' %}">
<i class="fa fa-th"></i>
<span class="title">新媒体舆情</span>
</a>
</li>
{# <li class="open">#}
<li class="">
<li {% if url_name == 'monitor-timeliness-monitoring' %} class="open" {% endif %}>
<a href="{% url 'monitor-timeliness-monitoring' %}">
<i class="fa fa-map-marker"></i>
<span class="title">时效性监测</span>
{# <span class="arrow "></span>#}
{# <span class="arrow "></span>#}
</a>
{# <ul class="sub-menu">#}
{# <li>#}
{# <a class="" href="">新媒体详情监测</a>#}
{# </li>#}
{# <li>#}
{# <a class="" href="">页面详情</a>#}
{# </li>#}
{# </ul>#}
{# <ul class="sub-menu">#}
{# <li>#}
{# <a class="" href="">新媒体详情监测</a>#}
{# </li>#}
{# <li>#}
{# <a class="" href="">页面详情</a>#}
{# </li>#}
{# </ul>#}
</li>
<li class="">
<li {% if url_name == 'monitor-error-monitoring' %} class="open" {% endif %}>
<a href="{% url 'monitor-error-monitoring' %}">
<i class="fa fa-bar-chart"></i>
<span class="title">错别字监测</span>
</a>
</li>
<li class="">
<li {% if url_name == 'monitor-sensitive-word-monitoring' %} class="open" {% endif %}>
<a href="{% url 'monitor-sensitive-word-monitoring' %}">
<i class="fa fa-folder-open"></i>
<span class="title">敏感词监测</span>
</a>
</li>
<li class="">
<li {% if url_name == 'monitor-comment-on-interactive-monitoring' %} class="open" {% endif %}>
<a href="{% url 'monitor-comment-on-interactive-monitoring' %}">
<i class="fa fa-th"></i>
<span class="title">评论互动监测</span>
</a>
</li>
<li class="">
<li {% if url_name == 'monitor-monitoring-report' %} class="open" {% endif %}>
<a href="{% url 'monitor-monitoring-report' %}">
<i class="fa fa-suitcase"></i>
<span class="title">监测报告</span>
</a>
</li>
<li class="">
<li {% if url_name|startswith:'group' %}class="open" {% endif %}>
<a href="javascript:;">
<i class="fa fa-sliders"></i>
<span class="title">矩阵管理</span>
@ -83,47 +85,47 @@
</a>
<ul class="sub-menu">
<li>
<a class="" href="{% url 'group-management-create' %}">新建矩阵</a>
<a {% if url_name == 'group-management-create' %} class="active" {% endif %} href="{% url 'group-management-create' %}">新建矩阵</a>
</li>
<li>
<a class="" href="{% url 'group-management-management-init' %}">编辑矩阵</a>
</li>
<li>
<a class="" href="">搜索添加单位</a>
<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 {% if url_name|startswith:'newmedia' %}class="open" {% endif %}>
<a href="javascript:;">
<i class="fa fa-gift"></i>
<span class="title">新媒体管理</span>
<span class="arrow "></span><span class="label label-orange">NEW</span>
{# <span class="arrow "></span><span class="label label-orange">NEW</span>#}
</a>
<ul class="sub-menu">
<li>
<a class="" href="{% url 'newmedia-management-create-menu' %}">新建新媒体</a>
<a {% if url_name == 'newmedia-management-create-menu' %} class="active" {% endif %} href="{% url 'newmedia-management-create-menu' %}">新建新媒体</a>
</li>
<li>
<a class="" href="{% url 'newmedia-management-edit-menu' %}">编辑新媒体</a>
<a {% if url_name == 'newmedia-management-edit-menu' %} class="active" {% endif %} href="{% url 'newmedia-management-edit-menu' %}">编辑新媒体</a>
</li>
</ul>
</li>
<li class="">
<li {% if url_name|startswith:'organization' %}class="open" {% endif %}>
<a href="javascript:;">
<i class="fa fa-envelope"></i>
<span class="title">主体单位管理</span>
<span class="arrow "></span><span class="label label-orange">4</span>
{# <span class="arrow "></span><span class="label label-orange">0</span>#}
</a>
<ul class="sub-menu">
<li>
<a class="" href="{% url 'organization-management-create' %}">新建单位</a>
<a {% if url_name == 'organization-management-create' %} class="active" {% endif %} href="{% url 'organization-management-create' %}">新建单位</a>
</li>
<li>
<a class="" href="{% url 'organization-management-management' %}">编辑单位</a>
<a {% if url_name == 'organization-management-management' %} class="active" {% endif %} href="{% url 'organization-management-management' %}">编辑单位</a>
</li>
</ul>
</li>
<li class="">
<li {% if url_name|startswith:'news' %}class="open" {% endif %}>
<a href="javascript:;">
<i class="fa fa-sliders"></i>
<span class="title">新闻管理</span>
@ -131,20 +133,20 @@
</a>
<ul class="sub-menu">
<li>
<a class="" href="{% url 'news-management-create' %}">发布新闻</a>
<a {% if url_name == 'news-management-create' %} class="active" {% endif %} href="{% url 'news-management-create' %}">发布新闻</a>
</li>
<li>
<a class="" href="{% url 'new-management' %}">新闻管理</a>
<a {% if url_name == 'news-management' %} class="active" {% endif %} href="{% url 'news-management' %}">新闻管理</a>
</li>
</ul>
</li>
<li class="">
<li {% if url_name == 'user-management-management' %} class="open" {% endif %}>
<a href="{% url 'user-management-management' %}">
<i class="fa fa-columns"></i>
<span class="title">用户管理</span>
</a>
</li>
<li class="">
<li {% if url_name == 'user-management-update' %} class="open" {% endif %}>
<a href="{% url 'user-management-update' user.id %}">
<i class="fa fa-dashboard"></i>
<span class="title">系统设置</span>
@ -200,3 +202,4 @@
</ul>
</div>
{% endwith %}

View File

@ -0,0 +1,10 @@
from django import template
register = template.Library()
@register.filter(name='startswith')
def startswith(text, starts):
if isinstance(text, str):
return text.startswith(starts)
return False

View File

@ -172,7 +172,7 @@ def register(request):
def get_province(request):
# 省
province = Area_code_2020.objects.filter(level=1)
province = Area_code_2020.objects.filter(level=1,name='甘肃省')
res = []
for i in province:
res.append([i.code, i.name, i.level, i.pcode])

View File

@ -41,7 +41,8 @@
<div class="row">
<div class="col-md-8 col-sm-9 col-xs-10">
<form method="post"
action="{% url 'group-management-update' group.id %}" enctype="multipart/form-data">{% csrf_token %}
action="{% url 'group-management-update' group.id %}"
enctype="multipart/form-data">{% csrf_token %}
<div class="form-group">
<label class="form-label" for="name">矩阵名称</label>
<div class="controls">
@ -92,26 +93,27 @@
<label class="form-label" for="administrativedivision">行政区划</label>
<div class="controls">
<select id="province" name="province">
<option value="{{ group.province }}">{{ group.province }}</option>
<option value="{{ group.province }}">{{ p }}</option>
</select>
<select id="city" name="city" style="margin-left: 20px">
<option value="{{ group.cities }}">{{ group.cities }}</option>
<option value="{{ group.cities }}">{{ c }}</option>
</select>
<select id="district" name="district" style="margin-left: 20px">
<option value="{{ group.district }}">{{ group.district }}</option>
<option value="{{ group.district }}">{{ d }}</option>
</select>
<select id="town" name="town" style="margin-left: 20px">
<option value="{{ group.town }}">{{ group.town }}</option>
<option value="{{ group.town }}">{{ t }}</option>
</select>
<select id="village" name="village" style="margin-left: 20px">
<option value="{{ group.village }}">{{ group.village }}</option>
<option value="{{ group.village }}">{{ v }}</option>
</select>
</div>
</div>
<div class="form-group">
<label class="form-label" for="stauts">管理员</label>
<div class="controls" style="margin-left: 5%">
<a href="{% url 'group-admin-create' group.id %}"><span class="glyphicon glyphicon-plus" aria-hidden="true">添加管理员</span></a>
<a href="{% url 'group-admin-create' group.id %}"><span
class="glyphicon glyphicon-plus" aria-hidden="true">添加管理员</span></a>
<table class="table table-hover" style="margin-top: 20px">
<thead>
<tr>
@ -147,7 +149,8 @@
<div class="form-group">
<label class="form-label" for="stauts">成员</label>
<div class="controls" style="margin-left: 5%">
<a href="{% url 'group-user-create' group.id %}"><span class="glyphicon glyphicon-plus" aria-hidden="true">添加成员</span></a>
<a href="{% url 'group-user-create' group.id %}"><span
class="glyphicon glyphicon-plus" aria-hidden="true">添加成员</span></a>
<table class="table table-hover" style="margin-top: 20px">
<thead>
<tr>
@ -194,3 +197,78 @@
</div>
</body>
{% endblock %}
{% block add_js %}
<script>
$(function () {
$.get('/get/province/', function (data) {
for (var i = 0, len = data.province.length; i < len; i++) {
$new = $("<option value=" + data.province[i][0] + ">" + data.province[i][1] + "</option>");
$("#province").append($new);
}
})
//当省份改变后
$("#province").change(function () {
$("#city").empty().append('<option value="">请选择市</option>');
$("#district").empty().append('<option value="">请选择区/县</option>');
$("#town").empty().append('<option value="">请选择乡/镇</option>');
$("#village").empty().append('<option value="">请选择村/街道</option>');
$.ajax({
url: '/get/city/',
type: 'get',
data: {"code": $(this).val()}
}).done(function (data) {
for (var i = 0, len = data.city.length; i < len; i++) {
$new = $("<option value=" + data.city[i][0] + ">" + data.city[i][1] + "</option>");
$("#city").append($new);
}
})
})
//当城市改变后
$("#city").change(function () {
$("#district").empty().append('<option value="">请选择区/县</option>');
$("#town").empty().append('<option value="">请选择乡/镇</option>');
$("#village").empty().append('<option value="">请选择村/街道</option>');
$.ajax({
url: '/get/district/',
type: 'get',
data: {"code": $(this).val()}
}).done(function (data) {
for (var i = 0, len = data.district.length; i < len; i++) {
$new = $("<option value=" + data.district[i][0] + ">" + data.district[i][1] + "</option>");
$("#district").append($new);
}
})
})
//当县改变后
$("#district").change(function () {
$("#town").empty().append('<option value="">请选择乡/镇</option>');
$("#village").empty().append('<option value="">请选择村/街道</option>');
$.ajax({
url: '/get/town/',
type: 'get',
data: {"code": $(this).val()}
}).done(function (data) {
for (var i = 0, len = data.town.length; i < len; i++) {
$new = $("<option value=" + data.town[i][0] + ">" + data.town[i][1] + "</option>");
$("#town").append($new);
}
})
})
//当乡改变后
$("#district").change(function () {
$("#village").empty().append('<option value="">请选择村/街道</option>');
$.ajax({
url: '/get/village/',
type: 'get',
data: {"code": $(this).val()}
}).done(function (data) {
for (var i = 0, len = data.village.length; i < len; i++) {
$new = $("<option value=" + data.village[i][0] + ">" + data.village[i][1] + "</option>");
$("#village").append($new);
}
})
})
})
</script>
{% endblock %}

View File

@ -71,7 +71,7 @@
<td style="vertical-align: middle;text-align: center">{{ r.name }}</td>
<td style="vertical-align: middle;text-align: center">{{ r.type }}</td>
<td style="vertical-align: middle;text-align: center">{{ r.admin_count }}</td>
<td style="vertical-align: middle;text-align: center">{{ r.admin_count }}</td>
<td style="vertical-align: middle;text-align: center">{{ r.user_count }}</td>
<td style="vertical-align: middle;text-align: center">{{ r.status }}</td>
<td style="vertical-align: middle;text-align: center">
<a href="{% url 'group-management-update' r.id %}"

View File

@ -112,7 +112,7 @@
<div class="controls">
<select class="form-control" name="classify">
{% for g in g_c_c_res %}
<option value="{{ g }}">{{ g }}</option>
<option value="{{ g.0 }}">{{ g.1 }}</option>
{% endfor %}
</select>
</div>
@ -135,8 +135,11 @@
<script>
$(function () {
$.get('/get/province/', function (data) {
{#s = "<option value='620000000000' selected>甘肃省</option>"#}
{#$("#province").append(s);#}
for (var i = 0, len = data.province.length; i < len; i++) {
$new = $("<option value=" + data.province[i][0] + ">" + data.province[i][1] + "</option>");
$("#province").append($new);
}
})

View File

@ -71,7 +71,7 @@
<td style="vertical-align: middle;text-align: center">{{ r.name }}</td>
<td style="vertical-align: middle;text-align: center">{{ r.type }}</td>
<td style="vertical-align: middle;text-align: center">{{ r.admin_count }}</td>
<td style="vertical-align: middle;text-align: center">{{ r.admin_count }}</td>
<td style="vertical-align: middle;text-align: center">{{ r.user_count }}</td>
<td style="vertical-align: middle;text-align: center">{{ r.status }}</td>
<td style="vertical-align: middle;text-align: center">
<a href="{% url 'group-management-update' r.id %}"

View File

@ -41,7 +41,8 @@
<div class="row">
<div class="col-md-8 col-sm-9 col-xs-10">
<form method="post"
action="{% url 'group-management-update' group.id %}" enctype="multipart/form-data">{% csrf_token %}
action="{% url 'group-management-update' group.id %}"
enctype="multipart/form-data">{% csrf_token %}
<div class="form-group">
<label class="form-label" for="name">矩阵名称</label>
<div class="controls">
@ -92,19 +93,19 @@
<label class="form-label" for="administrativedivision">行政区划</label>
<div class="controls">
<select id="province" name="province">
<option value="{{ group.province }}">{{ group.province }}</option>
<option value="{{ group.province }}">{{ p }}</option>
</select>
<select id="city" name="city" style="margin-left: 20px">
<option value="{{ group.cities }}">{{ group.cities }}</option>
<option value="{{ group.cities }}">{{ c }}</option>
</select>
<select id="district" name="district" style="margin-left: 20px">
<option value="{{ group.district }}">{{ group.district }}</option>
<option value="{{ group.district }}">{{ d }}</option>
</select>
<select id="town" name="town" style="margin-left: 20px">
<option value="{{ group.town }}">{{ group.town }}</option>
<option value="{{ group.town }}">{{ t }}</option>
</select>
<select id="village" name="village" style="margin-left: 20px">
<option value="{{ group.village }}">{{ group.village }}</option>
<option value="{{ group.village }}">{{ v }}</option>
</select>
</div>
</div>
@ -112,7 +113,13 @@
<label class="form-label" for="classify">矩阵分类</label>
<div class="controls">
<select class="form-control" name="classify">
<option value="{{ group.classify }}">{{ group.classify }}</option>
{% if group.classify == '0' %}
<option value="{{ group.classify }}">区域</option>
{% elif group.classify == '1' %}
<option value="{{ group.classify }}">媒体种类</option>
{% elif group.classify == '2' %}
<option value="{{ group.classify }}">行业</option>
{% endif %}
{% for g in g_c_c_res %}
<option value="{{ g }}">{{ g }}</option>
{% endfor %}
@ -122,7 +129,8 @@
<div class="form-group">
<label class="form-label" for="stauts">管理员</label>
<div class="controls" style="margin-left: 5%">
<a href="{% url 'group-admin-create' group.id %}"><span class="glyphicon glyphicon-plus" aria-hidden="true">添加管理员</span></a>
<a href="{% url 'group-admin-create' group.id %}"><span
class="glyphicon glyphicon-plus" aria-hidden="true">添加管理员</span></a>
<table class="table table-hover" style="margin-top: 20px">
<thead>
<tr>
@ -158,7 +166,8 @@
<div class="form-group">
<label class="form-label" for="stauts">成员</label>
<div class="controls" style="margin-left: 5%">
<a href="{% url 'group-user-create' group.id %}"><span class="glyphicon glyphicon-plus" aria-hidden="true">添加成员</span></a>
<a href="{% url 'group-user-create' group.id %}"><span
class="glyphicon glyphicon-plus" aria-hidden="true">添加成员</span></a>
<table class="table table-hover" style="margin-top: 20px">
<thead>
<tr>

View File

@ -70,7 +70,7 @@
<td style="vertical-align: middle;text-align: center">{{ r.name }}</td>
<td style="vertical-align: middle;text-align: center">{{ r.type }}</td>
<td style="vertical-align: middle;text-align: center">{{ r.admin_count }}</td>
<td style="vertical-align: middle;text-align: center">{{ r.admin_count }}</td>
<td style="vertical-align: middle;text-align: center">{{ r.user_count }}</td>
<td style="vertical-align: middle;text-align: center">{{ r.status }}</td>
</tr>
{% endfor %}

View File

@ -53,7 +53,7 @@ urlpatterns = [
path('newmedia/detail/<str:pk>/weixin/',views.newmedia_detail_weixin,name='newmedia-detail-weixin'),
#新闻管理
path('news/management/',views.new_management,name='new-management'),
path('news/management/',views.new_management,name='news-management'),
path('news/management/create/', views.news_management_create, name='news-management-create'),
path('news/management/detail/<str:pk>/', views.news_management_detail, name='news-management-detail'),
path('news/management/delete/<str:pk>/', views.news_management_delete, name='news-management-delete'),

View File

@ -83,7 +83,8 @@ def user_update(request, pk):
passwordold = request.POST.get('passwordold')
passwordnew = request.POST.get('passwordnew')
confirm_password = request.POST.get('confirm_password')
if passwordold is not None and passwordnew is not None and confirm_password is not None:
print(len(passwordold), len(passwordnew), confirm_password)
if len(passwordold) != 0 and len(passwordnew) != 0 and len(confirm_password) != 0:
if passwordnew == confirm_password:
user.email = email
user.username = username
@ -109,7 +110,7 @@ def user_update(request, pk):
user.save()
userprofile.save()
messages.success(request, "修改成功")
return HttpResponseRedirect("/")
return HttpResponseRedirect("/index")
return render(request, 'management/user-management-update.html',
{'usee': user, 'userprofile': userprofile, 'organization': organization})
@ -119,7 +120,7 @@ def user_update(request, pk):
def group_management_init(request):
user = request.user
# 创建的矩阵
group_initer = Group.objects.filter(user_id=user.id)
group_initer = Group.objects.filter(user_id=user.id).order_by('-created')
print(group_initer)
paginator = Paginator(group_initer, 6)
page = int(request.GET.get('page', 1))
@ -148,7 +149,7 @@ def group_management_admin(request):
# 管理的矩阵
user = request.user
group_admin_list = []
for g_a in Group_admin.objects.filter(user_id=user.id):
for g_a in Group_admin.objects.filter(user_id=user.id).order_by('-created'):
group_admin = Group.objects.get(id=g_a.group_id)
group_admin_list.append(group_admin)
paginator = Paginator(group_admin_list, 6)
@ -178,7 +179,7 @@ def group_management_user(request):
# 加入的矩阵
user = request.user
group_user_list = []
for g_u in Group_user.objects.filter(user_id=user.id):
for g_u in Group_user.objects.filter(user_id=user.id).order_by('-created'):
group_user = Group.objects.get(id=g_u.group_id)
group_user_list.append(group_user)
paginator = Paginator(group_user_list, 6)
@ -206,6 +207,21 @@ def group_management_user(request):
@login_required
def group_update(request, pk):
group = Group.objects.get(id=pk)
p = ''
c = ''
d = ''
t = ''
v = ''
if group.province:
p = Area_code_2020.objects.get(code=group.province).name
if group.cities:
c = Area_code_2020.objects.get(code=group.cities).name
if group.district:
d = Area_code_2020.objects.get(code=group.district).name
if group.town:
t = Area_code_2020.objects.get(code=group.town).name
if group.village:
v = Area_code_2020.objects.get(code=group.village).name
group_status_choices_list = []
for g in range(2):
group_status_choices_list.append(g)
@ -249,27 +265,27 @@ def group_update(request, pk):
classify = request.POST.get('classify')
print(str(province) + "66666666666666666666666666")
if province != '' and province.isdigit():
province_r = Area_code_2020.objects.get(code=province).name
province_r = province
else:
province_r = province
city = request.POST.get('city')
if city != '' and city.isdigit():
city_r = Area_code_2020.objects.get(code=city).name
city_r = city
else:
city_r = city
district = request.POST.get('district')
if district != '' and district.isdigit():
district_r = Area_code_2020.objects.get(code=district).name
district_r = district
else:
district_r = district
town = request.POST.get('town')
if town != '' and town.isdigit():
town_r = Area_code_2020.objects.get(code=town).name
town_r = town
else:
town_r = town
village = request.POST.get('village')
if village != '' and village.isdigit():
village_r = Area_code_2020.objects.get(code=village).name
village_r = village
else:
village_r = village
if image is not None:
@ -289,7 +305,8 @@ def group_update(request, pk):
return HttpResponseRedirect('/management/group/management/init/')
return render(request, 'management/group-management-update.html',
{'group': group, 'group_status_choices_list': group_status_choices_list, 'group_type': group_type,
'g_a_list': g_a_list, 'g_u_list': g_u_list, 'g_c_c_res': g_c_c_res})
'g_a_list': g_a_list, 'g_u_list': g_u_list, 'g_c_c_res': g_c_c_res, 'p': p, 'c': c, 'd': d, 't': t,
'v': v})
@login_required
@ -302,38 +319,42 @@ def group_create(request):
GROUP_CLASSIFY_CHOICES = Group.GROUP_CLASSIFY_CHOICES
g_c_c_res = []
for g_c_c in GROUP_CLASSIFY_CHOICES:
g_c_c_res.append(list(g_c_c)[1])
g_c_c_res.append([list(g_c_c)[0], list(g_c_c)[1]])
if request.method == 'POST':
name = request.POST.get('name')
presentation = request.POST.get('presentation')
image = None
if not request.FILES.get('image'):
image = 'group.jpg'
else:
image = request.FILES.get('image')
type = request.POST.get('type')
status = request.POST.get('status')
province = request.POST.get('province')
classify = request.POST.get('classify')
if province != '':
province_r = Area_code_2020.objects.get(code=province).name
province_r = province
else:
messages.error(request, '请选择行政区划')
return HttpResponseRedirect('/management/organization/create/')
city = request.POST.get('city')
if city != '':
city_r = Area_code_2020.objects.get(code=city).name
city_r = city
else:
city_r = city
district = request.POST.get('district')
if district != '':
district_r = Area_code_2020.objects.get(code=district).name
district_r = district
else:
district_r = district
town = request.POST.get('town')
if town != '':
town_r = Area_code_2020.objects.get(code=town).name
town_r = town
else:
town_r = town
village = request.POST.get('village')
if village != '':
village_r = Area_code_2020.objects.get(code=village).name
village_r = village
else:
village_r = village
print(name, presentation, image, type, status, province, city, district, town, village)
@ -342,8 +363,24 @@ def group_create(request):
province=province_r, cities=city_r, district=district_r, town=town_r, village=village_r,
user_id=user.id, classify=classify)
group.save()
p = ''
c = ''
d = ''
t = ''
v = ''
if group.province:
p = Area_code_2020.objects.get(code=group.province).name
if group.cities:
c = Area_code_2020.objects.get(code=group.cities).name
if group.district:
d = Area_code_2020.objects.get(code=group.district).name
if group.town:
t = Area_code_2020.objects.get(code=group.town).name
if group.village:
v = Area_code_2020.objects.get(code=group.village).name
messages.success(request, '添加成功')
return render(request, 'management/add-group-admin-and-user.html', {'group': group})
return render(request, 'management/add-group-admin-and-user.html',
{'group': group, 'p': p, 'c': c, 'd': d, 't': t, 'v': v})
else:
messages.error(request, '矩阵名不能为空')
# return HttpResponseRedirect('/management/group/management/')
@ -422,6 +459,7 @@ def organization_management(request):
district = o.district
print(level, province, cities, district)
organization = None
res = []
if level == 1:
organization = Organization.objects.filter(province=province).order_by('-created')
elif level == 2:
@ -438,14 +476,15 @@ def organization_management(request):
organization = paginator.page(1)
except EmptyPage:
organization = paginator.page(paginator.num_pages)
res = []
for i in organization:
o = dict()
o['id'] = str(i.id)
o['name'] = i.name
o['image'] = i.image.url
o['organizationtype'] = i.organizationtype.organizationtype
if len(i.province) > 0 and len(i.cities) > 0 and len(i.district) > 0 and len(i.town) > 0 and len(i.village) > 0:
if len(i.province) > 0 and len(i.cities) > 0 and len(i.district) > 0 and len(i.town) > 0 and len(
i.village) > 0:
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(
@ -467,7 +506,8 @@ def organization_management(request):
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() + Toutiao.objects.filter(
organization_id=i.id).count() + Qita.objects.filter(
organization_id=i.id).count()
res.append(o)
@ -787,6 +827,7 @@ def newmedia_management_edit_weixin(request):
cities = o.cities
district = o.district
weixin = None
res = []
if level == 1:
weixin = Weixin.objects.filter(organization__province=province).order_by('-created')
elif level == 2:
@ -796,6 +837,7 @@ def newmedia_management_edit_weixin(request):
weixin = Weixin.objects.filter(organization__province=province, organization__cities=cities,
organization__district=district).order_by(
'-created')
if weixin is not None:
paginator = Paginator(weixin, 6)
page = int(request.GET.get('page', 1))
try:
@ -804,7 +846,7 @@ def newmedia_management_edit_weixin(request):
weixin = paginator.page(1)
except EmptyPage:
weixin = paginator.page(paginator.num_pages)
res = []
for w in weixin:
o = dict()
o['id'] = str(w.id)
@ -828,7 +870,8 @@ def newmedia_management_edit_weixin(request):
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:
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(
@ -853,6 +896,7 @@ def newmedia_management_edit_weibo(request):
cities = o.cities
district = o.district
weibo = None
res = []
if level == 1:
weibo = Weibo.objects.filter(organization__province=province).order_by('-created')
elif level == 2:
@ -860,6 +904,7 @@ def newmedia_management_edit_weibo(request):
elif level == 3:
weibo = Weibo.objects.filter(organization__province=province, organization__cities=cities,
organization__district=district).order_by('-created')
if weibo is not None:
paginator = Paginator(weibo, 6)
page = int(request.GET.get('page', 1))
try:
@ -868,7 +913,7 @@ def newmedia_management_edit_weibo(request):
weibo = paginator.page(1)
except EmptyPage:
weibo = paginator.page(paginator.num_pages)
res = []
for w in weibo:
o = dict()
o['id'] = str(w.id)
@ -892,7 +937,8 @@ def newmedia_management_edit_weibo(request):
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:
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(
@ -917,6 +963,7 @@ def newmedia_management_edit_toutiao(request):
cities = o.cities
district = o.district
toutiao = None
res = []
if level == 1:
toutiao = Toutiao.objects.filter(organization__province=province).order_by('-created')
elif level == 2:
@ -926,6 +973,7 @@ def newmedia_management_edit_toutiao(request):
toutiao = Toutiao.objects.filter(organization__province=province, organization__cities=cities,
organization__district=district).order_by(
'-created')
if toutiao is not None:
paginator = Paginator(toutiao, 6)
page = int(request.GET.get('page', 1))
try:
@ -934,7 +982,6 @@ def newmedia_management_edit_toutiao(request):
toutiao = paginator.page(1)
except EmptyPage:
toutiao = paginator.page(paginator.num_pages)
res = []
for w in toutiao:
o = dict()
o['id'] = str(w.id)
@ -958,7 +1005,8 @@ def newmedia_management_edit_toutiao(request):
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:
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(
@ -983,6 +1031,7 @@ def newmedia_management_edit_douyin(request):
cities = o.cities
district = o.district
douyin = None
res = []
if level == 1:
douyin = Douyin.objects.filter(organization__province=province).order_by('-created')
elif level == 2:
@ -992,6 +1041,7 @@ def newmedia_management_edit_douyin(request):
douyin = Douyin.objects.filter(organization__province=province, organization__cities=cities,
organization__district=district).order_by(
'-created')
if douyin is not None:
paginator = Paginator(douyin, 6)
page = int(request.GET.get('page', 1))
try:
@ -1000,7 +1050,6 @@ def newmedia_management_edit_douyin(request):
douyin = paginator.page(1)
except EmptyPage:
douyin = paginator.page(paginator.num_pages)
res = []
for w in douyin:
o = dict()
o['id'] = str(w.id)
@ -1024,7 +1073,8 @@ def newmedia_management_edit_douyin(request):
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:
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(
@ -1049,6 +1099,7 @@ def newmedia_management_edit_qita(request):
cities = o.cities
district = o.district
qita = None
res = []
if level == 1:
qita = Qita.objects.filter(organization__province=province).order_by('-created')
elif level == 2:
@ -1056,6 +1107,7 @@ def newmedia_management_edit_qita(request):
elif level == 3:
qita = Qita.objects.filter(organization__province=province, organization__cities=cities,
organization__district=district).order_by('-created')
if qita is not None:
paginator = Paginator(qita, 6)
page = int(request.GET.get('page', 1))
try:
@ -1064,7 +1116,6 @@ def newmedia_management_edit_qita(request):
qita = paginator.page(1)
except EmptyPage:
qita = paginator.page(paginator.num_pages)
res = []
for w in qita:
o = dict()
o['id'] = str(w.id)
@ -1089,7 +1140,8 @@ def newmedia_management_edit_qita(request):
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:
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(

View File

@ -1,12 +1,13 @@
# Django~=2.2.15
# django-bootstrap3
# django-simple-captcha
# psycopg2-binary
# django-cors-headers
# aliyun-python-sdk-core-v3
# channels
# requests
# parsel
# django-summernote
# python-dateutil
# channels_redis[cryptography]
Django~=2.2.15
django-bootstrap3
django-simple-captcha
psycopg2-binary
django-cors-headers
aliyun-python-sdk-core-v3
channels
requests
parsel
django-summernote
python-dateutil
channels_redis[cryptography]
jieba