From fd293ce05c504586159ae741aac82919985ae936 Mon Sep 17 00:00:00 2001 From: Bob <1397910458@qq.com> Date: Mon, 17 Aug 2020 18:23:42 +0800 Subject: [PATCH] =?UTF-8?q?#=E6=96=B0=E5=AA=92=E4=BD=93=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/workspace.xml | 643 ++++++++++-------- dashboard/models.py | 44 +- dashboard/templates/dashboard/base/left.html | 4 +- .../paginator/weixin-management-paginate.html | 18 + .../management/group-admin-create.html | 74 ++ .../management/group-management-update.html | 12 +- .../management/group-management.html | 16 - .../management/group-user-create.html | 74 ++ .../newmedia-management-create-menu.html | 107 +++ .../newmedia-management-create-weixin.html | 105 +++ .../newmedia-management-edit-menu.html | 107 +++ .../newmedia-management-edit-weixin.html | 82 +++ .../organization-management-create.html | 2 +- management/urls.py | 22 +- management/views.py | 124 +++- 15 files changed, 1107 insertions(+), 327 deletions(-) create mode 100644 dashboard/templates/dashboard/paginator/weixin-management-paginate.html create mode 100644 management/templates/management/group-admin-create.html create mode 100644 management/templates/management/group-user-create.html create mode 100644 management/templates/management/newmedia-management-create-menu.html create mode 100644 management/templates/management/newmedia-management-create-weixin.html create mode 100644 management/templates/management/newmedia-management-edit-menu.html create mode 100644 management/templates/management/newmedia-management-edit-weixin.html diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 5281c16..cf80f87 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,27 +2,19 @@ - - - - - - - + + + + + + + - - - - - - + - - - @@ -97,8 +89,8 @@ - - + + @@ -116,8 +108,8 @@ - - + + @@ -125,11 +117,20 @@ + + + + + + + + + - - + + @@ -138,47 +139,58 @@ - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -232,13 +244,11 @@ @@ -275,6 +295,7 @@ + @@ -282,6 +303,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -311,11 +366,28 @@ + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+ + + + + + + + + + +
+ + +{% endblock %} diff --git a/management/templates/management/group-management-update.html b/management/templates/management/group-management-update.html index c9d4810..db2e7a8 100644 --- a/management/templates/management/group-management-update.html +++ b/management/templates/management/group-management-update.html @@ -111,7 +111,7 @@
- + @@ -133,9 +133,9 @@ - + @@ -147,7 +147,7 @@
- +
{{ g_a.username }} {{ g_a.name }} {{ g_a.organization }}{{ g_a.organization }}{{ g_a.administrativedivision }} - 删除
@@ -169,9 +169,9 @@ - + diff --git a/management/templates/management/group-management.html b/management/templates/management/group-management.html index 732a18e..6bdea39 100644 --- a/management/templates/management/group-management.html +++ b/management/templates/management/group-management.html @@ -96,20 +96,4 @@ {% block add_js %} - {% endblock %} diff --git a/management/templates/management/group-user-create.html b/management/templates/management/group-user-create.html new file mode 100644 index 0000000..b9cdc88 --- /dev/null +++ b/management/templates/management/group-user-create.html @@ -0,0 +1,74 @@ +{% extends 'dashboard/base/base.html' %} +{% load static %} +{% block content %} + + + + +
+ +
+ {% include 'dashboard/base/left.html' %} +
+
+
+ {% if messages %} + + {% endif %} +
+
+ +
+

添加群组成员

+
+
+
+ +
+
+
+

群组成员表单

+
+
+
+
+
{% csrf_token %} +
+ +
+ +
+
+
+ +
+ +
+
+ + + +
+
+
+
+
+
+
+
+
+ +{% endblock %} diff --git a/management/templates/management/newmedia-management-create-menu.html b/management/templates/management/newmedia-management-create-menu.html new file mode 100644 index 0000000..b635c22 --- /dev/null +++ b/management/templates/management/newmedia-management-create-menu.html @@ -0,0 +1,107 @@ +{% extends 'dashboard/base/base.html' %} +{% load static %} +{% block css %} + + + + + +{% endblock %} +{% block content %} + +
+
+ {% include 'dashboard/base/left.html' %} +
+
+
+ + {% if messages %} + + {% endif %} +
+
+ +
+

新建新媒体

+
+
+
+ + +
+
+
+

新媒体列表

+
+
+
+
+
+ +
+
+ 微信 +
+
+
+
+ +
+
+ 微博 +
+
+
+
+ +
+
+ 今日头条 +
+
+
+
+ +
+
+ 其他新媒体 +
+
+
+
+
+
+
+
+
+
+
+ +{% endblock %} +{% block add_js %} + + +{% endblock %} diff --git a/management/templates/management/newmedia-management-create-weixin.html b/management/templates/management/newmedia-management-create-weixin.html new file mode 100644 index 0000000..763ed05 --- /dev/null +++ b/management/templates/management/newmedia-management-create-weixin.html @@ -0,0 +1,105 @@ +{% extends 'dashboard/base/base.html' %} +{% load static %} +{% block content %} + + + + +
+ +
+ {% include 'dashboard/base/left.html' %} +
+
+
+ {% if messages %} + + {% endif %} +
+
+ +
+

新建新媒体

+
+
+
+ +
+
+
+

新建微信

+
+
+
+
+
{% csrf_token %} +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+ + +
+
+
+
+
+
+
+
+
+ +{% endblock %} + diff --git a/management/templates/management/newmedia-management-edit-menu.html b/management/templates/management/newmedia-management-edit-menu.html new file mode 100644 index 0000000..5e44f7f --- /dev/null +++ b/management/templates/management/newmedia-management-edit-menu.html @@ -0,0 +1,107 @@ +{% extends 'dashboard/base/base.html' %} +{% load static %} +{% block css %} + + + + + +{% endblock %} +{% block content %} + +
+
+ {% include 'dashboard/base/left.html' %} +
+
+
+ + {% if messages %} + + {% endif %} +
+
+ +
+

编辑新媒体

+
+
+
+ + +
+
+
+

新媒体列表

+
+
+
+
+
+ +
+
+ 微信 +
+
+
+
+ +
+
+ 微博 +
+
+
+
+ +
+
+ 今日头条 +
+
+
+
+ +
+
+ 其他新媒体 +
+
+
+
+
+
+
+
+
+
+
+ +{% endblock %} +{% block add_js %} + + +{% endblock %} diff --git a/management/templates/management/newmedia-management-edit-weixin.html b/management/templates/management/newmedia-management-edit-weixin.html new file mode 100644 index 0000000..5b74106 --- /dev/null +++ b/management/templates/management/newmedia-management-edit-weixin.html @@ -0,0 +1,82 @@ +{% extends 'dashboard/base/base.html' %} +{% load static %} +{% block css %} + + +{% endblock %} +{% block content %} + +
+
+ {% include 'dashboard/base/left.html' %} +
+
+
+
+
+
+

新媒体编辑

+
+
+
+
+
+
+

微信公众号列表

+
+
+
+
+
{{ g_u.username }} {{ g_u.name }} {{ g_u.organization }}{{ g_u.organization }}{{ g_u.administrativedivision }} - 删除
+ + + + + + + + + + + + + + {% for w in res %} + + + + + + + + + + + {% endfor %} + +
图标新媒体名称新媒体ID责任主体主体类型行政区划状态操作
{{ w.code }}{{ w.weixinid }}{{ w.organization }}{{ w.organization_type }}{{ w.administrativedivision }}{{ w.status }} + 删除 +
+ +
+
+ + + + + +
+
+ + +{% endblock %} +{% block add_js %} + + + +{% endblock %} diff --git a/management/templates/management/organization-management-create.html b/management/templates/management/organization-management-create.html index c62b2b7..dde77f9 100644 --- a/management/templates/management/organization-management-create.html +++ b/management/templates/management/organization-management-create.html @@ -27,7 +27,7 @@
-

编辑单位

+

新建单位

diff --git a/management/urls.py b/management/urls.py index 70ae448..0ea8b1f 100644 --- a/management/urls.py +++ b/management/urls.py @@ -12,12 +12,22 @@ urlpatterns = [ path('group/update//', views.group_update, name='group-management-update'), path('group/delete//', views.group_delete, name='group-management-delete'), - #添加管理员 + # 添加群组管理员、成员 + path('group/admin/create//', views.group_admin_create, name='group-admin-create'), + path('group/admin/delete///', views.group_admin_delete, name='group-admin-delete'), + path('group/user/create//', views.group_user_create, name='group-user-create'), + path('group/user/delete///', views.group_user_delete, name='group-user-delete'), - #主体单位管理 - path('organization/management/',views.organization_management,name='organization-management-management'), - 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'), + # 主体单位管理 + path('organization/management/', views.organization_management, name='organization-management-management'), + 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'), + + #新媒体管理 + path('newmedia/management/create/menu/',views.newmedia_management_create_menu,name='newmedia-management-create-menu'), + path('newmedia/management/edit/menu/',views.newmedia_management_edit_menu,name='newmedia-management-edit-menu'), + path('newmedia/management/create/weixin/',views.newmedia_management_create_weixin,name='newmedia-management-create-weixin'), + path('newmedia/management/edit/weixin/',views.newmedia_management_edit_weixin,name='newmedia-management-edit-weixin'), ] diff --git a/management/views.py b/management/views.py index 1611182..3fb1356 100644 --- a/management/views.py +++ b/management/views.py @@ -80,6 +80,7 @@ def group_update(request, pk): group_status_choices_list.append(list(g)[1]) group_type = Group_type.objects.all() group_admin = Group_admin.objects.filter(group_id=pk) + print(pk) g_a_list = [] for g_a in group_admin: o = dict() @@ -88,7 +89,8 @@ def group_update(request, pk): o['username'] = g_a.user.username o['name'] = Userprofile.objects.get(user_id=g_a.user.id).name o['organization'] = Userprofile.objects.get(user_id=g_a.user.id).organization.name - o['administrativedivision'] = str(g_a.group.province)+'-'+str(g_a.group.cities)+'-'+str(g_a.group.district)+'-'+str(g_a.group.town)+'-'+str(g_a.group.village) + o['administrativedivision'] = str(g_a.group.province) + '-' + str(g_a.group.cities) + '-' + str( + g_a.group.district) + '-' + str(g_a.group.town) + '-' + str(g_a.group.village) g_a_list.append(o) group_user = Group_user.objects.filter(group_id=pk) g_u_list = [] @@ -205,6 +207,53 @@ def group_create(request): {'group_status_choices_list': group_status_choices_list, 'group_type': group_type}) +def group_admin_create(request, pk): + if request.method == 'POST': + user = request.POST.get("user") + print(user) + results = Group_admin.objects.filter(user_id=user, group_id=pk).count() + if results != 0: + messages.success(request, "该管理员已经存在") + return HttpResponseRedirect('/management/group/update/%s/' % (pk)) + group_admin = Group_admin(user_id=user, group_id=pk) + group_admin.save() + messages.success(request, "添加成功") + return HttpResponseRedirect('/management/group/update/%s/' % (pk)) + group = Group.objects.get(id=pk).name + user = User.objects.all() + return render(request, 'management/group-admin-create.html', {'usee': user, 'group': group, 'pk': pk}) + + +def group_admin_delete(request, pk, group_pk): + group_admin = Group_admin.objects.get(id=pk) + group_admin.delete() + messages.success(request, '删除成功') + return HttpResponseRedirect('/management/group/update/%s/' % (group_pk)) + + +def group_user_create(request, pk): + if request.method == 'POST': + user = request.POST.get('user') + results = Group_user.objects.filter(user_id=user, group_id=pk).count() + if results != 0: + messages.success(request, "该成员已经存在") + return HttpResponseRedirect('/management/group/update/%s/' % (pk)) + group_user = Group_user(user_id=user, group_id=pk) + group_user.save() + messages.success(request, '添加成功') + return HttpResponseRedirect('/management/group/update/%s' % (pk)) + group = Group.objects.get(id=pk).name + user = User.objects.all() + return render(request, 'management/group-user-create.html', {'usee': user, 'group': group, 'pk': pk}) + + +def group_user_delete(request, pk, group_pk): + group_user = Group_user.objects.get(id=pk) + group_user.delete() + messages.success(request, '删除成功') + return HttpResponseRedirect('/management/group/update/%s/' % (group_pk)) + + def group_delete(request, pk): group = Group.objects.get(id=pk) group.delete() @@ -342,3 +391,76 @@ def organization_create(request): messages.error(request, '单位名不能为空') return HttpResponseRedirect('/management/organization/management/') return render(request, 'management/organization-management-create.html', {'organizationtype': organizationtype}) + + +def newmedia_management_create_menu(request): + return render(request, 'management/newmedia-management-create-menu.html') + + +def newmedia_management_create_weixin(request): + WEIXIN_STATUS_CHOICES = Weixin.WEIXIN_STATUS_CHOICES + weixin_status_choices_list = [] + for w in WEIXIN_STATUS_CHOICES: + weixin_status_choices_list.append(list(w)[1]) + organization = Organization.objects.all() + if request.method == 'POST': + code = request.POST.get('code') + weixinid = request.POST.get('weixinid') + alias = request.POST.get('alias') + image = request.FILES.get('image') + organization = request.POST.get('organization') + status = request.POST.get('status') + if code is not None: + if organization is not None: + if image is not None: + weixin = Weixin(code=code, weixinid=weixinid, alias=alias, image=image, + organization_id=organization, status=status) + weixin.save() + messages.success(request, '创建成功') + return HttpResponseRedirect('/management/newmedia/management/create/weixin/') + else: + weixin = Weixin(code=code, weixinid=weixinid, alias=alias, image='cover/weixin.PNG', + organization_id=organization, status=status) + weixin.save() + messages.success(request, '创建成功') + return HttpResponseRedirect('/management/newmedia/management/create/weixin/') + else: + messages.success(request, "请选择单位") + return render(request, 'management/newmedia-management-create-weixin.html', + {'weixin_status_choices_list': weixin_status_choices_list, "organization": organization}) + else: + messages.success(request, "微信公众号不能为空") + return render(request, 'management/newmedia-management-create-weixin.html', + {'weixin_status_choices_list': weixin_status_choices_list, "organization": organization}) + return render(request, 'management/newmedia-management-create-weixin.html', + {'weixin_status_choices_list': weixin_status_choices_list, "organization": organization}) + + +def newmedia_management_edit_menu(request): + return render(request, 'management/newmedia-management-edit-menu.html') + + +def newmedia_management_edit_weixin(request): + weixin = Weixin.objects.all() + 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) + res = [] + for w in weixin: + o = dict() + o['id'] = str(w.id) + o['image'] = w.image + o['code'] = w.code + o['weixinid'] = w.weixinid + o['organization'] = w.organization.name + o['organization_type'] = w.organization.organizationtype.organizationtype + o['administrativedivision'] = str(w.organization.province) + '-' + str(w.organization.cities) + '-' + str( + w.organization.district) + '-' + str(w.organization.town) + '-' + str(w.organization.village) + o['status'] = w.status + res.append(o) + return render(request, 'management/newmedia-management-edit-weixin.html', {'weixin': weixin,'res':res})