diff --git a/backstage/templates/backstage/backstage-app-inform-management.html b/backstage/templates/backstage/backstage-app-inform-management.html new file mode 100644 index 0000000..2eba888 --- /dev/null +++ b/backstage/templates/backstage/backstage-app-inform-management.html @@ -0,0 +1,106 @@ +{% extends 'dashboard/base/base.html' %} +{% load static %} +{% block css %} + + +{% endblock %} +{% block content %} + +
+
+ {% include 'dashboard/base/left.html' %} +
+
+
+
+
+
+

用户通知管理

+
+
+
+
+
+
+

成员列表

+{#
{% csrf_token %}#} +{#
#} +{# #} +{#
#} +{#
#} +{#
#} +{# #} +{# #} +{# #} +{# #} +{#
#} +{#
#} +{#
#} +

成员总计:{{ user_count }}

+
+
+
+
+ + + + + + + + + + + + + + + {% for u in userallinfo %} + + + + + + + {# #} + + + + + {% endfor %} + +
序号头像姓名电话单位名称行政区划通知方式操作
{{ forloop.counter }}{{ u.name }}{{ u.phone }}{{ u.organization }}{{ u.type }}{{ u.administrativedivision }}短信通知 + 取消 + +
+ +
+
+
+
+
+
+
+
+
+
+ +{% endblock %} +{% block add_js %} + + + +{% endblock %} diff --git a/backstage/templates/backstage/backstage-weixin-update.html b/backstage/templates/backstage/backstage-weixin-update.html index 13903b0..9e98928 100644 --- a/backstage/templates/backstage/backstage-weixin-update.html +++ b/backstage/templates/backstage/backstage-weixin-update.html @@ -29,16 +29,208 @@
-
微信数据更新
+
微信数据对比(上传国办系统导出数据,可以获取数据对比结果)
{% csrf_token %} -{#
#} -{# #} -{# #} -{#
#} + {#
#} + {# #} + {# #} + {#
#} +
+ + +
+ +
+
+ {% for d in data_results %} + {{ d }} + {% endfor %} +
+
+ +
+
+ +
+ + +
+
+ {% if messages %} + + {% endif %} + +
+
+
+
+
+
微博数据对比(上传国办系统导出数据,可以获取数据对比结果)
+
+ +
{% csrf_token %} + {#
#} + {# #} + {# #} + {#
#} +
+ + +
+ +
+
+ {% for d in data_results %} + {{ d }} + {% endfor %} +
+
+ +
+
+ +
+ +
+
+
+ {% if messages %} + + {% endif %} + +
+
+
+
+
+
头条数据对比(上传国办系统导出数据,可以获取数据对比结果)
+
+ +
{% csrf_token %} + {#
#} + {# #} + {# #} + {#
#} +
+ + +
+ +
+
+ {% for d in data_results %} + {{ d }} + {% endfor %} +
+
+ +
+
+ +
+ +
+
+
+ {% if messages %} + + {% endif %} + +
+
+
+
+
+
抖音数据对比(上传国办系统导出数据,可以获取数据对比结果)
+
+ +
{% csrf_token %} + {#
#} + {# #} + {# #} + {#
#} +
+ + +
+ +
+
+ {% for d in data_results %} + {{ d }} + {% endfor %} +
+
+ +
+
+ +
+ +
+
+
+ {% if messages %} + + {% endif %} + +
+
+
+
+
+
其他数据对比(上传国办系统导出数据,可以获取数据对比结果)
+
+ +
{% csrf_token %} + {#
#} + {# #} + {# #} + {#
#}
diff --git a/backstage/urls.py b/backstage/urls.py index 9f01967..6a079c1 100644 --- a/backstage/urls.py +++ b/backstage/urls.py @@ -16,4 +16,6 @@ urlpatterns = [ path('backstage/toutiao/update/',views.backstage_toutiao_update,name='backstage-toutiao_update'), path('backstage/qita/update/',views.backstage_qita_update,name='backstage-qita_update'), path('backstage/add/unqualified/media/',views.add_unqualified_media,name='backstage-add-unqualified-media'), + path('backstage/app/inform/manage/',views.backstage_app_inform_manage,name='backstage-app-inform-manage'), + path('backstage/app/inform/delete//',views.backstage_app_inform_delete,name='backstage-app-inform-delete'), ] diff --git a/backstage/views.py b/backstage/views.py index e307c80..39d2fc3 100644 --- a/backstage/views.py +++ b/backstage/views.py @@ -6,6 +6,8 @@ from datetime import datetime import xlrd from django.contrib import messages +from django.contrib.auth.models import User +from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage from django.http import HttpResponse, HttpResponseRedirect, FileResponse from django.shortcuts import render @@ -14,7 +16,7 @@ from xlrd import xldate_as_tuple, xldate_as_datetime from NewMediaMonitoring import settings from dashboard.models import TimelinessMonitoring, Wrongly, Comment, Area_code_2020, Organization, Weixin, Douyin, \ - Weibo, Toutiao, Qita, NewMedia + Weibo, Toutiao, Qita, NewMedia, Userprofile from polls.models import UnqualifiedMedia @@ -121,7 +123,7 @@ def backstage_comment(request): comment.save() except: - print(v) + pass else: messages.error(request, '请上传正确的文件类型!!!') @@ -133,7 +135,6 @@ def backstage_user(request): return render(request, '') def backstage_organization_update(request): - print("____________________________________________________________________") data_results = [] if request.method == 'POST': o_code_list = [] @@ -210,7 +211,6 @@ def backstage_weixin_update(request): else: x['c'] = '异常' data_results.append(x) - print(data_results) return render(request, 'backstage/backstage-weixin-update.html', {'data_results': data_results}) def backstage_douyin_update(request): @@ -251,7 +251,6 @@ def backstage_douyin_update(request): else: x['c'] = '异常' data_results.append(x) - print(data_results) return render(request, 'backstage/backstage-douyin-update.html', {'data_results': data_results}) def backstage_weibo_update(request): @@ -292,7 +291,6 @@ def backstage_weibo_update(request): else: x['c'] = '异常' data_results.append(x) - print(data_results) return render(request, 'backstage/backstage-weibo-update.html', {'data_results': data_results}) def backstage_toutiao_update(request): @@ -333,7 +331,6 @@ def backstage_toutiao_update(request): else: x['c'] = '异常' data_results.append(x) - print(data_results) return render(request, 'backstage/backstage-toutiao-update.html', {'data_results': data_results}) def backstage_qita_update(request): @@ -374,7 +371,6 @@ def backstage_qita_update(request): else: x['c'] = '异常' data_results.append(x) - print(data_results) return render(request, 'backstage/backstage-toutiao-update.html', {'data_results': data_results}) def add_unqualified_media(request): @@ -400,7 +396,6 @@ def add_unqualified_media(request): unit = table.row_values(row)[1] media_id = None type = None - print(media_code) try: if "微信" in str(media_type): media_id = Weixin.objects.get(code=name).id @@ -441,7 +436,6 @@ def add_unqualified_media(request): unqualifiedmedia.save() except: pass - print(media_id) messages.success(request,"上传成功") return render(request,'backstage/backstage_add_unqualified_media.html') @@ -518,7 +512,6 @@ def backstage_data_download(request): o_qita['function'] = qt.function o_qita['articleurl'] = qt.articleurl results.append(o_qita) - # print(results) t = int(time.time()) os.popen('mkdir /var/www/p3/newmediamonitoring/static/upload') f = '/var/www/p3/newmediamonitoring/static/upload' @@ -526,7 +519,6 @@ def backstage_data_download(request): writer = csv.writer(csvfile) writer.writerow(["类型","名称", "单位", "别名", "状态", "ID", "关注量","新媒体标识码","功能","文章URL"]) for r in results: - # print(r['type']) writer.writerow([r['type'], r['code'], r['organization'],r['alias'], r['status'], r['id'], r['attention'],r['identificationcode'],r['function'], r['articleurl']]) file = open(f+'/'+user.username+'.csv','rb') response = FileResponse(file) @@ -534,5 +526,94 @@ def backstage_data_download(request): response['Content-Disposition'] = 'attachment;filename="data.csv"' return response +def backstage_app_inform_manage(request): + user_count = User.objects.all().count() + 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 + userpaginator = None + # if level == 1: + # userpaginator = Userprofile.objects.filter(organization__province=province).order_by('-created') + # elif level == 2: + # userpaginator = Userprofile.objects.filter(organization__province=province, + # organization__cities=cities).order_by('-created') + # elif level == 3: + # userpaginator = Userprofile.objects.filter(organization__province=province, + # organization__cities=cities, + # organization__district=district).order_by('-created') + if level == 9: + userpaginator = Userprofile.objects.filter(message_status=1).order_by('-created') + userallinfo = [] + if userpaginator is not None: + paginator = Paginator(userpaginator, 6) + page = int(request.GET.get('page', 1)) + try: + userpaginator = paginator.page(page) + except PageNotAnInteger: + userpaginator = paginator.page(1) + except EmptyPage: + userpaginator = paginator.page(paginator.num_pages) + for u in userpaginator: + o = dict() + o['id'] = str(u.id) + o['user_id'] = str(u.user_id) + if u.image: + o['image'] = u.image + else: + o['image'] = '/profile/user_default.jpg' + o['name'] = u.name + o['phone'] = u.user.username + o['organization'] = u.organization.name + organization_id = u.organization.id + if Organization.objects.get(id=organization_id).province and Organization.objects.get( + id=organization_id).cities and Organization.objects.get( + id=organization_id).district and Organization.objects.get( + id=organization_id).town and Organization.objects.get(id=organization_id).village: + o['administrativedivision'] = str(str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).cities)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).district)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).town)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).village))).replace( + 'None', '') + elif Organization.objects.get(id=organization_id).province and Organization.objects.get( + id=organization_id).cities and Organization.objects.get( + id=organization_id).district and Organization.objects.get(id=organization_id).town: + o['administrativedivision'] = str(str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).cities)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).district)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).town))).replace('None', + '') + elif Organization.objects.get(id=organization_id).province and Organization.objects.get( + id=organization_id).cities and Organization.objects.get(id=organization_id).district: + o['administrativedivision'] = str(str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).cities)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).district))).replace( + 'None', '') + elif Organization.objects.get(id=organization_id).province and Organization.objects.get( + id=organization_id).cities: + o['administrativedivision'] = str(str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).cities))).replace( + 'None', '') + elif Organization.objects.get(id=organization_id).province: + o['administrativedivision'] = str(str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province))).replace( + 'None', '') + userallinfo.append(o) + return render(request, 'backstage/backstage-app-inform-management.html', + {'userallinfo': userallinfo, 'userpaginator': userpaginator, 'user_count': user_count}) + +def backstage_app_inform_delete(request,pk): + user = Userprofile.objects.get(user_id=pk) + user.message_status = 0 + user.save() + messages.success(request,'取消成功') + return HttpResponseRedirect('/backstage/backstage/app/inform/manage/') diff --git a/dashboard/templates/dashboard/base/left.html b/dashboard/templates/dashboard/base/left.html index dd5dedd..41ee2ea 100644 --- a/dashboard/templates/dashboard/base/left.html +++ b/dashboard/templates/dashboard/base/left.html @@ -192,31 +192,35 @@
  • 数据下载 + href="{% url 'backstage-data-download' %}">数据下载
  • 微信更新 + href="{% url 'backstage-weixin_update' %}">数据对比
  • - 头条更新 + app通知管理
  • + {#
  • #} + {# 头条更新#} + {#
  • #} + {#
  • #} + {# 抖音更新#} + {#
  • #} + {#
  • #} + {# 微博更新#} + {#
  • #} + {#
  • #} + {# 其他更新#} + {#
  • #}
  • - 抖音更新 -
  • -
  • - 微博更新 -
  • -
  • - 其他更新 -
  • -
  • 添加不合格记录 + href="{% url 'backstage-add-unqualified-media' %}">添加不合格记录
  • diff --git a/dashboard/views.py b/dashboard/views.py index afcecb8..fee507f 100644 --- a/dashboard/views.py +++ b/dashboard/views.py @@ -147,11 +147,9 @@ def user_login_for_phone(request): # if float(time.time()) - float(check_code.c_time) > 60: # check_code.delete() # return '验证码超时已被删除' - # print(21333333333) # # except: else: - print(1233333333) messages.error(request, '请输入正确的验证码!!!') return render(request, 'dashboard/login-for-phone-new.html') @@ -208,14 +206,12 @@ def author_code(request): apikey = "304eb08353f7ebf00596737acfc31f53" # mobile = "18119305139" mobile = request.POST.get('mobile') - print(str(mobile) + "99999999999999999999999999999999999999999") tpl_id = 4045320 code = "" for i in range(6): ch = chr(random.randrange(ord('0'), ord('9') + 1)) code += ch - print(code) # tpl_value = {'#dateStart#': '10月1日', '#dateEnd#': '10日', '#type#': '微信公众号', '#name#': code} tpl_value = {'#code#': code} @@ -238,7 +234,6 @@ def author_code(request): check_code.phone_code = code check_code.save() except: - print(code, mobile, 1111111111) check_code = CheckCode(phone_code=code, phone=mobile) check_code.save() conn.close() @@ -350,7 +345,6 @@ def get_province(request): def get_city(request): code = request.GET.get('code') - print(code) # 市 cities = Area_code_2020.objects.filter(pcode=code) res = [] @@ -426,7 +420,6 @@ def import_user(request): name = r[1] zhiwei = r[2] phone = r[3] - print(organization) o = Organization.objects.get(name=organization) password = str(phone)[5:] if phone: @@ -439,10 +432,9 @@ def import_user(request): u.save() else: if '平凉' in organization: - print(organization) Userprofile.objects.filter(user__username=phone).update(organization_id=o.id) except: - print(phone) + pass return HttpResponse('ok') @@ -553,7 +545,6 @@ def user_search_by_keyword(request): userprofile__organization__district=district) elif level == 9: if keytype == '1': - print(keyword) userpaginator = Userprofile.objects.filter(name__contains=keyword) elif keytype == '2': userpaginator = Userprofile.objects.filter(organization__name__contains=keyword) @@ -769,7 +760,6 @@ def organization_search_by_keyword(request): except EmptyPage: organization = paginator.page(paginator.num_pages) for i in organization: - print(i) o = dict() o['id'] = str(i.id) o['name'] = i.name @@ -826,7 +816,6 @@ def weixin_search_by_keyword(request): district = o.district weixin = None res = [] - print(level) if level == 1: if keytype == '1': weixin = Weixin.objects.filter(organization__province=province, code__contains=keyword).order_by('-created') @@ -1774,7 +1763,6 @@ def xxxx(request): toutiao_count = [] douyin_count = [] qita_count = [] - # print(u.count()) # o = [] # weixin = None # for i in u: @@ -1786,16 +1774,11 @@ def xxxx(request): # # weixin_count.append(weixin) # # # toutiao_count.append(toutiao) # # - # print(len(weixin_count),len(toutiao_count)) - # # print(len(o)) - # # print(len(list(set(o)))) u = Userprofile.objects.filter(status='1') o_list = [] for i in u: o_list.append(i.organization_id) - print(list(set(o_list))) - print(len(list(set(o_list)))) for j in list(set(o_list)): if Weixin.objects.filter(organization_id=j).count() > 0: @@ -1809,6 +1792,4 @@ def xxxx(request): if Qita.objects.filter(organization_id=j).count() > 0: qita_count.append(Qita.objects.filter(organization_id=j)) - print(len(weixin_count), len(weibo_count), len(toutiao_count), len(douyin_count), len(qita_count)) - print(int(len(weixin_count))+ len(weibo_count)+len(toutiao_count)+len(douyin_count)+ len(qita_count)) diff --git a/management/templates/management/group-management-admin.html b/management/templates/management/group-management-admin.html index cc2f4ac..d052a1e 100644 --- a/management/templates/management/group-management-admin.html +++ b/management/templates/management/group-management-admin.html @@ -75,6 +75,8 @@
    我共管理{% if admin_count %}{{ admin_count }}{% else %} 0{% endif %}个矩阵
    + +
    @@ -88,7 +90,6 @@ 矩阵类型 管理员个数 成员个数 - 状态 操作 @@ -103,7 +104,6 @@ {{ r.type }} {{ r.admin_count }} {{ r.user_count }} - {{ r.status }} 编辑 diff --git a/management/templates/management/group-management-init.html b/management/templates/management/group-management-init.html index d1b6ed1..095992f 100644 --- a/management/templates/management/group-management-init.html +++ b/management/templates/management/group-management-init.html @@ -73,7 +73,8 @@
    我共创建{% if init_count %}{{ init_count }}{% else %} 0{% endif %}个矩阵
    - + +
    @@ -87,7 +88,6 @@ 矩阵类型 管理员个数 成员个数 - 状态 操作 @@ -102,7 +102,6 @@ {{ r.type }} {{ r.admin_count }} {{ r.user_count }} - {{ r.status }} 编辑 diff --git a/management/templates/management/group-management-superuser.html b/management/templates/management/group-management-superuser.html index 9200fdb..4c10219 100644 --- a/management/templates/management/group-management-superuser.html +++ b/management/templates/management/group-management-superuser.html @@ -75,6 +75,8 @@
    共有{% if count %}{{ count }}{% else %} 0{% endif %}个矩阵
    + +
    @@ -88,7 +90,6 @@ 矩阵类型 管理员个数 成员个数 - 状态 操作 @@ -103,7 +104,6 @@ {{ r.type }} {{ r.admin_count }} {{ r.user_count }} - {{ r.status }} 编辑 diff --git a/management/templates/management/group-management-user.html b/management/templates/management/group-management-user.html index 4cae616..7558f31 100644 --- a/management/templates/management/group-management-user.html +++ b/management/templates/management/group-management-user.html @@ -75,6 +75,8 @@
    我共加入{% if user_count %}{{ user_count }}{% else %} 0{% endif %}个矩阵
    + +
    @@ -88,7 +90,6 @@ 矩阵类型 管理员个数 成员个数 - 状态 @@ -102,7 +103,6 @@ {{ r.type }} {{ r.admin_count }} {{ r.user_count }} - {{ r.status }} {% endfor %} diff --git a/management/templates/management/newmedia-management-edit-douyin.html b/management/templates/management/newmedia-management-edit-douyin.html index 2767af2..163190c 100644 --- a/management/templates/management/newmedia-management-edit-douyin.html +++ b/management/templates/management/newmedia-management-edit-douyin.html @@ -46,6 +46,17 @@

    抖音总计:{{ douyin_count }}

    +
    diff --git a/management/templates/management/newmedia-management-edit-qita.html b/management/templates/management/newmedia-management-edit-qita.html index a734f0c..ea71621 100644 --- a/management/templates/management/newmedia-management-edit-qita.html +++ b/management/templates/management/newmedia-management-edit-qita.html @@ -32,12 +32,13 @@ -{# #} + {# #}
    - + @@ -46,6 +47,17 @@

    其他新媒体总计:{{ qita_count }}

    +
    @@ -78,10 +90,13 @@ {{ w.qitaid }} {{ w.organization }} {{ w.administrativedivision }} - {% if w.status == 0 %}已删除{% elif w.status == 3 %}正常{% elif w.status == 1 %}申请市级审核中 -{% elif w.status == 2 %}申请省级审核中{% elif w.status == 4 %}市级注销审核中{% elif w.status == 5 %}省级注销审核中 + + {% if w.status == 0 %}已删除{% elif w.status == 3 %} + 正常{% elif w.status == 1 %}申请市级审核中 + {% elif w.status == 2 %}申请省级审核中{% elif w.status == 4 %} + 市级注销审核中{% elif w.status == 5 %}省级注销审核中 - {% endif %} + {% endif %} 编辑 diff --git a/management/templates/management/newmedia-management-edit-toutiao.html b/management/templates/management/newmedia-management-edit-toutiao.html index 9729e78..b01f647 100644 --- a/management/templates/management/newmedia-management-edit-toutiao.html +++ b/management/templates/management/newmedia-management-edit-toutiao.html @@ -37,7 +37,8 @@
    - + @@ -46,6 +47,17 @@

    头条总计:{{ toutiao_count }}

    +
    @@ -75,10 +87,13 @@ {{ w.toutiaoid }} {{ w.organization }} {{ w.administrativedivision }} - {% if w.status == 0 %}已删除{% elif w.status == 3 %}正常{% elif w.status == 1 %}申请市级审核中 -{% elif w.status == 2 %}申请省级审核中{% elif w.status == 4 %}市级注销审核中{% elif w.status == 5 %}省级注销审核中 + + {% if w.status == 0 %}已删除{% elif w.status == 3 %} + 正常{% elif w.status == 1 %}申请市级审核中 + {% elif w.status == 2 %}申请省级审核中{% elif w.status == 4 %} + 市级注销审核中{% elif w.status == 5 %}省级注销审核中 - {% endif %} + {% endif %} 编辑 diff --git a/management/templates/management/newmedia-management-edit-weibo.html b/management/templates/management/newmedia-management-edit-weibo.html index 4a045b2..ece8d3a 100644 --- a/management/templates/management/newmedia-management-edit-weibo.html +++ b/management/templates/management/newmedia-management-edit-weibo.html @@ -46,6 +46,17 @@

    微博总计:{{ weibo_count }}

    +
    diff --git a/management/templates/management/newmedia-management-edit-weixin.html b/management/templates/management/newmedia-management-edit-weixin.html index a42f35f..89194f4 100644 --- a/management/templates/management/newmedia-management-edit-weixin.html +++ b/management/templates/management/newmedia-management-edit-weixin.html @@ -37,15 +37,29 @@
    - +
    -

    微信总计:{{ weixin_count }}

    +

    微信总计:{{ weixin_count }}


    + + +
    @@ -75,10 +89,13 @@ {{ w.weixinid }} {{ w.organization }} {{ w.administrativedivision }} - {% if w.status == 0 %}已删除{% elif w.status == 3 %}正常{% elif w.status == 1 %}申请市级审核中 -{% elif w.status == 2 %}申请省级审核中{% elif w.status == 4 %}市级注销审核中{% elif w.status == 5 %}省级注销审核中 + + {% if w.status == 0 %}已删除{% elif w.status == 3 %} + 正常{% elif w.status == 1 %}申请市级审核中 + {% elif w.status == 2 %}申请省级审核中{% elif w.status == 4 %} + 市级注销审核中{% elif w.status == 5 %}省级注销审核中 - {% endif %} + {% endif %} 编辑 @@ -89,15 +106,15 @@ {% endfor %} -{# {% if keyword %}#} -{# #} -{# {% else %}#} + {# {% if keyword %}#} + {# #} + {# {% else %}#} -{# {% endif %}#} + {# {% endif %}#}
    diff --git a/management/templates/management/organization-management.html b/management/templates/management/organization-management.html index 1c7f578..21b281c 100644 --- a/management/templates/management/organization-management.html +++ b/management/templates/management/organization-management.html @@ -67,6 +67,15 @@ {# #} {#
    #} +
    diff --git a/management/templates/management/user-management.html b/management/templates/management/user-management.html index c008b07..903c267 100644 --- a/management/templates/management/user-management.html +++ b/management/templates/management/user-management.html @@ -36,7 +36,8 @@
    - + @@ -45,6 +46,21 @@

    成员总计:{{ user_count }}

    +
    @@ -54,7 +70,8 @@ 序号 头像 姓名 - 电话 + 电话 单位名称 {# 单位类型#} 行政区划 diff --git a/management/urls.py b/management/urls.py index c5c1a3b..52eaf69 100644 --- a/management/urls.py +++ b/management/urls.py @@ -5,14 +5,21 @@ from management import views urlpatterns = [ # 用户管理 path('user/management/', views.user_management, name='user-management-management'), + path('user/management/order/by/name/', views.user_management_order_by_name, name='user-management-management-order-by-name'), + path('user/management/order/by/o/', views.user_management_order_by_o, name='user-management-management-order-by-o'), + path('user/management/order/by/phone/', views.user_management_order_by_phone, name='user-management-management-order-by-phone'), path('user/management/?sort=username/', views.user_management, name='user-management-management-sort'), path('user/delete//', views.user_delete, name='user-management-delete'), path('user/update//', views.user_update, name='user-management-update'), # 矩阵管理 path('group/management/init/', views.group_management_init, name='group-management-management-init'), + path('group/management/init/order/by/name/', views.group_management_init_order_by_name, name='group-management-management-init-order-by-name'), path('group/management/admin/', views.group_management_admin, name='group-management-management-admin'), + path('group/management/admin/order/by/name/', views.group_management_admin_order_by_name, name='group-management-management-admin-order-by-name'), path('group/management/user/', views.group_management_user, name='group-management-management-user'), + path('group/management/user/order/by/name/', views.group_management_user_order_by_name, name='group-management-management-user-order-by-name'), path('group/management/super/', views.group_management_superuser, name='group-management-management-superuser'), + path('group/management/super/order/by/name/', views.group_management_superuser_order_by_name, name='group-management-management-superuser-order-by-name'), path('group/create/', views.group_create, name='group-management-create'), path('group/update//', views.group_update, name='group-management-update'), path('group/delete//', views.group_delete, name='group-management-delete'), @@ -27,6 +34,7 @@ urlpatterns = [ # 主体单位管理 path('organization/management/', views.organization_management, name='organization-management-management'), + path('organization/management/order/by/name/', views.organization_management_order_by_name, name='organization-management-management-order-by-name'), path('organization/create/', views.organization_create, name='organization-management-create'), path('organization/delete//', views.organization_delete, name='organization-management-delete'), path('organization/update//', views.organization_update, name='organization-management-update'), @@ -40,10 +48,20 @@ urlpatterns = [ path('newmedia/management/create/douyin/',views.newmedia_management_create_douyin,name='newmedia-management-create-douyin'), path('newmedia/management/create/qita/',views.newmedia_management_create_qita,name='newmedia-management-create-qita'), path('newmedia/management/edit/weixin/',views.newmedia_management_edit_weixin,name='newmedia-management-edit-weixin'), + path('newmedia/management/edit/weixin/order/by/name/',views.newmedia_management_edit_weixin_order_by_name,name='newmedia-management-edit-weixin-order-by-name'), + path('newmedia/management/edit/weixin/order/by/o/',views.newmedia_management_edit_weixin_order_by_o,name='newmedia-management-edit-weixin-order-by-o'), path('newmedia/management/edit/weibo/',views.newmedia_management_edit_weibo,name='newmedia-management-edit-weibo'), + path('newmedia/management/edit/weibo/order/by/name/',views.newmedia_management_edit_weibo_order_by_name,name='newmedia-management-edit-weibo-order-by-name'), + path('newmedia/management/edit/weibo/order/by/o/',views.newmedia_management_edit_weibo_order_by_o,name='newmedia-management-edit-weibo-order-by-o'), path('newmedia/management/edit/toutiao/',views.newmedia_management_edit_toutiao,name='newmedia-management-edit-toutiao'), + path('newmedia/management/edit/toutiao/order/by/name/',views.newmedia_management_edit_toutiao_order_by_name,name='newmedia-management-edit-toutiao-order-by-name'), + path('newmedia/management/edit/toutiao/order/by/o/',views.newmedia_management_edit_toutiao_order_o,name='newmedia-management-edit-toutiao-order-by-o'), path('newmedia/management/edit/douyin/',views.newmedia_management_edit_douyin,name='newmedia-management-edit-douyin'), + path('newmedia/management/edit/douyin/order/by/name/',views.newmedia_management_edit_douyin_order_by_name,name='newmedia-management-edit-douyin-order-by-name'), + path('newmedia/management/edit/douyin/order/by/o/',views.newmedia_management_edit_douyin_order_by_o,name='newmedia-management-edit-douyin-order-by-o'), path('newmedia/management/edit/qita/',views.newmedia_management_edit_qita,name='newmedia-management-edit-qita'), + path('newmedia/management/edit/qita/order/by/name/',views.newmedia_management_edit_qita_order_by_name,name='newmedia-management-edit-qita-order-by-name'), + path('newmedia/management/edit/qita/order/by/o/',views.newmedia_management_edit_qita_order_by_o,name='newmedia-management-edit-qita-order-by-o'), path('newmedia/management/update/weixin//',views.newmedia_management_update_weixin,name='newmedia-management-update-weixin'), path('newmedia/management/update/weibo//',views.newmedia_management_update_weibo,name='newmedia-management-update-weibo'), path('newmedia/management/update/toutiao//',views.newmedia_management_update_toutiao,name='newmedia-management-update-toutiao'), diff --git a/management/views.py b/management/views.py index 6be4b2b..bda5d2c 100644 --- a/management/views.py +++ b/management/views.py @@ -100,6 +100,261 @@ def user_management(request): return render(request, 'management/user-management.html', {'userallinfo': userallinfo, 'userpaginator': userpaginator, 'user_count': user_count}) +@login_required +def user_management_order_by_name(request): + user_count = User.objects.all().count() + 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 + userpaginator = None + if level == 1: + userpaginator = Userprofile.objects.filter(organization__province=province).order_by('name') + elif level == 2: + userpaginator = Userprofile.objects.filter(organization__province=province, + organization__cities=cities).order_by('name') + elif level == 3: + userpaginator = Userprofile.objects.filter(organization__province=province, + organization__cities=cities, + organization__district=district).order_by('name') + elif level == 9: + userpaginator = Userprofile.objects.all().order_by('name') + userallinfo = [] + if userpaginator is not None: + paginator = Paginator(userpaginator, 6) + page = int(request.GET.get('page', 1)) + try: + userpaginator = paginator.page(page) + except PageNotAnInteger: + userpaginator = paginator.page(1) + except EmptyPage: + userpaginator = paginator.page(paginator.num_pages) + + for u in userpaginator: + o = dict() + o['id'] = str(u.id) + o['user_id'] = str(u.user_id) + if u.image: + o['image'] = u.image + else: + o['image'] = '/profile/user_default.jpg' + o['name'] = u.name + o['phone'] = u.user.username + o['organization'] = u.organization.name + organization_id = u.organization.id + if Organization.objects.get(id=organization_id).province and Organization.objects.get( + id=organization_id).cities and Organization.objects.get( + id=organization_id).district and Organization.objects.get( + id=organization_id).town and Organization.objects.get(id=organization_id).village: + o['administrativedivision'] = str(str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).cities)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).district)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).town)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).village))).replace( + 'None', '') + elif Organization.objects.get(id=organization_id).province and Organization.objects.get( + id=organization_id).cities and Organization.objects.get( + id=organization_id).district and Organization.objects.get(id=organization_id).town: + o['administrativedivision'] = str(str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).cities)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).district)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).town))).replace('None', + '') + elif Organization.objects.get(id=organization_id).province and Organization.objects.get( + id=organization_id).cities and Organization.objects.get(id=organization_id).district: + o['administrativedivision'] = str(str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).cities)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).district))).replace( + 'None', '') + elif Organization.objects.get(id=organization_id).province and Organization.objects.get( + id=organization_id).cities: + o['administrativedivision'] = str(str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).cities))).replace( + 'None', '') + elif Organization.objects.get(id=organization_id).province: + o['administrativedivision'] = str(str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province))).replace( + 'None', '') + userallinfo.append(o) + return render(request, 'management/user-management.html', + {'userallinfo': userallinfo, 'userpaginator': userpaginator, 'user_count': user_count}) +@login_required +def user_management_order_by_o(request): + user_count = User.objects.all().count() + 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 + userpaginator = None + if level == 1: + userpaginator = Userprofile.objects.filter(organization__province=province).order_by('organization__name') + elif level == 2: + userpaginator = Userprofile.objects.filter(organization__province=province, + organization__cities=cities).order_by('organization__name') + elif level == 3: + userpaginator = Userprofile.objects.filter(organization__province=province, + organization__cities=cities, + organization__district=district).order_by('organization__name') + elif level == 9: + userpaginator = Userprofile.objects.all().order_by('organization__name') + userallinfo = [] + if userpaginator is not None: + paginator = Paginator(userpaginator, 6) + page = int(request.GET.get('page', 1)) + try: + userpaginator = paginator.page(page) + except PageNotAnInteger: + userpaginator = paginator.page(1) + except EmptyPage: + userpaginator = paginator.page(paginator.num_pages) + + for u in userpaginator: + o = dict() + o['id'] = str(u.id) + o['user_id'] = str(u.user_id) + if u.image: + o['image'] = u.image + else: + o['image'] = '/profile/user_default.jpg' + o['name'] = u.name + o['phone'] = u.user.username + o['organization'] = u.organization.name + organization_id = u.organization.id + if Organization.objects.get(id=organization_id).province and Organization.objects.get( + id=organization_id).cities and Organization.objects.get( + id=organization_id).district and Organization.objects.get( + id=organization_id).town and Organization.objects.get(id=organization_id).village: + o['administrativedivision'] = str(str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).cities)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).district)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).town)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).village))).replace( + 'None', '') + elif Organization.objects.get(id=organization_id).province and Organization.objects.get( + id=organization_id).cities and Organization.objects.get( + id=organization_id).district and Organization.objects.get(id=organization_id).town: + o['administrativedivision'] = str(str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).cities)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).district)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).town))).replace('None', + '') + elif Organization.objects.get(id=organization_id).province and Organization.objects.get( + id=organization_id).cities and Organization.objects.get(id=organization_id).district: + o['administrativedivision'] = str(str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).cities)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).district))).replace( + 'None', '') + elif Organization.objects.get(id=organization_id).province and Organization.objects.get( + id=organization_id).cities: + o['administrativedivision'] = str(str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).cities))).replace( + 'None', '') + elif Organization.objects.get(id=organization_id).province: + o['administrativedivision'] = str(str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province))).replace( + 'None', '') + userallinfo.append(o) + return render(request, 'management/user-management.html', + {'userallinfo': userallinfo, 'userpaginator': userpaginator, 'user_count': user_count}) + +@login_required +def user_management_order_by_phone(request): + user_count = User.objects.all().count() + 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 + userpaginator = None + if level == 1: + userpaginator = Userprofile.objects.filter(organization__province=province).order_by('user__username') + elif level == 2: + userpaginator = Userprofile.objects.filter(organization__province=province, + organization__cities=cities).order_by('user__username') + elif level == 3: + userpaginator = Userprofile.objects.filter(organization__province=province, + organization__cities=cities, + organization__district=district).order_by('user__username') + elif level == 9: + userpaginator = Userprofile.objects.all().order_by('user__username') + userallinfo = [] + if userpaginator is not None: + paginator = Paginator(userpaginator, 6) + page = int(request.GET.get('page', 1)) + try: + userpaginator = paginator.page(page) + except PageNotAnInteger: + userpaginator = paginator.page(1) + except EmptyPage: + userpaginator = paginator.page(paginator.num_pages) + + for u in userpaginator: + o = dict() + o['id'] = str(u.id) + o['user_id'] = str(u.user_id) + if u.image: + o['image'] = u.image + else: + o['image'] = '/profile/user_default.jpg' + o['name'] = u.name + o['phone'] = u.user.username + o['organization'] = u.organization.name + organization_id = u.organization.id + if Organization.objects.get(id=organization_id).province and Organization.objects.get( + id=organization_id).cities and Organization.objects.get( + id=organization_id).district and Organization.objects.get( + id=organization_id).town and Organization.objects.get(id=organization_id).village: + o['administrativedivision'] = str(str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).cities)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).district)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).town)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).village))).replace( + 'None', '') + elif Organization.objects.get(id=organization_id).province and Organization.objects.get( + id=organization_id).cities and Organization.objects.get( + id=organization_id).district and Organization.objects.get(id=organization_id).town: + o['administrativedivision'] = str(str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).cities)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).district)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).town))).replace('None', + '') + elif Organization.objects.get(id=organization_id).province and Organization.objects.get( + id=organization_id).cities and Organization.objects.get(id=organization_id).district: + o['administrativedivision'] = str(str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).cities)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).district))).replace( + 'None', '') + elif Organization.objects.get(id=organization_id).province and Organization.objects.get( + id=organization_id).cities: + o['administrativedivision'] = str(str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province)) + '-' + str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).cities))).replace( + 'None', '') + elif Organization.objects.get(id=organization_id).province: + o['administrativedivision'] = str(str( + Area_code_2020.objects.get(code=Organization.objects.get(id=organization_id).province))).replace( + 'None', '') + userallinfo.append(o) + return render(request, 'management/user-management.html', + {'userallinfo': userallinfo, 'userpaginator': userpaginator, 'user_count': user_count}) + + @login_required def user_delete(request, pk): @@ -121,7 +376,6 @@ def user_update(request, pk): username = request.POST.get('username') image = request.FILES.get('image') - user.email = email user.username = username userprofile.organization_id = o_id @@ -170,6 +424,39 @@ def group_management_init(request): {'group': group, 'res_g_i': res_g_i, 'init_count': init_count, 'level': level}) +@login_required +def group_management_init_order_by_name(request): + user = request.user + level = Userprofile.objects.get(user_id=user.id).organization.level.level + init_count = Group.objects.filter(user_id=user.id).count() + # 创建的矩阵 + group_initer = Group.objects.filter(user_id=user.id).order_by('name') + paginator = Paginator(group_initer, 6) + page = int(request.GET.get('page', 1)) + try: + group = paginator.page(page) + except PageNotAnInteger: + group = paginator.page(1) + except EmptyPage: + group = paginator.page(paginator.num_pages) + res_g_i = [] + for r_g_i in group: + o1 = dict() + o1['id'] = str(r_g_i.id) + if r_g_i.image: + o1['image'] = r_g_i.image.url + else: + o1['image'] = 'groupimage/danweimoren.jpg' + o1['name'] = r_g_i.name + o1['type'] = r_g_i.type + o1['admin_count'] = Group_admin.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 + 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}) + + @login_required def group_management_admin(request): # 管理的矩阵 @@ -206,6 +493,42 @@ def group_management_admin(request): {'group': group, 'res_g_a': res_g_a, 'admin_count': admin_count, 'level': level}) +@login_required +def group_management_admin_order_by_name(request): + # 管理的矩阵 + user = request.user + level = Userprofile.objects.get(user_id=user.id).organization.level.level + admin_count = Group_admin.objects.filter(user_id=user.id).count() + group_admin_list = [] + for g_a in Group_admin.objects.filter(user_id=user.id).order_by('group__name'): + group_admin = Group.objects.get(id=g_a.group_id) + group_admin_list.append(group_admin) + paginator = Paginator(group_admin_list, 6) + page = int(request.GET.get('page', 1)) + try: + group = paginator.page(page) + except PageNotAnInteger: + group = paginator.page(1) + except EmptyPage: + group = paginator.page(paginator.num_pages) + res_g_a = [] + for r_g_a in group: + o2 = dict() + o2['id'] = str(r_g_a.id) + if r_g_a.image: + o2['image'] = r_g_a.image.url + else: + o2['image'] = 'groupimage/danweimoren.jpg' + o2['name'] = r_g_a.name + o2['type'] = r_g_a.type + o2['admin_count'] = Group_admin.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 + 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}) + + @login_required def group_management_user(request): # 加入的矩阵 @@ -242,6 +565,42 @@ def group_management_user(request): {'group': group, 'res_g_u': res_g_u, 'user_count': user_count, 'level': level}) +@login_required +def group_management_user_order_by_name(request): + # 加入的矩阵 + user = request.user + level = Userprofile.objects.get(user_id=user.id).organization.level.level + user_count = Group_user.objects.filter(user_id=user.id).count() + group_user_list = [] + for g_u in Group_user.objects.filter(user_id=user.id).order_by('group__name'): + group_user = Group.objects.get(id=g_u.group_id) + group_user_list.append(group_user) + paginator = Paginator(group_user_list, 6) + page = int(request.GET.get('page', 1)) + try: + group = paginator.page(page) + except PageNotAnInteger: + group = paginator.page(1) + except EmptyPage: + group = paginator.page(paginator.num_pages) + res_g_u = [] + for r_g_u in group: + o3 = dict() + o3['id'] = str(r_g_u.id) + if r_g_u.image: + o3['image'] = r_g_u.image.url + else: + o3['image'] = 'groupimage/danweimoren.jpg' + o3['name'] = r_g_u.name + o3['type'] = r_g_u.type + o3['admin_count'] = Group_admin.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 + 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}) + + @login_required def group_management_superuser(request): user = request.user @@ -274,6 +633,38 @@ def group_management_superuser(request): {'group': group, 'res_g_i': res_g_i, 'count': count, 'level': level}) +@login_required +def group_management_superuser_order_by_name(request): + user = request.user + level = Userprofile.objects.get(user_id=user.id).organization.level.level + count = Group.objects.all().count() + group = Group.objects.all().order_by('name') + paginator = Paginator(group, 6) + page = int(request.GET.get('page', 1)) + try: + group = paginator.page(page) + except PageNotAnInteger: + group = paginator.page(1) + except EmptyPage: + group = paginator.page(paginator.num_pages) + res_g_i = [] + for r_g_i in group: + o1 = dict() + o1['id'] = str(r_g_i.id) + if r_g_i.image: + o1['image'] = r_g_i.image.url + else: + o1['image'] = 'groupimage/danweimoren.jpg' + o1['name'] = r_g_i.name + o1['type'] = r_g_i.type + o1['admin_count'] = Group_admin.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 + 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}) + + @login_required def group_update(request, pk): group = Group.objects.get(id=pk) @@ -321,10 +712,10 @@ def group_update(request, pk): 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) + 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( @@ -436,7 +827,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,'page':group_user}) + 'v': v, 'page': group_user}) @login_required @@ -661,7 +1052,6 @@ 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: @@ -676,6 +1066,72 @@ def organization_management(request): return render(request, 'management/organization-management.html', {"organization": organization, 'res': res, 'organization_count': organization_count}) +@login_required +def organization_management_order_by_name(request): + organization_count = Organization.objects.all().count() + 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 + organization = None + res = [] + if level == 1: + organization = Organization.objects.filter(province=province).order_by('name') + elif level == 2: + organization = Organization.objects.filter(province=province, cities=cities).order_by('name') + elif level == 3: + organization = Organization.objects.filter(province=province, cities=cities, district=district).order_by( + 'name') + elif level == 9: + organization = Organization.objects.all().order_by('name') + if organization is not None: + paginator = Paginator(organization, 6) + page = int(request.GET.get('page', 1)) + try: + organization = paginator.page(page) + except PageNotAnInteger: + organization = paginator.page(1) + except EmptyPage: + organization = paginator.page(paginator.num_pages) + for i in organization: + o = dict() + o['id'] = str(i.id) + o['name'] = i.name + if i.image: + o['image'] = i.image.url + else: + o['image'] = 'danweimoren.jpg' + 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 organization_delete(request, pk): @@ -706,9 +1162,7 @@ def organization_update(request, pk): level = Level.objects.all() weixin = Weixin.objects.filter(organization_id=pk) - print(weixin) weixin_count = Weixin.objects.filter(organization_id=pk).count() - print(weixin_count) weibo = Weibo.objects.filter(organization_id=pk) weibo_count = weibo.count() toutiao = Toutiao.objects.filter(organization_id=pk) @@ -756,7 +1210,11 @@ def organization_update(request, pk): messages.success(request, '修改成功') return HttpResponseRedirect('/management/organization/management/') return render(request, 'management/organization-management-update.html', - {'organization': organization, 'level': level, 'p': p, 'c': c, 'd': d, 't': t, 'v': v,'weixin':weixin,'weibo':weibo,'douyin':douyin,'qita':qita,'toutiao':toutiao,'weixin_count':weixin_count,'weibo_count':weibo_count,'douyin_count':douyin_count,'toutiao_count':toutiao_count,'qita_count':qita_count,'o_user':o_user,'o_user_count':o_user_count}) + {'organization': organization, 'level': level, 'p': p, 'c': c, 'd': d, 't': t, 'v': v, + 'weixin': weixin, 'weibo': weibo, 'douyin': douyin, 'qita': qita, 'toutiao': toutiao, + 'weixin_count': weixin_count, 'weibo_count': weibo_count, 'douyin_count': douyin_count, + 'toutiao_count': toutiao_count, 'qita_count': qita_count, 'o_user': o_user, + 'o_user_count': o_user_count}) def organization_create(request): @@ -1123,6 +1581,158 @@ def newmedia_management_edit_weixin(request): {'weixin': weixin, 'res': res, 'weixin_count': weixin_count}) +@login_required +def newmedia_management_edit_weixin_order_by_name(request): + weixin_count = Weixin.objects.all().count() + 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: + weixin = Weixin.objects.filter(organization__province=province).order_by('code') + elif level == 2: + weixin = Weixin.objects.filter(organization__province=province, organization__cities=cities).order_by( + '-code') + elif level == 3: + weixin = Weixin.objects.filter(organization__province=province, organization__cities=cities, + organization__district=district).order_by( + '-code') + elif level == 9: + weixin = Weixin.objects.all().order_by('-code') + if weixin is not None: + paginator = Paginator(weixin, 6) + page = int(request.GET.get('page', 1)) + try: + weixin = paginator.page(page) + except PageNotAnInteger: + weixin = paginator.page(1) + except EmptyPage: + weixin = paginator.page(paginator.num_pages) + + for w in weixin: + o = dict() + o['id'] = str(w.id) + if w.image: + o['image'] = w.image + else: + o['image'] = 'weixin.png' + 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 newmedia_management_edit_weixin_order_by_o(request): + weixin_count = Weixin.objects.all().count() + 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: + weixin = Weixin.objects.filter(organization__province=province).order_by('organization__name') + elif level == 2: + weixin = Weixin.objects.filter(organization__province=province, organization__cities=cities).order_by( + 'organization__name') + elif level == 3: + weixin = Weixin.objects.filter(organization__province=province, organization__cities=cities, + organization__district=district).order_by( + 'organization__name') + elif level == 9: + weixin = Weixin.objects.all().order_by('organization__name') + if weixin is not None: + paginator = Paginator(weixin, 6) + page = int(request.GET.get('page', 1)) + try: + weixin = paginator.page(page) + except PageNotAnInteger: + weixin = paginator.page(1) + except EmptyPage: + weixin = paginator.page(paginator.num_pages) + + for w in weixin: + o = dict() + o['id'] = str(w.id) + if w.image: + o['image'] = w.image + else: + o['image'] = 'weixin.png' + 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 newmedia_management_edit_weibo(request): weibo_count = Weibo.objects.all().count() @@ -1197,6 +1807,151 @@ def newmedia_management_edit_weibo(request): {'weibo': weibo, 'res': res, 'weibo_count': weibo_count}) +@login_required +def newmedia_management_edit_weibo_order_by_name(request): + weibo_count = Weibo.objects.all().count() + 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: + weibo = Weibo.objects.filter(organization__province=province).order_by('code') + elif level == 2: + weibo = Weibo.objects.filter(organization__province=province, organization__cities=cities).order_by('code') + elif level == 3: + weibo = Weibo.objects.filter(organization__province=province, organization__cities=cities, + organization__district=district).order_by('code') + elif level == 9: + weibo = Weibo.objects.all().order_by('code') + if weibo is not None: + paginator = Paginator(weibo, 6) + page = int(request.GET.get('page', 1)) + try: + weibo = paginator.page(page) + except PageNotAnInteger: + weibo = paginator.page(1) + except EmptyPage: + weibo = paginator.page(paginator.num_pages) + + for w in weibo: + o = dict() + o['id'] = str(w.id) + if w.image: + o['image'] = w.image + else: + o['image'] = 'weibo.png' + o['code'] = w.code + o['weiboid'] = w.weiboid + 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-weibo.html', + {'weibo': weibo, 'res': res, 'weibo_count': weibo_count}) + +@login_required +def newmedia_management_edit_weibo_order_by_o(request): + weibo_count = Weibo.objects.all().count() + 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: + weibo = Weibo.objects.filter(organization__province=province).order_by('organization__name') + elif level == 2: + weibo = Weibo.objects.filter(organization__province=province, organization__cities=cities).order_by('organization__name') + elif level == 3: + weibo = Weibo.objects.filter(organization__province=province, organization__cities=cities, + organization__district=district).order_by('organization__name') + elif level == 9: + weibo = Weibo.objects.all().order_by('organization__name') + if weibo is not None: + paginator = Paginator(weibo, 6) + page = int(request.GET.get('page', 1)) + try: + weibo = paginator.page(page) + except PageNotAnInteger: + weibo = paginator.page(1) + except EmptyPage: + weibo = paginator.page(paginator.num_pages) + + for w in weibo: + o = dict() + o['id'] = str(w.id) + if w.image: + o['image'] = w.image + else: + o['image'] = 'weibo.png' + o['code'] = w.code + o['weiboid'] = w.weiboid + 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-weibo.html', + {'weibo': weibo, 'res': res, 'weibo_count': weibo_count}) @login_required def newmedia_management_edit_toutiao(request): toutiao_count = Toutiao.objects.all().count() @@ -1271,6 +2026,152 @@ def newmedia_management_edit_toutiao(request): return render(request, 'management/newmedia-management-edit-toutiao.html', {'toutiao': toutiao, 'res': res, 'toutiao_count': toutiao_count}) +@login_required +def newmedia_management_edit_toutiao_order_by_name(request): + toutiao_count = Toutiao.objects.all().count() + 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 + toutiao = None + res = [] + if level == 1: + toutiao = Toutiao.objects.filter(organization__province=province).order_by('code') + elif level == 2: + toutiao = Toutiao.objects.filter(organization__province=province, organization__cities=cities).order_by( + 'code') + elif level == 3: + toutiao = Toutiao.objects.filter(organization__province=province, organization__cities=cities, + organization__district=district).order_by( + 'code') + elif level == 9: + toutiao = Toutiao.objects.all().order_by('code') + if toutiao is not None: + paginator = Paginator(toutiao, 6) + page = int(request.GET.get('page', 1)) + try: + toutiao = paginator.page(page) + except PageNotAnInteger: + toutiao = paginator.page(1) + except EmptyPage: + toutiao = paginator.page(paginator.num_pages) + for w in toutiao: + o = dict() + o['id'] = str(w.id) + if w.image: + o['image'] = w.image + else: + o['image'] = 'toutiao.png' + o['code'] = w.code + o['toutiaoid'] = w.toutiaoid + 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-toutiao.html', + {'toutiao': toutiao, 'res': res, 'toutiao_count': toutiao_count}) +@login_required +def newmedia_management_edit_toutiao_order_o(request): + toutiao_count = Toutiao.objects.all().count() + 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 + toutiao = None + res = [] + if level == 1: + toutiao = Toutiao.objects.filter(organization__province=province).order_by('organization__name') + elif level == 2: + toutiao = Toutiao.objects.filter(organization__province=province, organization__cities=cities).order_by( + 'organization__name') + elif level == 3: + toutiao = Toutiao.objects.filter(organization__province=province, organization__cities=cities, + organization__district=district).order_by( + 'organization__name') + elif level == 9: + toutiao = Toutiao.objects.all().order_by('organization__name') + if toutiao is not None: + paginator = Paginator(toutiao, 6) + page = int(request.GET.get('page', 1)) + try: + toutiao = paginator.page(page) + except PageNotAnInteger: + toutiao = paginator.page(1) + except EmptyPage: + toutiao = paginator.page(paginator.num_pages) + for w in toutiao: + o = dict() + o['id'] = str(w.id) + if w.image: + o['image'] = w.image + else: + o['image'] = 'toutiao.png' + o['code'] = w.code + o['toutiaoid'] = w.toutiaoid + 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-toutiao.html', + {'toutiao': toutiao, 'res': res, 'toutiao_count': toutiao_count}) @login_required def newmedia_management_edit_douyin(request): @@ -1346,6 +2247,154 @@ def newmedia_management_edit_douyin(request): return render(request, 'management/newmedia-management-edit-douyin.html', {'douyin': douyin, 'res': res, 'douyin_count': douyin_count}) +@login_required +def newmedia_management_edit_douyin_order_by_name(request): + douyin_count = Douyin.objects.all().count() + 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 + douyin = None + res = [] + if level == 1: + douyin = Douyin.objects.filter(organization__province=province).order_by('code') + elif level == 2: + douyin = Douyin.objects.filter(organization__province=province, organization__cities=cities).order_by( + 'code') + elif level == 3: + douyin = Douyin.objects.filter(organization__province=province, organization__cities=cities, + organization__district=district).order_by( + 'code') + elif level == 9: + douyin = Douyin.objects.all().order_by('code') + if douyin is not None: + paginator = Paginator(douyin, 6) + page = int(request.GET.get('page', 1)) + try: + douyin = paginator.page(page) + except PageNotAnInteger: + douyin = paginator.page(1) + except EmptyPage: + douyin = paginator.page(paginator.num_pages) + for w in douyin: + o = dict() + o['id'] = str(w.id) + if w.image: + o['image'] = w.image + else: + o['image'] = 'douyin.jpg' + o['code'] = w.code + o['douyinid'] = w.douyinid + 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-douyin.html', + {'douyin': douyin, 'res': res, 'douyin_count': douyin_count}) + +@login_required +def newmedia_management_edit_douyin_order_by_o(request): + douyin_count = Douyin.objects.all().count() + 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 + douyin = None + res = [] + if level == 1: + douyin = Douyin.objects.filter(organization__province=province).order_by('organization__name') + elif level == 2: + douyin = Douyin.objects.filter(organization__province=province, organization__cities=cities).order_by( + 'organization__name') + elif level == 3: + douyin = Douyin.objects.filter(organization__province=province, organization__cities=cities, + organization__district=district).order_by( + 'organization__name') + elif level == 9: + douyin = Douyin.objects.all().order_by('organization__name') + if douyin is not None: + paginator = Paginator(douyin, 6) + page = int(request.GET.get('page', 1)) + try: + douyin = paginator.page(page) + except PageNotAnInteger: + douyin = paginator.page(1) + except EmptyPage: + douyin = paginator.page(paginator.num_pages) + for w in douyin: + o = dict() + o['id'] = str(w.id) + if w.image: + o['image'] = w.image + else: + o['image'] = 'douyin.jpg' + o['code'] = w.code + o['douyinid'] = w.douyinid + 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-douyin.html', + {'douyin': douyin, 'res': res, 'douyin_count': douyin_count}) + @login_required def newmedia_management_edit_qita(request): @@ -1420,6 +2469,150 @@ def newmedia_management_edit_qita(request): return render(request, 'management/newmedia-management-edit-qita.html', {'qita': qita, 'res': res, 'qita_count': qita_count}) +@login_required +def newmedia_management_edit_qita_order_by_name(request): + qita_count = Qita.objects.all().count() + 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 + qita = None + res = [] + if level == 1: + qita = Qita.objects.filter(organization__province=province).order_by('code') + elif level == 2: + qita = Qita.objects.filter(organization__province=province, organization__cities=cities).order_by('code') + elif level == 3: + qita = Qita.objects.filter(organization__province=province, organization__cities=cities, + organization__district=district).order_by('code') + elif level == 9: + qita = Qita.objects.all().order_by('code') + if qita is not None: + paginator = Paginator(qita, 6) + page = int(request.GET.get('page', 1)) + try: + qita = paginator.page(page) + except PageNotAnInteger: + qita = paginator.page(1) + except EmptyPage: + qita = paginator.page(paginator.num_pages) + for w in qita: + o = dict() + o['id'] = str(w.id) + if w.image: + o['image'] = w.image + else: + o['image'] = 'qita.png' + o['type'] = w.type + o['name'] = w.code + o['qitaid'] = w.qitaid + 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-qita.html', + {'qita': qita, 'res': res, 'qita_count': qita_count}) +@login_required +def newmedia_management_edit_qita_order_by_o(request): + qita_count = Qita.objects.all().count() + 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 + qita = None + res = [] + if level == 1: + qita = Qita.objects.filter(organization__province=province).order_by('organization__name') + elif level == 2: + qita = Qita.objects.filter(organization__province=province, organization__cities=cities).order_by('organization__name') + elif level == 3: + qita = Qita.objects.filter(organization__province=province, organization__cities=cities, + organization__district=district).order_by('organization__name') + elif level == 9: + qita = Qita.objects.all().order_by('organization__name') + if qita is not None: + paginator = Paginator(qita, 6) + page = int(request.GET.get('page', 1)) + try: + qita = paginator.page(page) + except PageNotAnInteger: + qita = paginator.page(1) + except EmptyPage: + qita = paginator.page(paginator.num_pages) + for w in qita: + o = dict() + o['id'] = str(w.id) + if w.image: + o['image'] = w.image + else: + o['image'] = 'qita.png' + o['type'] = w.type + o['name'] = w.code + o['qitaid'] = w.qitaid + 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-qita.html', + {'qita': qita, 'res': res, 'qita_count': qita_count}) @login_required def newmedia_management_update_weixin(request, pk): @@ -1877,8 +3070,9 @@ def newmedia_detail_weixin(request, pk): return render(request, 'management/newmedia-detail-weixin.html', {'weixin': weixin}) + @login_required -def group_user_search(request,pk): +def group_user_search(request, pk): keyword = request.POST.get('keyword') keytype = request.POST.get('keytype') group = Group.objects.get(id=pk) @@ -1946,7 +3140,7 @@ def group_user_search(request,pk): o['administrativedivision'] = str(Area_code_2020.objects.get(code=str(admin_p)).name) g_a_list.append(o) if keytype == '1': - group_user = Group_user.objects.filter(group_id=pk,user__userprofile__name__contains=keyword) + group_user = Group_user.objects.filter(group_id=pk, user__userprofile__name__contains=keyword) elif keytype == '2': group_user = Group_user.objects.filter(group_id=pk, user__username__contains=keyword) paginator = Paginator(group_user, 6) @@ -1997,4 +3191,4 @@ def group_user_search(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, 'page': group_user,'keytype':keytype,'keyword':keyword}) \ No newline at end of file + 'v': v, 'page': group_user, 'keytype': keytype, 'keyword': keyword})