#add message

This commit is contained in:
xieshen 2021-01-14 15:18:50 +08:00
parent 9ef5c9973a
commit 519eadff57
1 changed files with 91 additions and 65 deletions

View File

@ -29,11 +29,11 @@ def user_management(request):
userpaginator = Userprofile.objects.filter(organization__province=province).order_by('-created') userpaginator = Userprofile.objects.filter(organization__province=province).order_by('-created')
elif level == 2: elif level == 2:
userpaginator = Userprofile.objects.filter(organization__province=province, userpaginator = Userprofile.objects.filter(organization__province=province,
organization__cities=cities).order_by('-created') organization__cities=cities).order_by('-created')
elif level == 3: elif level == 3:
userpaginator = Userprofile.objects.filter(organization__province=province, userpaginator = Userprofile.objects.filter(organization__province=province,
organization__cities=cities, organization__cities=cities,
organization__district=district).order_by('-created') organization__district=district).order_by('-created')
elif level == 9: elif level == 9:
userpaginator = Userprofile.objects.all().order_by('-created') userpaginator = Userprofile.objects.all().order_by('-created')
userallinfo = [] userallinfo = []
@ -96,7 +96,7 @@ def user_management(request):
'None', '') 'None', '')
userallinfo.append(o) userallinfo.append(o)
return render(request, 'management/user-management.html', return render(request, 'management/user-management.html',
{'userallinfo': userallinfo, 'userpaginator': userpaginator,'user_count':user_count}) {'userallinfo': userallinfo, 'userpaginator': userpaginator, 'user_count': user_count})
@login_required @login_required
@ -155,7 +155,6 @@ def user_update(request, pk):
@login_required @login_required
def group_management_init(request): def group_management_init(request):
user = request.user user = request.user
level = Userprofile.objects.get(user_id=user.id).organization.level.level level = Userprofile.objects.get(user_id=user.id).organization.level.level
init_count = Group.objects.filter(user_id=user.id).count() init_count = Group.objects.filter(user_id=user.id).count()
@ -180,7 +179,8 @@ def group_management_init(request):
o1['user_count'] = Group_user.objects.filter(group_id=r_g_i.id).count() o1['user_count'] = Group_user.objects.filter(group_id=r_g_i.id).count()
o1['status'] = r_g_i.status o1['status'] = r_g_i.status
res_g_i.append(o1) res_g_i.append(o1)
return render(request, 'management/group-management-init.html', {'group': group, 'res_g_i': res_g_i,'init_count':init_count,'level':level}) return render(request, 'management/group-management-init.html',
{'group': group, 'res_g_i': res_g_i, 'init_count': init_count, 'level': level})
@login_required @login_required
@ -212,7 +212,8 @@ def group_management_admin(request):
o2['user_count'] = Group_user.objects.filter(group_id=r_g_a.id).count() o2['user_count'] = Group_user.objects.filter(group_id=r_g_a.id).count()
o2['status'] = r_g_a.status o2['status'] = r_g_a.status
res_g_a.append(o2) res_g_a.append(o2)
return render(request, 'management/group-management-admin.html', {'group': group, 'res_g_a': res_g_a,'admin_count':admin_count,'level':level}) return render(request, 'management/group-management-admin.html',
{'group': group, 'res_g_a': res_g_a, 'admin_count': admin_count, 'level': level})
@login_required @login_required
@ -244,10 +245,12 @@ def group_management_user(request):
o3['user_count'] = Group_user.objects.filter(group_id=r_g_u.id).count() o3['user_count'] = Group_user.objects.filter(group_id=r_g_u.id).count()
o3['status'] = r_g_u.status o3['status'] = r_g_u.status
res_g_u.append(o3) res_g_u.append(o3)
return render(request, 'management/group-management-user.html', {'group': group, 'res_g_u': res_g_u,'user_count':user_count,'level':level}) return render(request, 'management/group-management-user.html',
{'group': group, 'res_g_u': res_g_u, 'user_count': user_count, 'level': level})
@login_required @login_required
def group_management_superuser(request): def group_management_superuser(request):
user = request.user user = request.user
level = Userprofile.objects.get(user_id=user.id).organization.level.level level = Userprofile.objects.get(user_id=user.id).organization.level.level
count = Group.objects.all().count() count = Group.objects.all().count()
@ -271,7 +274,8 @@ def group_management_superuser(request):
o1['user_count'] = Group_user.objects.filter(group_id=r_g_i.id).count() o1['user_count'] = Group_user.objects.filter(group_id=r_g_i.id).count()
o1['status'] = r_g_i.status o1['status'] = r_g_i.status
res_g_i.append(o1) res_g_i.append(o1)
return render(request, 'management/group-management-superuser.html', {'group': group, 'res_g_i': res_g_i,'count':count,'level':level}) return render(request, 'management/group-management-superuser.html',
{'group': group, 'res_g_i': res_g_i, 'count': count, 'level': level})
@login_required @login_required
@ -282,13 +286,13 @@ def group_update(request, pk):
d = '' d = ''
t = '' t = ''
v = '' v = ''
if group.province != '' and group.province != 'None' : if group.province != '' and group.province != 'None':
p = Area_code_2020.objects.get(code=group.province).name p = Area_code_2020.objects.get(code=group.province).name
if group.cities and group.cities != 'None': if group.cities and group.cities != 'None':
c = Area_code_2020.objects.get(code=group.cities).name c = Area_code_2020.objects.get(code=group.cities).name
if group.district and group.district != 'None': if group.district and group.district != 'None':
d = Area_code_2020.objects.get(code=group.district).name d = Area_code_2020.objects.get(code=group.district).name
if group.town and group.town != 'None' : if group.town and group.town != 'None':
t = Area_code_2020.objects.get(code=group.town).name t = Area_code_2020.objects.get(code=group.town).name
if group.village and group.village != 'None': if group.village and group.village != 'None':
v = Area_code_2020.objects.get(code=group.village).name v = Area_code_2020.objects.get(code=group.village).name
@ -310,26 +314,32 @@ def group_update(request, pk):
o['username'] = g_a.user.username o['username'] = g_a.user.username
o['name'] = Userprofile.objects.get(user_id=g_a.user.id).name 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 o['organization'] = Userprofile.objects.get(user_id=g_a.user.id).organization.name
if g_a.group.province and g_a.group.province != 'None' and g_a.group.cities and g_a.group.cities != 'None' and g_a.group.district and g_a.group.district != 'None' and g_a.group.town and g_a.group.town != 'None' and g_a.group.village and g_a.group.village != 'None':
o['administrativedivision'] = str(Area_code_2020.objects.get(code=g_a.group.province).name) + '-' + str( admin_p = Userprofile.objects.get(user_id=g_a.user_id).organization.province
Area_code_2020.objects.get(code=g_a.group.cities).name) + '-' + str( admin_c = Userprofile.objects.get(user_id=g_a.user_id).organization.cities
Area_code_2020.objects.get(code=g_a.group.district).name) + '-' + str( admin_d = Userprofile.objects.get(user_id=g_a.user_id).organization.district
Area_code_2020.objects.get(code=g_a.group.town).name) + '-' + str( admin_t = Userprofile.objects.get(user_id=g_a.user_id).organization.town
Area_code_2020.objects.get(code=g_a.group.village).name) admin_v = Userprofile.objects.get(user_id=g_a.user_id).organization.village
elif g_a.group.province and g_a.group.province != 'None' and g_a.group.cities and g_a.group.cities != 'None' and g_a.group.district and g_a.group.district != 'None' and g_a.group.town and g_a.group.town != 'None': 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=g_a.group.province).name) + '-' + str( o['administrativedivision'] = str(Area_code_2020.objects.get(code=admin_p).name) + '-' + str(
Area_code_2020.objects.get(code=g_a.group.cities).name) + '-' + str( Area_code_2020.objects.get(code=admin_c).name) + '-' + str(
Area_code_2020.objects.get(code=g_a.group.district).name) + '-' + str( Area_code_2020.objects.get(code=admin_d).name) + '-' + str(
Area_code_2020.objects.get(code=g_a.group.town).name) Area_code_2020.objects.get(code=admin_t).name) + '-' + str(
elif g_a.group.province and g_a.group.province != 'None' and g_a.group.cities and g_a.group.cities != 'None' and g_a.group.district and g_a.group.district != 'None': Area_code_2020.objects.get(code=admin_v).name)
o['administrativedivision'] = str(Area_code_2020.objects.get(code=g_a.group.province).name) + '-' + str( 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':
Area_code_2020.objects.get(code=g_a.group.cities).name) + '-' + str( o['administrativedivision'] = str(Area_code_2020.objects.get(code=admin_p).name) + '-' + str(
Area_code_2020.objects.get(code=g_a.group.district).name) Area_code_2020.objects.get(code=admin_c).name) + '-' + str(
elif g_a.group.province and g_a.group.province != 'None' and g_a.group.cities and g_a.group.cities != 'None': Area_code_2020.objects.get(code=admin_d).name) + '-' + str(
o['administrativedivision'] = str(Area_code_2020.objects.get(code=g_a.group.province).name) + '-' + str( Area_code_2020.objects.get(code=admin_t).name)
Area_code_2020.objects.get(code=g_a.group.cities).name) elif admin_p and admin_p != 'None' and admin_c and admin_c != 'None' and admin_d and admin_d != 'None':
elif g_a.group.province and g_a.group.province != 'None': o['administrativedivision'] = str(Area_code_2020.objects.get(code=admin_p).name) + '-' + str(
o['administrativedivision'] = str(Area_code_2020.objects.get(code=g_a.group.province).name) 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) g_a_list.append(o)
group_user = Group_user.objects.filter(group_id=pk) group_user = Group_user.objects.filter(group_id=pk)
g_u_list = [] g_u_list = []
@ -340,26 +350,31 @@ def group_update(request, pk):
i['username'] = g_u.user.username i['username'] = g_u.user.username
i['name'] = Userprofile.objects.get(user_id=g_u.user.id).name 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 i['organization'] = Userprofile.objects.get(user_id=g_u.user.id).organization.name
if g_u.group.province and g_u.group.province != 'None' and g_u.group.cities and g_u.group.cities != 'None' and g_u.group.district and g_u.group.district != 'None' and g_u.group.town and g_u.group.town != 'None' and g_u.group.village and g_u.group.village != 'None': user_p = Userprofile.objects.get(user_id=g_u.user_id).organization.province
i['administrativedivision'] = str(Area_code_2020.objects.get(code=g_u.group.province).name) + '-' + str( user_c = Userprofile.objects.get(user_id=g_u.user_id).organization.cities
Area_code_2020.objects.get(code=g_u.group.cities).name) + '-' + str( user_d = Userprofile.objects.get(user_id=g_u.user_id).organization.district
Area_code_2020.objects.get(code=g_u.group.district).name) + '-' + str( user_t = Userprofile.objects.get(user_id=g_u.user_id).organization.town
Area_code_2020.objects.get(code=g_u.group.town).name) + '-' + str( user_v = Userprofile.objects.get(user_id=g_u.user_id).organization.village
Area_code_2020.objects.get(code=g_u.group.village).name) 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':
elif g_u.group.province and g_u.group.province != 'None' and g_u.group.cities and g_u.group.cities != 'None' and g_u.group.district and g_u.group.district != 'None' and g_u.group.town and g_u.group.town != 'None': i['administrativedivision'] = str(Area_code_2020.objects.get(code=user_p).name) + '-' + str(
i['administrativedivision'] = str(Area_code_2020.objects.get(code=g_u.group.province).name) + '-' + str( Area_code_2020.objects.get(code=user_c).name) + '-' + str(
Area_code_2020.objects.get(code=g_u.group.cities).name) + '-' + str( Area_code_2020.objects.get(code=user_d).name) + '-' + str(
Area_code_2020.objects.get(code=g_u.group.district).name) + '-' + str( Area_code_2020.objects.get(code=user_t).name) + '-' + str(
Area_code_2020.objects.get(code=g_u.group.town).name) Area_code_2020.objects.get(code=user_v).name)
elif g_u.group.province and g_u.group.province != 'None' and g_u.group.cities and g_u.group.cities != 'None' and g_u.group.district and g_u.group.district != 'None': 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=g_u.group.province).name) + '-' + str( i['administrativedivision'] = str(Area_code_2020.objects.get(code=user_p).name) + '-' + str(
Area_code_2020.objects.get(code=g_u.group.cities).name) + '-' + str( Area_code_2020.objects.get(code=user_c).name) + '-' + str(
Area_code_2020.objects.get(code=g_u.group.district).name) Area_code_2020.objects.get(code=user_d).name) + '-' + str(
elif g_u.group.province and g_u.group.province != 'None' and g_u.group.cities and g_u.group.cities != 'None': Area_code_2020.objects.get(code=user_t).name)
i['administrativedivision'] = str(Area_code_2020.objects.get(code=g_u.group.province).name) + '-' + str( elif user_p and user_p != 'None' and user_c and user_c != 'None' and user_d and user_d != 'None':
Area_code_2020.objects.get(code=g_u.group.cities).name) i['administrativedivision'] = str(Area_code_2020.objects.get(code=user_p).name) + '-' + str(
elif g_u.group.province and g_u.group.province != 'None': Area_code_2020.objects.get(code=user_c).name) + '-' + str(
i['administrativedivision'] = str(Area_code_2020.objects.get(code=g_u.group.province).name) 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) g_u_list.append(i)
if request.method == 'POST': if request.method == 'POST':
name = request.POST.get('name') name = request.POST.get('name')
@ -492,6 +507,7 @@ def group_create(request):
{'group_status_choices_list': group_status_choices_list, 'group_type': group_type, {'group_status_choices_list': group_status_choices_list, 'group_type': group_type,
'g_c_c_res': g_c_c_res}) 'g_c_c_res': g_c_c_res})
@login_required @login_required
def get_user(request): def get_user(request):
keywords = request.GET.get('keyword') keywords = request.GET.get('keyword')
@ -530,7 +546,7 @@ def group_admin_create(request, pk):
messages.success(request, "添加成功") messages.success(request, "添加成功")
return HttpResponseRedirect('/management/group/update/%s/' % (pk)) return HttpResponseRedirect('/management/group/update/%s/' % (pk))
group = Group.objects.get(id=pk).name group = Group.objects.get(id=pk).name
return render(request, 'management/group-admin-create.html', { 'group': group, 'pk': pk}) return render(request, 'management/group-admin-create.html', {'group': group, 'pk': pk})
@login_required @login_required
@ -643,7 +659,8 @@ def organization_management(request):
organization_id=i.id).count() organization_id=i.id).count()
res.append(o) res.append(o)
return render(request, 'management/organization-management.html', {"organization": organization, 'res': res,'organization_count':organization_count}) return render(request, 'management/organization-management.html',
{"organization": organization, 'res': res, 'organization_count': organization_count})
@login_required @login_required
@ -1072,7 +1089,8 @@ def newmedia_management_edit_weixin(request):
o['administrativedivision'] = str(Area_code_2020.objects.get(code=w.organization.province).name) o['administrativedivision'] = str(Area_code_2020.objects.get(code=w.organization.province).name)
o['status'] = w.status o['status'] = w.status
res.append(o) res.append(o)
return render(request, 'management/newmedia-management-edit-weixin.html', {'weixin': weixin, 'res': res,'weixin_count':weixin_count}) return render(request, 'management/newmedia-management-edit-weixin.html',
{'weixin': weixin, 'res': res, 'weixin_count': weixin_count})
@login_required @login_required
@ -1142,7 +1160,8 @@ def newmedia_management_edit_weibo(request):
o['administrativedivision'] = str(Area_code_2020.objects.get(code=w.organization.province).name) o['administrativedivision'] = str(Area_code_2020.objects.get(code=w.organization.province).name)
o['status'] = w.status o['status'] = w.status
res.append(o) res.append(o)
return render(request, 'management/newmedia-management-edit-weibo.html', {'weibo': weibo, 'res': res,'weibo_count':weibo_count}) return render(request, 'management/newmedia-management-edit-weibo.html',
{'weibo': weibo, 'res': res, 'weibo_count': weibo_count})
@login_required @login_required
@ -1213,7 +1232,8 @@ def newmedia_management_edit_toutiao(request):
o['administrativedivision'] = str(Area_code_2020.objects.get(code=w.organization.province).name) o['administrativedivision'] = str(Area_code_2020.objects.get(code=w.organization.province).name)
o['status'] = w.status o['status'] = w.status
res.append(o) res.append(o)
return render(request, 'management/newmedia-management-edit-toutiao.html', {'toutiao': toutiao, 'res': res,'toutiao_count':toutiao_count}) return render(request, 'management/newmedia-management-edit-toutiao.html',
{'toutiao': toutiao, 'res': res, 'toutiao_count': toutiao_count})
@login_required @login_required
@ -1284,7 +1304,8 @@ def newmedia_management_edit_douyin(request):
o['administrativedivision'] = str(Area_code_2020.objects.get(code=w.organization.province).name) o['administrativedivision'] = str(Area_code_2020.objects.get(code=w.organization.province).name)
o['status'] = w.status o['status'] = w.status
res.append(o) res.append(o)
return render(request, 'management/newmedia-management-edit-douyin.html', {'douyin': douyin, 'res': res,'douyin_count':douyin_count}) return render(request, 'management/newmedia-management-edit-douyin.html',
{'douyin': douyin, 'res': res, 'douyin_count': douyin_count})
@login_required @login_required
@ -1354,7 +1375,8 @@ def newmedia_management_edit_qita(request):
o['administrativedivision'] = str(Area_code_2020.objects.get(code=w.organization.province).name) o['administrativedivision'] = str(Area_code_2020.objects.get(code=w.organization.province).name)
o['status'] = w.status o['status'] = w.status
res.append(o) res.append(o)
return render(request, 'management/newmedia-management-edit-qita.html', {'qita': qita, 'res': res,'qita_count':qita_count}) return render(request, 'management/newmedia-management-edit-qita.html',
{'qita': qita, 'res': res, 'qita_count': qita_count})
@login_required @login_required
@ -1687,7 +1709,8 @@ def new_management(request):
elif n.type == '6': elif n.type == '6':
o['type'] = '重点新闻' o['type'] = '重点新闻'
news_list.append(o) news_list.append(o)
return render(request, 'management/news-management.html', {'news': news_list, 'new': news,'news_count':news_count}) return render(request, 'management/news-management.html',
{'news': news_list, 'new': news, 'news_count': news_count})
@login_required @login_required
@ -1735,8 +1758,10 @@ def news_management_create(request):
o['choices'] = list(i)[1] o['choices'] = list(i)[1]
results.append(o) results.append(o)
return render(request, 'management/news-management-create.html', {'type': results}) return render(request, 'management/news-management-create.html', {'type': results})
@login_required @login_required
def news_management_update(request,pk): def news_management_update(request, pk):
news = News.objects.get(id=pk) news = News.objects.get(id=pk)
type = News.NEWMEDIA_NEWS_CHOICES type = News.NEWMEDIA_NEWS_CHOICES
results = [] results = []
@ -1772,8 +1797,8 @@ def news_management_update(request,pk):
n = News.objects.get(id=pk) n = News.objects.get(id=pk)
if request.POST.get('date'): if request.POST.get('date'):
date = request.POST.get('date') date = request.POST.get('date')
News.objects.filter(id=pk).update(type=t, title=title, author=author, date=date, content=content, source=source) News.objects.filter(id=pk).update(type=t, title=title, author=author, date=date, content=content,
source=source)
n.image = image n.image = image
n.save() n.save()
@ -1785,9 +1810,10 @@ def news_management_update(request,pk):
else: else:
News.objects.filter(id=pk).update(type=t, title=title, author=author, content=content, News.objects.filter(id=pk).update(type=t, title=title, author=author, content=content,
source=source) source=source)
messages.success(request,'编辑成功') messages.success(request, '编辑成功')
return HttpResponseRedirect('/management/news/management/') return HttpResponseRedirect('/management/news/management/')
return render(request,'management/news-management-update.html',{'news':news,'type':results}) return render(request, 'management/news-management-update.html', {'news': news, 'type': results})
@login_required @login_required
def news_management_detail(request, pk): def news_management_detail(request, pk):