diff --git a/management/templates/management/group-management-update.html b/management/templates/management/group-management-update.html index 5f83a5d..cf0f86c 100644 --- a/management/templates/management/group-management-update.html +++ b/management/templates/management/group-management-update.html @@ -121,7 +121,7 @@ {% endif %} {% for g in g_c_c_res %} - + {% endfor %} diff --git a/management/templates/management/user-management-update.html b/management/templates/management/user-management-update.html index d16b0ef..0ecbb68 100644 --- a/management/templates/management/user-management-update.html +++ b/management/templates/management/user-management-update.html @@ -1,119 +1,162 @@ -{% extends 'dashboard/base/base.html' %} -{% load static %} -{% block content %} - - - - -
- -
- {% include 'dashboard/base/left.html' %} -
-
-
- {% if messages %} - - {% endif %} -
-
- -
-

系统设置

-
-
-
- -
-
-
-

用户信息

-
-
-
-
-
{% csrf_token %} -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
- -
- -
-
- -
-
- -
-
- -
- -
-
-
-
-
-
-
-
-
-
- -{% endblock %} - +{% extends 'dashboard/base/base.html' %} +{% load static %} +{% block content %} + + + + +
+ +
+ {% include 'dashboard/base/left.html' %} +
+
+
+ {% if messages %} + + {% endif %} +
+
+ +
+

系统设置

+
+
+
+ +
+
+
+

用户信息

+
+
+
+
+
{% csrf_token %} +
+ + {#
#} + {# #} + + {#
#} + +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+ +{% endblock %} +{% block add_js %} + +{% endblock %} + diff --git a/management/views.py b/management/views.py index 41e71c1..4775d6c 100644 --- a/management/views.py +++ b/management/views.py @@ -52,8 +52,8 @@ def user_management(request): print(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: + 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( @@ -63,7 +63,7 @@ def user_management(request): '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: + 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( @@ -106,7 +106,8 @@ def user_update(request, pk): userprofile = Userprofile.objects.get(user_id=user.id) organization = Organization.objects.filter(status='1') if request.method == 'POST': - organization_id = request.POST.get('organization') + o = request.POST.get('organization') + o_id = Organization.objects.get(name=o).id name = request.POST.get('name') email = request.POST.get('email') username = request.POST.get('username') @@ -120,7 +121,7 @@ def user_update(request, pk): user.email = email user.username = username user.password = make_password(passwordnew) - userprofile.organization_id = organization_id + userprofile.organization_id = o_id userprofile.name = name if image is not None: userprofile.image = image @@ -134,7 +135,7 @@ def user_update(request, pk): else: user.email = email user.username = username - userprofile.organization_id = organization_id + userprofile.organization_id = o_id userprofile.name = name if image is not None: userprofile.image = image @@ -259,7 +260,7 @@ def group_update(request, pk): GROUP_CLASSIFY_CHOICES = Group.GROUP_CLASSIFY_CHOICES g_c_c_res = [] for g_c_c in GROUP_CLASSIFY_CHOICES: - g_c_c_res.append(list(g_c_c)[1]) + g_c_c_res.append([list(g_c_c)[0], list(g_c_c)[1]]) group_type = Group_type.objects.all() group_admin = Group_admin.objects.filter(group_id=pk) print(pk) @@ -271,8 +272,26 @@ 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) + if g_a.group.province and g_a.group.cities and g_a.group.district and g_a.group.town and g_a.group.village: + o['administrativedivision'] = str(Area_code_2020.objects.get(code=g_a.group.province).name) + '-' + str( + Area_code_2020.objects.get(code=g_a.group.cities).name) + '-' + str( + Area_code_2020.objects.get(code=g_a.group.district).name) + '-' + str( + Area_code_2020.objects.get(code=g_a.group.town).name) + '-' + str( + Area_code_2020.objects.get(code=g_a.group.village).name) + elif g_a.group.province and g_a.group.cities and g_a.group.district and g_a.group.town: + o['administrativedivision'] = str(Area_code_2020.objects.get(code=g_a.group.province).name) + '-' + str( + Area_code_2020.objects.get(code=g_a.group.cities).name) + '-' + str( + Area_code_2020.objects.get(code=g_a.group.district).name) + '-' + str( + Area_code_2020.objects.get(code=g_a.group.town).name) + elif g_a.group.province and g_a.group.cities and g_a.group.district: + o['administrativedivision'] = str(Area_code_2020.objects.get(code=g_a.group.province).name) + '-' + str( + Area_code_2020.objects.get(code=g_a.group.cities).name) + '-' + str( + Area_code_2020.objects.get(code=g_a.group.district).name) + elif g_a.group.province and g_a.group.cities: + o['administrativedivision'] = str(Area_code_2020.objects.get(code=g_a.group.province).name) + '-' + str( + Area_code_2020.objects.get(code=g_a.group.cities).name) + elif g_a.group.province: + o['administrativedivision'] = str(Area_code_2020.objects.get(code=g_a.group.province).name) g_a_list.append(o) group_user = Group_user.objects.filter(group_id=pk) g_u_list = [] @@ -283,8 +302,26 @@ def group_update(request, pk): i['username'] = g_u.user.username i['name'] = Userprofile.objects.get(user_id=g_u.user.id).name i['organization'] = Userprofile.objects.get(user_id=g_u.user.id).organization.name - i['administrativedivision'] = str(g_u.group.province) + '-' + str(g_u.group.cities) + '-' + str( - g_u.group.district) + '-' + str(g_u.group.town) + '-' + str(g_u.group.village) + if g_u.group.province and g_u.group.cities and g_u.group.district and g_u.group.town and g_u.group.village: + i['administrativedivision'] = str(Area_code_2020.objects.get(code=g_u.group.province).name) + '-' + str( + Area_code_2020.objects.get(code=g_u.group.cities).name) + '-' + str( + Area_code_2020.objects.get(code=g_u.group.district).name) + '-' + str( + Area_code_2020.objects.get(code=g_u.group.town).name) + '-' + str( + Area_code_2020.objects.get(code=g_u.group.village).name) + elif g_u.group.province and g_u.group.cities and g_u.group.district and g_u.group.town: + i['administrativedivision'] = str(Area_code_2020.objects.get(code=g_u.group.province).name) + '-' + str( + Area_code_2020.objects.get(code=g_u.group.cities).name) + '-' + str( + Area_code_2020.objects.get(code=g_u.group.district).name) + '-' + str( + Area_code_2020.objects.get(code=g_u.group.town).name) + elif g_u.group.province and g_u.group.cities and g_u.group.district: + i['administrativedivision'] = str(Area_code_2020.objects.get(code=g_u.group.province).name) + '-' + str( + Area_code_2020.objects.get(code=g_u.group.cities).name) + '-' + str( + Area_code_2020.objects.get(code=g_u.group.district).name) + elif g_u.group.province and g_u.group.cities: + i['administrativedivision'] = str(Area_code_2020.objects.get(code=g_u.group.province).name) + '-' + str( + Area_code_2020.objects.get(code=g_u.group.cities).name) + elif g_u.group.province: + i['administrativedivision'] = str(Area_code_2020.objects.get(code=g_u.group.province).name) g_u_list.append(i) if request.method == 'POST': name = request.POST.get('name') @@ -613,8 +650,18 @@ def organization_update(request, pk): def organization_create(request): - organizationtype = Organizationtype.objects.all() - level = Level.objects.all() + user = request.user + l = Userprofile.objects.get(user_id=user.id).organization.level.level + if user.is_superuser: + level = Level.objects.filter(level__in=[1, 2, 3, 5, 0]) + elif l == '1': + level = Level.objects.filter(level__in=[2, 3, 5, 0]) + elif l == '2': + level = Level.objects.filter(level__in=[3, 5, 0]) + elif l == '3': + level = Level.objects.filter(level__in=[5, 0]) + else: + level = Level.objects.filter(level__in=[0]) if request.method == 'POST': name = request.POST.get('name') image = None @@ -650,7 +697,7 @@ def organization_create(request): messages.error(request, '单位名不能为空') return HttpResponseRedirect('/management/organization/create/') return render(request, 'management/organization-management-create.html', - {'organizationtype': organizationtype, 'level': level}) + {'level': level}) @login_required @@ -1408,8 +1455,8 @@ def newmedia_management_update_douyin(request, pk): if image is not None: Douyin.objects.filter(id=pk).update(code=code, douyinid=douyinid, alias=alias, organization_id=o_id, status=status, - identificationcode=identificationcode, function=function, - articleurl=articleurl) + identificationcode=identificationcode, function=function, + articleurl=articleurl) douyin.image = image douyin.save() messages.success(request, '修改成功') @@ -1417,8 +1464,8 @@ def newmedia_management_update_douyin(request, pk): else: Douyin.objects.filter(id=pk).update(code=code, douyinid=douyinid, alias=alias, organization_id=o_id, status=status, - identificationcode=identificationcode, function=function, - articleurl=articleurl) + identificationcode=identificationcode, function=function, + articleurl=articleurl) messages.success(request, '修改成功') return HttpResponseRedirect('/management/newmedia/management/edit/douyin/') else: @@ -1460,8 +1507,8 @@ def newmedia_management_update_qita(request, pk): if image is not None: Qita.objects.filter(id=pk).update(type=type, code=name, qitaid=qitaid, alias=alias, organization_id=o_id, status=status, - identificationcode=identificationcode, function=function, - articleurl=articleurl) + identificationcode=identificationcode, function=function, + articleurl=articleurl) qita.image = image qita.save() messages.success(request, '修改成功') @@ -1469,8 +1516,8 @@ def newmedia_management_update_qita(request, pk): else: Qita.objects.filter(id=pk).update(type=type, code=name, qitaid=qitaid, alias=alias, organization_id=o_id, status=status, - identificationcode=identificationcode, function=function, - articleurl=articleurl) + identificationcode=identificationcode, function=function, + articleurl=articleurl) messages.success(request, '修改成功') return HttpResponseRedirect('/management/newmedia/management/edit/qita/') else: