#更改数据库
This commit is contained in:
parent
66a0d92483
commit
310a8a7024
|
@ -121,7 +121,7 @@
|
||||||
<option value="{{ group.classify }}">行业</option>
|
<option value="{{ group.classify }}">行业</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for g in g_c_c_res %}
|
{% for g in g_c_c_res %}
|
||||||
<option value="{{ g }}">{{ g }}</option>
|
<option value="{{ g.0 }}">{{ g.1 }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -45,13 +45,26 @@
|
||||||
enctype="multipart/form-data">{% csrf_token %}
|
enctype="multipart/form-data">{% csrf_token %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="form-label" for="organization">单位</label>
|
<label class="form-label" for="organization">单位</label>
|
||||||
<div class="controls">
|
{# <div class="controls">#}
|
||||||
<select class="form-control" name="organization">
|
{# <select class="form-control" name="organization">#}
|
||||||
<option value="{{ userprofile.organization.id }}">{{ userprofile.organization.name }}</option>
|
{# <option value="{{ userprofile.organization.id }}">{{ userprofile.organization.name }}</option>#}
|
||||||
{% for o in organization %}
|
{# {% for o in organization %}#}
|
||||||
<option value="{{ o.id }}">{{ o.name }}</option>
|
{# <option value="{{ o.id }}">{{ o.name }}</option>#}
|
||||||
{% endfor %}
|
{# {% endfor %}#}
|
||||||
</select>
|
{# </select>#}
|
||||||
|
|
||||||
|
{# </div>#}
|
||||||
|
<div class="input-group main-search">
|
||||||
|
<input type="text" class="form-control" placeholder="请输入关键字"
|
||||||
|
style="height: 40px;width: 985px;opacity: .9 "
|
||||||
|
name="organization" value="{{ userprofile.organization.name }}">
|
||||||
|
<div class="input-group-btn" style="display: none">
|
||||||
|
<button class="btn btn-default" type="button">
|
||||||
|
<span class="glyphicon glyphicon-search"></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="autocomplete-panel" style="z-index: 9999">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -116,4 +129,34 @@
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
{% block add_js %}
|
||||||
|
<script>
|
||||||
|
$(function () {
|
||||||
|
$('.main-search input').focus(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
$("#history_query").hide()
|
||||||
|
var width = $(this).width();
|
||||||
|
var position = $(this).position();
|
||||||
|
var val = $(this).val();
|
||||||
|
var params = {keyword: val}
|
||||||
|
if (val) {
|
||||||
|
$('.autocomplete-panel').load('/get/organization/' + '?' + $.param(params));
|
||||||
|
}
|
||||||
|
$('.autocomplete-panel').css({
|
||||||
|
width: width + 12,
|
||||||
|
top: position.top + 34,
|
||||||
|
left: position.left + 5
|
||||||
|
}).show();
|
||||||
|
}).blur(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
}).on('input', function (e) {
|
||||||
|
var val = $(this).val();
|
||||||
|
var params = {keyword: val}
|
||||||
|
$('.autocomplete-panel').load('/get/organization/' + '?' + $.param(params))
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,8 @@ def user_update(request, pk):
|
||||||
userprofile = Userprofile.objects.get(user_id=user.id)
|
userprofile = Userprofile.objects.get(user_id=user.id)
|
||||||
organization = Organization.objects.filter(status='1')
|
organization = Organization.objects.filter(status='1')
|
||||||
if request.method == 'POST':
|
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')
|
name = request.POST.get('name')
|
||||||
email = request.POST.get('email')
|
email = request.POST.get('email')
|
||||||
username = request.POST.get('username')
|
username = request.POST.get('username')
|
||||||
|
@ -120,7 +121,7 @@ def user_update(request, pk):
|
||||||
user.email = email
|
user.email = email
|
||||||
user.username = username
|
user.username = username
|
||||||
user.password = make_password(passwordnew)
|
user.password = make_password(passwordnew)
|
||||||
userprofile.organization_id = organization_id
|
userprofile.organization_id = o_id
|
||||||
userprofile.name = name
|
userprofile.name = name
|
||||||
if image is not None:
|
if image is not None:
|
||||||
userprofile.image = image
|
userprofile.image = image
|
||||||
|
@ -134,7 +135,7 @@ def user_update(request, pk):
|
||||||
else:
|
else:
|
||||||
user.email = email
|
user.email = email
|
||||||
user.username = username
|
user.username = username
|
||||||
userprofile.organization_id = organization_id
|
userprofile.organization_id = o_id
|
||||||
userprofile.name = name
|
userprofile.name = name
|
||||||
if image is not None:
|
if image is not None:
|
||||||
userprofile.image = image
|
userprofile.image = image
|
||||||
|
@ -259,7 +260,7 @@ def group_update(request, pk):
|
||||||
GROUP_CLASSIFY_CHOICES = Group.GROUP_CLASSIFY_CHOICES
|
GROUP_CLASSIFY_CHOICES = Group.GROUP_CLASSIFY_CHOICES
|
||||||
g_c_c_res = []
|
g_c_c_res = []
|
||||||
for g_c_c in GROUP_CLASSIFY_CHOICES:
|
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_type = Group_type.objects.all()
|
||||||
group_admin = Group_admin.objects.filter(group_id=pk)
|
group_admin = Group_admin.objects.filter(group_id=pk)
|
||||||
print(pk)
|
print(pk)
|
||||||
|
@ -271,8 +272,26 @@ def group_update(request, pk):
|
||||||
o['username'] = g_a.user.username
|
o['username'] = g_a.user.username
|
||||||
o['name'] = Userprofile.objects.get(user_id=g_a.user.id).name
|
o['name'] = Userprofile.objects.get(user_id=g_a.user.id).name
|
||||||
o['organization'] = Userprofile.objects.get(user_id=g_a.user.id).organization.name
|
o['organization'] = Userprofile.objects.get(user_id=g_a.user.id).organization.name
|
||||||
o['administrativedivision'] = str(g_a.group.province) + '-' + str(g_a.group.cities) + '-' + str(
|
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:
|
||||||
g_a.group.district) + '-' + str(g_a.group.town) + '-' + str(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)
|
g_a_list.append(o)
|
||||||
group_user = Group_user.objects.filter(group_id=pk)
|
group_user = Group_user.objects.filter(group_id=pk)
|
||||||
g_u_list = []
|
g_u_list = []
|
||||||
|
@ -283,8 +302,26 @@ def group_update(request, pk):
|
||||||
i['username'] = g_u.user.username
|
i['username'] = g_u.user.username
|
||||||
i['name'] = Userprofile.objects.get(user_id=g_u.user.id).name
|
i['name'] = Userprofile.objects.get(user_id=g_u.user.id).name
|
||||||
i['organization'] = Userprofile.objects.get(user_id=g_u.user.id).organization.name
|
i['organization'] = Userprofile.objects.get(user_id=g_u.user.id).organization.name
|
||||||
i['administrativedivision'] = str(g_u.group.province) + '-' + str(g_u.group.cities) + '-' + str(
|
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:
|
||||||
g_u.group.district) + '-' + str(g_u.group.town) + '-' + str(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)
|
g_u_list.append(i)
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
name = request.POST.get('name')
|
name = request.POST.get('name')
|
||||||
|
@ -613,8 +650,18 @@ def organization_update(request, pk):
|
||||||
|
|
||||||
|
|
||||||
def organization_create(request):
|
def organization_create(request):
|
||||||
organizationtype = Organizationtype.objects.all()
|
user = request.user
|
||||||
level = Level.objects.all()
|
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':
|
if request.method == 'POST':
|
||||||
name = request.POST.get('name')
|
name = request.POST.get('name')
|
||||||
image = None
|
image = None
|
||||||
|
@ -650,7 +697,7 @@ def organization_create(request):
|
||||||
messages.error(request, '单位名不能为空')
|
messages.error(request, '单位名不能为空')
|
||||||
return HttpResponseRedirect('/management/organization/create/')
|
return HttpResponseRedirect('/management/organization/create/')
|
||||||
return render(request, 'management/organization-management-create.html',
|
return render(request, 'management/organization-management-create.html',
|
||||||
{'organizationtype': organizationtype, 'level': level})
|
{'level': level})
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
|
Loading…
Reference in New Issue