#add message

This commit is contained in:
xieshen 2021-02-06 19:10:00 +08:00
parent 519ef557fa
commit 6f70d6f4d2
17 changed files with 366 additions and 205 deletions

View File

@ -0,0 +1,18 @@
<div id="pages" class="text-center">
<nav>
<ul class="pagination">
<li class="step-links">
{% if page.has_previous %}
<a class='active' href="?page={{ page.previous_page_number }}">上一页</a>
{% endif %}
<span class="current">
第{{ page.number }}页 共{{ page.paginator.num_pages }}页</span>
{% if page.has_next %}
<a class='active' href="?page={{ page.next_page_number }}">下一页</a>
{% endif %}
</li>
</ul>
</nav>
</div>

View File

@ -102,6 +102,9 @@ def user_login(request):
if user is not None:
if user.check_password(password):
login(request, user)
if Userprofile.objects.get(user_id=user.id).image is None:
userpro = Userprofile.objects.get(user_id=user.id)
userpro.image = '/profile/user_default.jpg'
return HttpResponseRedirect('/index/')
else:
messages.error(request, '无效的账号')

View File

@ -126,6 +126,8 @@
</select>
</div>
</div>
<button type="submit" class="btn btn-success">提交修改</button>
</form>
<div class="form-group">
<label class="form-label" for="stauts">管理员</label>
<div class="controls" style="margin-left: 5%">
@ -163,11 +165,27 @@
</table>
</div>
</div>
<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>
<div class="col-xs-12 col-lg-12 col-md-12">
<form action="{% url 'group-user-search' group.id %}"
method="post">{% csrf_token %}
<div class="col-md-12 title" style="margin-top: 20px">
<div class="input-group">
<input type="text" class="form-control"
placeholder="请输入姓名搜索"
name="keyword">
<span class="input-group-btn">
<button class="btn btn-default" type="submit">搜索</button>
</span>
</div>
</div>
</form>
</div>
<table class="table table-hover" style="margin-top: 20px">
<thead>
<tr>
@ -198,11 +216,13 @@
{% endfor %}
</tbody>
</table>
<div class="metadata-pagination">
{% include 'dashboard/paginator/group-user-management-paginate.html' %}
</div>
</div>
</div>
<button type="submit" class="btn btn-success">提交修改</button>
</form>
</div>
</div>
</div>

View File

@ -90,16 +90,16 @@
</div>
</label>
</div>
<div class="form-group">
<label class="form-label" for="status">状态</label>
<div class="controls">
<select class="form-control" name="status">
{% for w in douyin_status_choices_list %}
<option value="{{ w }}">{{ w }}</option>
{% endfor %}
</select>
</div>
</div>
{# <div class="form-group">#}
{# <label class="form-label" for="status">状态</label>#}
{# <div class="controls">#}
{# <select class="form-control" name="status">#}
{# {% for w in douyin_status_choices_list %}#}
{# <option value="{{ w }}">{{ w }}</option>#}
{# {% endfor %}#}
{# </select>#}
{# </div>#}
{# </div>#}
<div class="form-group">
<label class="form-label" for="identificationcode">新媒体标识码</label>
<div class="controls">

View File

@ -96,16 +96,16 @@
</div>
</label>
</div>
<div class="form-group">
<label class="form-label" for="status">状态</label>
<div class="controls">
<select class="form-control" name="status">
{% for w in qita_status_choices_list %}
<option value="{{ w }}">{{ w }}</option>
{% endfor %}
</select>
</div>
</div>
{# <div class="form-group">#}
{# <label class="form-label" for="status">状态</label>#}
{# <div class="controls">#}
{# <select class="form-control" name="status">#}
{# {% for w in qita_status_choices_list %}#}
{# <option value="{{ w }}">{{ w }}</option>#}
{# {% endfor %}#}
{# </select>#}
{# </div>#}
{# </div>#}
<div class="form-group">
<label class="form-label" for="identificationcode">新媒体标识码</label>
<div class="controls">

View File

@ -90,16 +90,16 @@
</div>
</label>
</div>
<div class="form-group">
<label class="form-label" for="status">状态</label>
<div class="controls">
<select class="form-control" name="status">
{% for w in toutiao_status_choices_list %}
<option value="{{ w }}">{{ w }}</option>
{% endfor %}
</select>
</div>
</div>
{# <div class="form-group">#}
{# <label class="form-label" for="status">状态</label>#}
{# <div class="controls">#}
{# <select class="form-control" name="status">#}
{# {% for w in toutiao_status_choices_list %}#}
{# <option value="{{ w }}">{{ w }}</option>#}
{# {% endfor %}#}
{# </select>#}
{# </div>#}
{# </div>#}
<div class="form-group">
<label class="form-label" for="identificationcode">新媒体标识码</label>
<div class="controls">

View File

@ -90,16 +90,16 @@
</div>
</label>
</div>
<div class="form-group">
<label class="form-label" for="status">状态</label>
<div class="controls">
<select class="form-control" name="status">
{% for w in weibo_status_choices_list %}
<option value="{{ w }}">{{ w }}</option>
{% endfor %}
</select>
</div>
</div>
{# <div class="form-group">#}
{# <label class="form-label" for="status">状态</label>#}
{# <div class="controls">#}
{# <select class="form-control" name="status">#}
{# {% for w in weibo_status_choices_list %}#}
{# <option value="{{ w }}">{{ w }}</option>#}
{# {% endfor %}#}
{# </select>#}
{# </div>#}
{# </div>#}
<div class="form-group">
<label class="form-label" for="identificationcode">新媒体标识码</label>
<div class="controls">

View File

@ -90,16 +90,16 @@
</div>
</label>
</div>
<div class="form-group">
<label class="form-label" for="status">状态</label>
<div class="controls">
<select class="form-control" name="status">
{% for w in weixin_status_choices_list %}
<option value="{{ w }}">{{ w }}</option>
{% endfor %}
</select>
</div>
</div>
{# <div class="form-group">#}
{# <label class="form-label" for="status">状态</label>#}
{# <div class="controls">#}
{# <select class="form-control" name="status">#}
{# {% for w in weixin_status_choices_list %}#}
{# <option value="{{ w }}">{{ w }}</option>#}
{# {% endfor %}#}
{# </select>#}
{# </div>#}
{# </div>#}
<div class="form-group">
<label class="form-label" for="identificationcode">新媒体标识码</label>
<div class="controls">

View File

@ -97,17 +97,17 @@
</div>
</label>
</div>
<div class="form-group">
<label class="form-label" for="status">状态</label>
<div class="controls">
<select class="form-control" name="status">
<option value="{{ douyin.status }}">{{ douyin.status }}</option>
{% for w in douyin_status_choices_list %}
<option value="{{ w }}">{{ w }}</option>
{% endfor %}
</select>
</div>
</div>
{# <div class="form-group">#}
{# <label class="form-label" for="status">状态</label>#}
{# <div class="controls">#}
{# <select class="form-control" name="status">#}
{# <option value="{{ douyin.status }}">{{ douyin.status }}</option>#}
{# {% for w in douyin_status_choices_list %}#}
{# <option value="{{ w }}">{{ w }}</option>#}
{# {% endfor %}#}
{# </select>#}
{# </div>#}
{# </div>#}
<div class="form-group">
<label class="form-label" for="identificationcode">新媒体标识码</label>
<div class="controls">

View File

@ -104,17 +104,17 @@
</div>
</label>
</div>
<div class="form-group">
<label class="form-label" for="status">状态</label>
<div class="controls">
<select class="form-control" name="status">
<option value="{{ qita.status }}">{{ qita.status }}</option>
{% for w in qita_status_choices_list %}
<option value="{{ w }}">{{ w }}</option>
{% endfor %}
</select>
</div>
</div>
{# <div class="form-group">#}
{# <label class="form-label" for="status">状态</label>#}
{# <div class="controls">#}
{# <select class="form-control" name="status">#}
{# <option value="{{ qita.status }}">{{ qita.status }}</option>#}
{# {% for w in qita_status_choices_list %}#}
{# <option value="{{ w }}">{{ w }}</option>#}
{# {% endfor %}#}
{# </select>#}
{# </div>#}
{# </div>#}
<div class="form-group">
<label class="form-label" for="identificationcode">新媒体标识码</label>
<div class="controls">

View File

@ -97,17 +97,17 @@
</div>
</label>
</div>
<div class="form-group">
<label class="form-label" for="status">状态</label>
<div class="controls">
<select class="form-control" name="status">
<option value="{{ toutiao.status }}">{{ toutiao.status }}</option>
{% for w in toutiao_status_choices_list %}
<option value="{{ w }}">{{ w }}</option>
{% endfor %}
</select>
</div>
</div>
{# <div class="form-group">#}
{# <label class="form-label" for="status">状态</label>#}
{# <div class="controls">#}
{# <select class="form-control" name="status">#}
{# <option value="{{ toutiao.status }}">{{ toutiao.status }}</option>#}
{# {% for w in toutiao_status_choices_list %}#}
{# <option value="{{ w }}">{{ w }}</option>#}
{# {% endfor %}#}
{# </select>#}
{# </div>#}
{# </div>#}
<div class="form-group">
<label class="form-label" for="identificationcode">新媒体标识码</label>
<div class="controls">

View File

@ -97,17 +97,17 @@
</div>
</label>
</div>
<div class="form-group">
<label class="form-label" for="status">状态</label>
<div class="controls">
<select class="form-control" name="status">
<option value="{{ weibo.status }}">{{ weibo.status }}</option>
{% for w in weibo_status_choices_list %}
<option value="{{ w }}">{{ w }}</option>
{% endfor %}
</select>
</div>
</div>
{# <div class="form-group">#}
{# <label class="form-label" for="status">状态</label>#}
{# <div class="controls">#}
{# <select class="form-control" name="status">#}
{# <option value="{{ weibo.status }}">{{ weibo.status }}</option>#}
{# {% for w in weibo_status_choices_list %}#}
{# <option value="{{ w }}">{{ w }}</option>#}
{# {% endfor %}#}
{# </select>#}
{# </div>#}
{# </div>#}
<div class="form-group">
<label class="form-label" for="identificationcode">新媒体标识码</label>
<div class="controls">

View File

@ -97,17 +97,17 @@
</div>
</label>
</div>
<div class="form-group">
<label class="form-label" for="status">状态</label>
<div class="controls">
<select class="form-control" name="status">
<option value="{{ weixin.status }}">{{ weixin.status }}</option>
{% for w in weixin_status_choices_list %}
<option value="{{ w }}">{{ w }}</option>
{% endfor %}
</select>
</div>
</div>
{# <div class="form-group">#}
{# <label class="form-label" for="status">状态</label>#}
{# <div class="controls">#}
{# <select class="form-control" name="status">#}
{# <option value="{{ weixin.status }}">{{ weixin.status }}</option>#}
{# {% for w in weixin_status_choices_list %}#}
{# <option value="{{ w }}">{{ w }}</option>#}
{# {% endfor %}#}
{# </select>#}
{# </div>#}
{# </div>#}
<div class="form-group">
<label class="form-label" for="identificationcode">新媒体标识码</label>
<div class="controls">

View File

@ -78,9 +78,9 @@
{% endfor %}
</tbody>
</table>
{# <div class="metadata-pagination">#}
{# {% include 'dashboard/paginator/user-management-paginate.html' %}#}
{# </div>#}
<div class="metadata-pagination">
{% include 'dashboard/paginator/user-management-paginate.html' %}
</div>
</div>
</div>
</div>

View File

@ -16,6 +16,7 @@ urlpatterns = [
path('group/create/', views.group_create, name='group-management-create'),
path('group/update/<str:pk>/', views.group_update, name='group-management-update'),
path('group/delete/<str:pk>/', views.group_delete, name='group-management-delete'),
path('group/user/search/<str:pk>/', views.group_user_search, name='group-user-search'),
# 添加矩阵管理员、成员
path('get/user/', views.get_user, name='get-user'),

View File

@ -342,6 +342,14 @@ def group_update(request, pk):
o['administrativedivision'] = str(Area_code_2020.objects.get(code=str(admin_p)).name)
g_a_list.append(o)
group_user = Group_user.objects.filter(group_id=pk)
paginator = Paginator(group_user, 6)
page = int(request.GET.get('page', 1))
try:
group_user = paginator.page(page)
except PageNotAnInteger:
group_user = paginator.page(1)
except EmptyPage:
group_user = paginator.page(paginator.num_pages)
g_u_list = []
for g_u in group_user:
i = dict()
@ -426,7 +434,7 @@ def group_update(request, pk):
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, 'p': p, 'c': c, 'd': d, 't': t,
'v': v})
'v': v,'page':group_user})
@login_required
@ -648,6 +656,7 @@ def organization_management(request):
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:
print(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:
@ -1834,3 +1843,115 @@ def newmedia_detail_weixin(request, pk):
weixin = Weixin.objects.all().order_by('-created')
return render(request, 'management/newmedia-detail-weixin.html', {'weixin': weixin})
@login_required
def group_user_search(request,pk):
keyword = request.POST.get('keyword')
group = Group.objects.get(id=pk)
p = ''
c = ''
d = ''
t = ''
v = ''
if group.province != '' and group.province != 'None':
p = Area_code_2020.objects.get(code=group.province).name
if group.cities and group.cities != 'None':
c = Area_code_2020.objects.get(code=group.cities).name
if group.district and group.district != 'None':
d = Area_code_2020.objects.get(code=group.district).name
if group.town and group.town != 'None':
t = Area_code_2020.objects.get(code=group.town).name
if group.village and group.village != 'None':
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)
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)[0], list(g_c_c)[1]])
group_type = Group_type.objects.all()
group_admin = Group_admin.objects.filter(group_id=pk)
g_a_list = []
for g_a in group_admin:
o = dict()
o['id'] = str(g_a.id)
if Userprofile.objects.get(user_id=g_a.user.id):
o['image'] = Userprofile.objects.get(user_id=g_a.user.id).image.url
o['username'] = g_a.user.username
o['name'] = Userprofile.objects.get(user_id=g_a.user.id).name
o['organization'] = Userprofile.objects.get(user_id=g_a.user.id).organization.name
admin_p = Userprofile.objects.get(user_id=g_a.user_id).organization.province
admin_c = Userprofile.objects.get(user_id=g_a.user_id).organization.cities
admin_d = Userprofile.objects.get(user_id=g_a.user_id).organization.district
admin_t = Userprofile.objects.get(user_id=g_a.user_id).organization.town
admin_v = Userprofile.objects.get(user_id=g_a.user_id).organization.village
if admin_p and admin_p != 'None' and admin_c and admin_c != 'None' and admin_d and admin_d != 'None' and admin_t and admin_t != 'None' and admin_v and admin_v != 'None':
o['administrativedivision'] = str(Area_code_2020.objects.get(code=admin_p).name) + '-' + str(
Area_code_2020.objects.get(code=admin_c).name) + '-' + str(
Area_code_2020.objects.get(code=admin_d).name) + '-' + str(
Area_code_2020.objects.get(code=admin_t).name) + '-' + str(
Area_code_2020.objects.get(code=admin_v).name)
elif admin_p and admin_p != 'None' and admin_c and admin_c != 'None' and admin_d and admin_d != 'None' and admin_t and admin_t != 'None':
o['administrativedivision'] = str(Area_code_2020.objects.get(code=admin_p).name) + '-' + str(
Area_code_2020.objects.get(code=admin_c).name) + '-' + str(
Area_code_2020.objects.get(code=admin_d).name) + '-' + str(
Area_code_2020.objects.get(code=admin_t).name)
elif admin_p and admin_p != 'None' and admin_c and admin_c != 'None' and admin_d and admin_d != 'None':
o['administrativedivision'] = str(Area_code_2020.objects.get(code=admin_p).name) + '-' + str(
Area_code_2020.objects.get(code=admin_c).name) + '-' + str(
Area_code_2020.objects.get(code=admin_d).name)
elif admin_p and admin_p != 'None' and admin_c and admin_c != 'None':
o['administrativedivision'] = str(Area_code_2020.objects.get(code=admin_p).name) + '-' + str(
Area_code_2020.objects.get(code=admin_c).name)
elif admin_p and admin_p != 'None':
o['administrativedivision'] = str(Area_code_2020.objects.get(code=str(admin_p)).name)
g_a_list.append(o)
group_user = Group_user.objects.filter(group_id=pk,user__userprofile__name__contains=keyword)
paginator = Paginator(group_user, 6)
page = int(request.GET.get('page', 1))
try:
group_user = paginator.page(page)
except PageNotAnInteger:
group_user = paginator.page(1)
except EmptyPage:
group_user = paginator.page(paginator.num_pages)
g_u_list = []
for g_u in group_user:
i = dict()
i['id'] = str(g_u.id)
i['image'] = Userprofile.objects.get(user_id=g_u.user.id).image.url
i['username'] = g_u.user.username
i['name'] = Userprofile.objects.get(user_id=g_u.user.id).name
i['organization'] = Userprofile.objects.get(user_id=g_u.user.id).organization.name
user_p = Userprofile.objects.get(user_id=g_u.user_id).organization.province
user_c = Userprofile.objects.get(user_id=g_u.user_id).organization.cities
user_d = Userprofile.objects.get(user_id=g_u.user_id).organization.district
user_t = Userprofile.objects.get(user_id=g_u.user_id).organization.town
user_v = Userprofile.objects.get(user_id=g_u.user_id).organization.village
if user_p and user_p != 'None' and user_c and user_c != 'None' and user_d and user_d != 'None' and user_t and user_t != 'None' and user_v and user_v != 'None':
i['administrativedivision'] = str(Area_code_2020.objects.get(code=user_p).name) + '-' + str(
Area_code_2020.objects.get(code=user_c).name) + '-' + str(
Area_code_2020.objects.get(code=user_d).name) + '-' + str(
Area_code_2020.objects.get(code=user_t).name) + '-' + str(
Area_code_2020.objects.get(code=user_v).name)
elif user_p and user_p != 'None' and user_c and user_c != 'None' and user_d and user_d != 'None' and user_t and user_t != 'None':
i['administrativedivision'] = str(Area_code_2020.objects.get(code=user_p).name) + '-' + str(
Area_code_2020.objects.get(code=user_c).name) + '-' + str(
Area_code_2020.objects.get(code=user_d).name) + '-' + str(
Area_code_2020.objects.get(code=user_t).name)
elif user_p and user_p != 'None' and user_c and user_c != 'None' and user_d and user_d != 'None':
i['administrativedivision'] = str(Area_code_2020.objects.get(code=user_p).name) + '-' + str(
Area_code_2020.objects.get(code=user_c).name) + '-' + str(
Area_code_2020.objects.get(code=user_d).name)
elif user_p and user_p != 'None' and user_c and user_c != 'None':
i['administrativedivision'] = str(Area_code_2020.objects.get(code=user_p).name) + '-' + str(
Area_code_2020.objects.get(code=user_c).name)
elif user_p and user_p != 'None':
i['administrativedivision'] = str(Area_code_2020.objects.get(code=str(user_p)).name)
g_u_list.append(i)
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, 'p': p, 'c': c, 'd': d, 't': t,
'v': v, 'page': group_user})

View File

@ -24,9 +24,9 @@ import pandas as pd
@login_required
def new_media_public_opinion_weixin(request):
weixin = Weixin.objects.all()
# weixin = Weixin.objects.all()
group = Group.objects.all()
weixin_data = Weixin_data.objects.all()
weixin_data = Weixin_data.objects.all()[:10]
res = []
for w in weixin_data:
o = dict()
@ -40,14 +40,14 @@ def new_media_public_opinion_weixin(request):
o['link'] = w.link
res.append(o)
return render(request, 'monitor/new-media-public-opinion-weixin.html',
{'res': res, 'weixin': weixin, 'group': group})
{'res': res, 'group': group})
@login_required
def new_media_public_opinion_toutiao(request):
toutiao = Toutiao.objects.all()
# toutiao = Toutiao.objects.all()
group = Group.objects.all()
toutiao_data = Toutiao_data.objects.all().order_by('-likenum')
toutiao_data = Toutiao_data.objects.all().order_by('-likenum')[:10]
res = []
for t in toutiao_data:
o = dict()
@ -55,22 +55,21 @@ def new_media_public_opinion_toutiao(request):
o['code'] = t.toutiao.code
o['image'] = t.toutiao.image
o['title'] = t.title
o['count'] = t.count
o['commentcount'] = t.commentcount
o['reply'] = t.reply
o['year'] = t.year
o['month'] = t.month
o['day'] = t.day
o['readnum'] = t.readnum
o['likenum'] = t.likenum
o['shownum'] = t.shownum
o['celltype'] = t.celltype
res.append(o)
return render(request, 'monitor/new-media-public-opinion-toutiao.html',
{'res': res, 'toutiao': toutiao, 'group': group})
{'res': res, 'group': group})
@login_required
def new_media_public_opinion_douyin(request):
douyin = Douyin.objects.all()
# douyin = Douyin.objects.all()
group = Group.objects.all()
douyin_data = Douyin_data.objects.all().order_by('-comment')
douyin_data = Douyin_data.objects.all().order_by('-comment')[:10]
res = []
for d in douyin_data:
o = dict()
@ -84,14 +83,14 @@ def new_media_public_opinion_douyin(request):
o['date'] = d.date
res.append(o)
return render(request, 'monitor/new-media-public-opinion-douyin.html',
{'res': res, 'douyin': douyin, 'group': group})
{'res': res, 'group': group})
@login_required
def new_media_public_opinion_weibo(request):
weibo = Weibo.objects.all()
# weibo = Weibo.objects.all()
group = Group.objects.all()
weibo_data = Weibo_data.objects.all().order_by('-like')
weibo_data = Weibo_data.objects.all().order_by('-like')[:10]
res = []
for w in weibo_data:
o = dict()
@ -106,14 +105,14 @@ def new_media_public_opinion_weibo(request):
o['month'] = w.month
o['day'] = w.day
res.append(o)
return render(request, 'monitor/new-media-public-opinion-weibo.html', {'res': res, 'weibo': weibo, 'group': group})
return render(request, 'monitor/new-media-public-opinion-weibo.html', {'res': res,'group': group})
@login_required
def new_media_public_opinion_qita(request):
qita = Qita.objects.all()
# qita = Qita.objects.all()
group = Group.objects.all()
qita_jc = Qita_jc.objects.all().order_by('-comment')
qita_jc = Qita_jc.objects.all().order_by('-comment')[:10]
res = []
for q in qita_jc:
o = dict()
@ -129,7 +128,7 @@ def new_media_public_opinion_qita(request):
o['month'] = q.month
o['day'] = q.day
res.append(o)
return render(request, 'monitor/new-media-public-opinion-qita.html', {'res': res, 'qita': qita, 'group': group})
return render(request, 'monitor/new-media-public-opinion-qita.html', {'res': res, 'group': group})
@login_required
@ -768,7 +767,6 @@ def timeliness_monitoring_json(request):
int(TimelinessMonitoring.objects.filter(city='622900000000', date=d.date, results='合格').count()) / int(
TimelinessMonitoring.objects.filter(city='622900000000', date=d.date).count()), 2) * 100)
print(lanzhou_YIELD)
return HttpResponse(json.dumps({
"status": "1",
"lanzhou": lanzhou,