#用户注册修改
This commit is contained in:
parent
e28948c3bd
commit
5084800861
|
@ -59,16 +59,24 @@
|
|||
|
||||
<form name="loginform" id="loginform" action="{% url 'dashboard-register' %}" method="post"
|
||||
enctype="multipart/form-data">{% csrf_token %}
|
||||
{# <p style="display: inline-block">#}
|
||||
{# <label for="name">单位<br/>#}
|
||||
{# <select class="form-control" name="organization">#}
|
||||
{# {% for o in organization %}#}
|
||||
{# <option value="{{ o.id }}">{{ o.name }}</option>#}
|
||||
{# {% endfor %}#}
|
||||
{# </select>#}
|
||||
{# </label>#}
|
||||
{# </p>#}
|
||||
<p style="display: inline-block">
|
||||
<label for="name">单位<br/>
|
||||
<select class="form-control" name="organization">
|
||||
{% for o in organization %}
|
||||
<option value="{{ o.id }}">{{ o.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<input type="text" id="search-text" name="organization">
|
||||
<p><span id='search-result'></span></p>
|
||||
</label>
|
||||
</p>
|
||||
<a href="{% url 'organization-management-create' %}"><span class="glyphicon glyphicon-plus" aria-hidden="true" style="margin-left: 40px"></span></a>
|
||||
<a href="{% url 'organization-management-create' %}"><span class="glyphicon glyphicon-plus"
|
||||
aria-hidden="true"
|
||||
style="margin-left: 40px"></span></a>
|
||||
<p>
|
||||
<label for="name">姓名<br/>
|
||||
<input type="text" name="name" id="user_login" class="input" value="" size="20"/></label>
|
||||
|
@ -88,12 +96,13 @@
|
|||
</p>
|
||||
<p>
|
||||
<label for="phone">电话<br/>
|
||||
<input type="text" name="username" id="user_login" class="input" value="" size="20"/></label>
|
||||
<input type="text" name="username" id="user_login" class="input" value="" size="20"/>
|
||||
</label>
|
||||
</p>
|
||||
{# <p>#}
|
||||
{# <label for="username">用户名<br/>#}
|
||||
{# <input type="text" name="username" id="user_login" class="input" value="" size="20"/></label>#}
|
||||
{# </p>#}
|
||||
{# <p>#}
|
||||
{# <label for="username">用户名<br/>#}
|
||||
{# <input type="text" name="username" id="user_login" class="input" value="" size="20"/></label>#}
|
||||
{# </p>#}
|
||||
<p>
|
||||
<label for="password">密码<br/>
|
||||
<input type="password" name="password" id="user_pass" class="input" value="" size="20"/></label>
|
||||
|
@ -183,6 +192,22 @@
|
|||
});
|
||||
|
||||
});
|
||||
$("#search-text").keyup(function () {
|
||||
var q = $("#search-text").val();
|
||||
$.getJSON("/get/organization/", {'q': q}, function (data) {
|
||||
console.log(data[0].name)
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
$('#search-result').append(data[i].name + '<br/>')
|
||||
}
|
||||
;
|
||||
})
|
||||
});
|
||||
$('#search-text').keydown(function () {
|
||||
$('#search-result').empty();
|
||||
})
|
||||
$('#search-text').blur(function () {
|
||||
$('#search-result').empty();
|
||||
})
|
||||
})
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -17,5 +17,7 @@ urlpatterns = [
|
|||
path('get/district/',views.get_district),
|
||||
path('get/town/',views.get_town),
|
||||
path('get/village/',views.get_village),
|
||||
#单位搜索
|
||||
path('get/organization/',views.get_organization)
|
||||
|
||||
]
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import json
|
||||
|
||||
from captcha.helpers import captcha_image_url
|
||||
from captcha.models import CaptchaStore
|
||||
from dateutil import relativedelta
|
||||
|
@ -5,7 +7,7 @@ from django.contrib import messages
|
|||
from django.contrib.auth import logout, authenticate, login
|
||||
from django.contrib.auth.models import User
|
||||
from django.db.models import Q
|
||||
from django.http import HttpResponseRedirect, JsonResponse
|
||||
from django.http import HttpResponseRedirect, JsonResponse, HttpResponse
|
||||
from django.shortcuts import render
|
||||
import datetime
|
||||
|
||||
|
@ -109,10 +111,6 @@ def register(request):
|
|||
messages.error(request, '请输入邮箱')
|
||||
else:
|
||||
email = request.POST.get('email')
|
||||
# if not request.POST.get('phone'):
|
||||
# messages.error(request, '请输入电话')
|
||||
# else:
|
||||
# phone = request.POST.get('phone')
|
||||
if not request.POST.get('username'):
|
||||
messages.error(request, '请输入用户名')
|
||||
else:
|
||||
|
@ -172,7 +170,7 @@ def register(request):
|
|||
|
||||
def get_province(request):
|
||||
# 省
|
||||
province = Area_code_2020.objects.filter(level=1,name='甘肃省')
|
||||
province = Area_code_2020.objects.filter(level=1, name='甘肃省')
|
||||
res = []
|
||||
for i in province:
|
||||
res.append([i.code, i.name, i.level, i.pcode])
|
||||
|
@ -220,4 +218,22 @@ def get_village(request):
|
|||
return JsonResponse({"village": res})
|
||||
|
||||
|
||||
|
||||
def get_organization(request):
|
||||
q = request.GET.get('q')
|
||||
organization = Organization.objects.filter(name__contains=q)[:20]
|
||||
res = []
|
||||
for o in organization:
|
||||
d = dict()
|
||||
d['name'] = o.name
|
||||
d['province'] = Area_code_2020.objects.get(code=o.province).name
|
||||
if o.cities:
|
||||
d['cities'] = Area_code_2020.objects.get(code=o.cities).name
|
||||
else:
|
||||
d['cities'] = ''
|
||||
if o.district:
|
||||
d['district'] = Area_code_2020.objects.get(code=o.district).name
|
||||
else:
|
||||
d['district'] = ''
|
||||
res.append(d)
|
||||
print(res)
|
||||
return HttpResponse(json.dumps(res))
|
||||
|
|
|
@ -582,7 +582,12 @@ def organization_create(request):
|
|||
level = Level.objects.all()
|
||||
if request.method == 'POST':
|
||||
name = request.POST.get('name')
|
||||
image = None
|
||||
if request.FILES.get('image'):
|
||||
image = request.FILES.get('image')
|
||||
else:
|
||||
image = 'danweimoren.jpg'
|
||||
|
||||
organizationtype = request.POST.get('organizationtype')
|
||||
level_id = request.POST.get('level_id')
|
||||
province = request.POST.get('province')
|
||||
|
@ -595,15 +600,20 @@ def organization_create(request):
|
|||
district = request.POST.get('district')
|
||||
town = request.POST.get('town')
|
||||
village = request.POST.get('village')
|
||||
results = Organization.objects.filter(name=name).count()
|
||||
if results > 0:
|
||||
messages.error(request, '您注册的主体已经存在')
|
||||
return HttpResponseRedirect('/management/organization/create/')
|
||||
if name is not None:
|
||||
organization = Organization(name=name, image=image, organizationtype_id=organizationtype,
|
||||
province=province, cities=city, district=district, town=town,
|
||||
village=village, level_id=level_id, status='0')
|
||||
organization.save()
|
||||
messages.success(request, '添加成功')
|
||||
return HttpResponseRedirect('/management/organization/management/')
|
||||
else:
|
||||
messages.error(request, '单位名不能为空')
|
||||
# return HttpResponseRedirect('/management/organization/management/')
|
||||
return HttpResponseRedirect('/management/organization/create/')
|
||||
return render(request, 'management/organization-management-create.html',
|
||||
{'organizationtype': organizationtype, 'level': level})
|
||||
|
||||
|
|
Loading…
Reference in New Issue