#单位管理,群组管理,用户管理
This commit is contained in:
parent
5e6577bada
commit
fbd99ad1d3
File diff suppressed because it is too large
Load Diff
|
@ -1,7 +1,7 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
from dashboard.models import Userprofile, Organization, Group, Level
|
||||
from dashboard.models import Userprofile, Organization, Group, Level, Organizationtype, Group_type
|
||||
|
||||
|
||||
class UserProfileAdmin(admin.ModelAdmin):
|
||||
|
@ -22,3 +22,9 @@ admin.site.register(Group,GroupAdmin)
|
|||
class LevelAdmin(admin.ModelAdmin):
|
||||
list_display = ('id',)
|
||||
admin.site.register(Level,LevelAdmin)
|
||||
class OrganizationtypeAdmin(admin.ModelAdmin):
|
||||
list_display = ('id',)
|
||||
admin.site.register(Organizationtype,OrganizationtypeAdmin)
|
||||
class Group_typeAdmin(admin.ModelAdmin):
|
||||
list_display = ('id',)
|
||||
admin.site.register(Group_type,Group_typeAdmin)
|
||||
|
|
|
@ -5,17 +5,56 @@ from django.db import models
|
|||
|
||||
|
||||
# Create your models here.
|
||||
# 组
|
||||
class Group_type(models.Model):
|
||||
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
|
||||
type = models.CharField('群组类型',max_length=256,null=True,blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.type
|
||||
# 群组
|
||||
class Group(models.Model):
|
||||
GROUP_STATUS_CHOICES = (
|
||||
('0','关闭'),
|
||||
('1','开启')
|
||||
)
|
||||
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
|
||||
name = models.CharField('组名', max_length=256, null=True, blank=True)
|
||||
name = models.CharField('群组名称', max_length=256, null=True, blank=True)
|
||||
presentation = models.TextField('群组描述', null=True, blank=True)
|
||||
image = models.FileField(upload_to='groupimage', null=True, blank=True)
|
||||
type = models.ForeignKey(Group_type,on_delete=models.CASCADE,null=True,blank=True)
|
||||
status = models.CharField('状态',max_length=256,null=True,blank=True,choices=GROUP_STATUS_CHOICES)
|
||||
province = models.CharField('省', max_length=256, null=True, blank=True)
|
||||
cities = models.CharField('市', max_length=256, null=True, blank=True)
|
||||
district = models.CharField('县', max_length=256, null=True, blank=True)
|
||||
town = models.CharField('乡', max_length=256, null=True, blank=True)
|
||||
village = models.CharField('村', max_length=256, null=True, blank=True)
|
||||
|
||||
created = models.DateTimeField('创建时间', auto_now_add=True)
|
||||
updated = models.DateTimeField('更新时间', auto_now=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
#群组管理员
|
||||
class Group_admin(models.Model):
|
||||
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True)
|
||||
group = models.ForeignKey(Group, on_delete=models.CASCADE, null=True, blank=True)
|
||||
created = models.DateTimeField('创建时间', auto_now_add=True)
|
||||
updated = models.DateTimeField('更新时间', auto_now=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.group.name
|
||||
#群组成员
|
||||
class Group_user(models.Model):
|
||||
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True)
|
||||
group = models.ForeignKey(Group, on_delete=models.CASCADE, null=True, blank=True)
|
||||
created = models.DateTimeField('创建时间', auto_now_add=True)
|
||||
updated = models.DateTimeField('更新时间', auto_now=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.user.username
|
||||
# 权限等级
|
||||
class Level(models.Model):
|
||||
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
|
||||
|
@ -27,14 +66,30 @@ class Level(models.Model):
|
|||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
#单位类型
|
||||
class Organizationtype(models.Model):
|
||||
id = models.UUIDField('id',primary_key=True,default=uuid.uuid4)
|
||||
organizationtype = models.CharField('单位类型',blank=True,null=True,max_length=256)
|
||||
created = models.DateTimeField('创建时间', auto_now_add=True)
|
||||
updated = models.DateTimeField('更新时间', auto_now=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.organizationtype
|
||||
|
||||
|
||||
# 单位
|
||||
class Organization(models.Model):
|
||||
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
|
||||
name = models.CharField('单位名', max_length=256, null=True, blank=True)
|
||||
group = models.ForeignKey(Group, on_delete=models.CASCADE)
|
||||
level = models.ForeignKey(Level,on_delete=models.CASCADE,null=True,blank=True)
|
||||
image = models.FileField(upload_to='cover', null=True, blank=True)
|
||||
organizationtype = models.ForeignKey(Organizationtype,on_delete=models.CASCADE, null=True, blank=True)
|
||||
province = models.CharField('省',max_length=256,null=True,blank=True)
|
||||
cities = models.CharField('市',max_length=256,null=True,blank=True)
|
||||
district = models.CharField('县',max_length=256,null=True,blank=True)
|
||||
town = models.CharField('乡',max_length=256,null=True,blank=True)
|
||||
village = models.CharField('村',max_length=256,null=True,blank=True)
|
||||
# group = models.ForeignKey(Group, on_delete=models.CASCADE, null=True, blank=True)
|
||||
# level = models.ForeignKey(Level,on_delete=models.CASCADE,null=True,blank=True)
|
||||
created = models.DateTimeField('创建时间', auto_now_add=True)
|
||||
updated = models.DateTimeField('更新时间', auto_now=True)
|
||||
|
||||
|
@ -46,8 +101,10 @@ class Organization(models.Model):
|
|||
class Userprofile(models.Model):
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||
name = models.CharField('姓名', null=True, blank=True, max_length=256)
|
||||
sex = models.CharField('性别', null=True, blank=True, max_length=256)
|
||||
image = models.FileField(upload_to='profile', null=True, blank=True)
|
||||
organization = models.ForeignKey(Organization, on_delete=models.CASCADE)
|
||||
organization = models.ForeignKey(Organization, on_delete=models.CASCADE, null=True, blank=True)
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return self.user.username
|
||||
|
@ -65,7 +122,8 @@ def create_user_profile(sender, instance, created, **kwargs):
|
|||
class Weixin(models.Model):
|
||||
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
|
||||
code = models.CharField('微信公众号', max_length=256, null=True, blank=True)
|
||||
organization = models.ForeignKey(Organization, on_delete=models.CASCADE)
|
||||
image = models.FileField(upload_to='cover', null=True, blank=True)
|
||||
organization = models.ForeignKey(Organization, on_delete=models.CASCADE, null=True, blank=True)
|
||||
created = models.DateTimeField('创建时间', auto_now_add=True)
|
||||
updated = models.DateTimeField('更新时间', auto_now=True)
|
||||
|
||||
|
@ -85,7 +143,7 @@ class Weixin_data(models.Model):
|
|||
comment = models.CharField('评论数', max_length=256, null=True, blank=True)
|
||||
reply = models.CharField('作者回复数', max_length=256, null=True, blank=True)
|
||||
content = models.TextField('正文', null=True, blank=True)
|
||||
weixin = models.ForeignKey(Weixin, on_delete=models.CASCADE)
|
||||
weixin = models.ForeignKey(Weixin, on_delete=models.CASCADE, null=True, blank=True)
|
||||
created = models.DateTimeField('创建时间', auto_now_add=True)
|
||||
updated = models.DateTimeField('更新时间', auto_now=True)
|
||||
|
||||
|
@ -99,7 +157,7 @@ class Weixin_comment(models.Model):
|
|||
comment = models.TextField('评论', null=True, blank=True)
|
||||
user = models.CharField('用户', max_length=256, null=True, blank=True)
|
||||
reply = models.TextField('回复', null=True, blank=True)
|
||||
weixin = models.ForeignKey(Weixin, on_delete=models.CASCADE)
|
||||
weixin = models.ForeignKey(Weixin, on_delete=models.CASCADE, null=True, blank=True)
|
||||
created = models.DateTimeField('创建时间', auto_now_add=True)
|
||||
updated = models.DateTimeField('更新时间', auto_now=True)
|
||||
|
||||
|
@ -113,7 +171,7 @@ class Weixin_Wrong(models.Model):
|
|||
wrong = models.CharField('错别字', max_length=256, null=True, blank=True)
|
||||
idea = models.CharField('建议', max_length=256, null=True, blank=True)
|
||||
site = models.CharField('位置', max_length=256, null=True, blank=True)
|
||||
weixin = models.ForeignKey(Weixin, on_delete=models.CASCADE)
|
||||
weixin = models.ForeignKey(Weixin, on_delete=models.CASCADE, null=True, blank=True)
|
||||
change = models.BooleanField('是否已修改', null=True, blank=True)
|
||||
created = models.DateTimeField('创建时间', auto_now_add=True)
|
||||
updated = models.DateTimeField('更新时间', auto_now=True)
|
||||
|
@ -126,7 +184,8 @@ class Weixin_Wrong(models.Model):
|
|||
class Weibo(models.Model):
|
||||
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
|
||||
code = models.CharField('微博号', max_length=256, null=True, blank=True)
|
||||
organization = models.ForeignKey(Organization, on_delete=models.CASCADE)
|
||||
image = models.FileField(upload_to='cover', null=True, blank=True)
|
||||
organization = models.ForeignKey(Organization, on_delete=models.CASCADE, null=True, blank=True)
|
||||
created = models.DateTimeField('创建时间', auto_now_add=True)
|
||||
updated = models.DateTimeField('更新时间', auto_now=True)
|
||||
|
||||
|
@ -150,7 +209,7 @@ class Weibi_data(models.Model):
|
|||
transpond = models.CharField('转发数', max_length=256, null=True, blank=True)
|
||||
comment = models.CharField('评论数', max_length=256, null=True, blank=True)
|
||||
title = models.CharField('文章标题', max_length=256, null=True, blank=True)
|
||||
weibo = models.ForeignKey(Weibo, on_delete=models.CASCADE)
|
||||
weibo = models.ForeignKey(Weibo, on_delete=models.CASCADE, null=True, blank=True)
|
||||
created = models.DateTimeField('创建时间', auto_now_add=True)
|
||||
updated = models.DateTimeField('更新时间', auto_now=True)
|
||||
|
||||
|
@ -164,7 +223,7 @@ class Weibo_Wrong(models.Model):
|
|||
wrong = models.CharField('错别字', max_length=256, null=True, blank=True)
|
||||
idea = models.CharField('建议', max_length=256, null=True, blank=True)
|
||||
site = models.CharField('位置', max_length=256, null=True, blank=True)
|
||||
weibo = models.ForeignKey(Weibo, on_delete=models.CASCADE)
|
||||
weibo = models.ForeignKey(Weibo, on_delete=models.CASCADE, null=True, blank=True)
|
||||
change = models.BooleanField('是否已修改', null=True, blank=True)
|
||||
created = models.DateTimeField('创建时间', auto_now_add=True)
|
||||
updated = models.DateTimeField('更新时间', auto_now=True)
|
||||
|
@ -174,7 +233,8 @@ class Weibo_Wrong(models.Model):
|
|||
class Toutiao(models.Model):
|
||||
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
|
||||
code = models.CharField('头条号', max_length=256, null=True, blank=True)
|
||||
organization = models.ForeignKey(Organization, on_delete=models.CASCADE)
|
||||
image = models.FileField(upload_to='cover', null=True, blank=True)
|
||||
organization = models.ForeignKey(Organization, on_delete=models.CASCADE, null=True, blank=True)
|
||||
created = models.DateTimeField('创建时间', auto_now_add=True)
|
||||
updated = models.DateTimeField('更新时间', auto_now=True)
|
||||
|
||||
|
@ -194,7 +254,7 @@ class Toutiao_data(models.Model):
|
|||
date = models.CharField('时间', max_length=256, null=True, blank=True)
|
||||
content = models.TextField('正文', null=True, blank=True)
|
||||
comment = models.TextField('评论', null=True, blank=True)
|
||||
toutiao = models.ForeignKey(Toutiao, on_delete=models.CASCADE)
|
||||
toutiao = models.ForeignKey(Toutiao, on_delete=models.CASCADE, null=True, blank=True)
|
||||
created = models.DateTimeField('创建时间', auto_now_add=True)
|
||||
updated = models.DateTimeField('更新时间', auto_now=True)
|
||||
|
||||
|
@ -208,7 +268,7 @@ class Toutiao_comment(models.Model):
|
|||
comment = models.TextField('评论', null=True, blank=True)
|
||||
user = models.CharField('用户', max_length=256, null=True, blank=True)
|
||||
reply = models.TextField('回复', null=True, blank=True)
|
||||
toutiao = models.ForeignKey(Toutiao, on_delete=models.CASCADE)
|
||||
toutiao = models.ForeignKey(Toutiao, on_delete=models.CASCADE, null=True, blank=True)
|
||||
created = models.DateTimeField('创建时间', auto_now_add=True)
|
||||
updated = models.DateTimeField('更新时间', auto_now=True)
|
||||
|
||||
|
@ -222,7 +282,7 @@ class Toutiao_Wrong(models.Model):
|
|||
wrong = models.CharField('错别字', max_length=256, null=True, blank=True)
|
||||
idea = models.CharField('建议', max_length=256, null=True, blank=True)
|
||||
site = models.CharField('位置', max_length=256, null=True, blank=True)
|
||||
toutiao = models.ForeignKey(Toutiao, on_delete=models.CASCADE)
|
||||
toutiao = models.ForeignKey(Toutiao, on_delete=models.CASCADE, null=True, blank=True)
|
||||
change = models.BooleanField('是否已修改', null=True, blank=True)
|
||||
created = models.DateTimeField('创建时间', auto_now_add=True)
|
||||
updated = models.DateTimeField('更新时间', auto_now=True)
|
||||
|
@ -234,7 +294,7 @@ class Toutiao_Wrong(models.Model):
|
|||
# 其他新媒体
|
||||
class Qita(models.Model):
|
||||
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
|
||||
organization = models.ForeignKey(Organization, on_delete=models.CASCADE)
|
||||
organization = models.ForeignKey(Organization, on_delete=models.CASCADE, null=True, blank=True)
|
||||
type = models.CharField('新媒体类型', max_length=256, null=True, blank=True)
|
||||
name = models.CharField('新媒体名称', max_length=256, null=True, blank=True)
|
||||
count = models.CharField('总发文量', max_length=256, null=True, blank=True)
|
||||
|
@ -245,5 +305,15 @@ class Qita(models.Model):
|
|||
created = models.DateTimeField('创建时间', auto_now_add=True)
|
||||
updated = models.DateTimeField('更新时间', auto_now=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
#5级地名库
|
||||
class Area_code_2020(models.Model):
|
||||
code = models.CharField('区划代码',max_length=256,null=True,blank=True)
|
||||
name = models.CharField('名称',max_length=256,null=True,blank=True)
|
||||
level = models.CharField('级别1-5,省市县镇村',max_length=256,null=True,blank=True)
|
||||
pcode = models.CharField('父级区划代码',max_length=256,null=True,blank=True)
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
<div id="pages" class="text-center">
|
||||
<nav>
|
||||
<ul class="pagination">
|
||||
<li class="step-links">
|
||||
{% if group.has_previous %}
|
||||
<a class='active' href="?page={{ group.previous_page_number }}">上一页</a>
|
||||
{% endif %}
|
||||
|
||||
<span class="current">
|
||||
第{{ group.number }}页 共{{ group.paginator.num_pages }}页</span>
|
||||
|
||||
{% if group.has_next %}
|
||||
<a class='active' href="?page={{ group.next_page_number }}">下一页</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
|
@ -0,0 +1,18 @@
|
|||
<div id="pages" class="text-center">
|
||||
<nav>
|
||||
<ul class="pagination">
|
||||
<li class="step-links">
|
||||
{% if organization.has_previous %}
|
||||
<a class='active' href="?page={{ organization.previous_page_number }}">上一页</a>
|
||||
{% endif %}
|
||||
|
||||
<span class="current">
|
||||
第{{ organization.number }}页 共{{ organization.paginator.num_pages }}页</span>
|
||||
|
||||
{% if organization.has_next %}
|
||||
<a class='active' href="?page={{ organization.next_page_number }}">下一页</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
|
@ -0,0 +1,18 @@
|
|||
<div id="pages" class="text-center">
|
||||
<nav>
|
||||
<ul class="pagination">
|
||||
<li class="step-links">
|
||||
{% if userpaginator.has_previous %}
|
||||
<a class='active' href="?page={{ userpaginator.previous_page_number }}">上一页</a>
|
||||
{% endif %}
|
||||
|
||||
<span class="current">
|
||||
第{{ userpaginator.number }}页 共{{ userpaginator.paginator.num_pages }}页</span>
|
||||
|
||||
{% if userpaginator.has_next %}
|
||||
<a class='active' href="?page={{ userpaginator.next_page_number }}">下一页</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
|
@ -57,7 +57,8 @@
|
|||
class="login loginpage col-lg-offset-4 col-lg-4 col-md-offset-3 col-md-6 col-sm-offset-3 col-sm-6 col-xs-offset-2 col-xs-8">
|
||||
<h1><a href="#" title="Login Page" tabindex="-1">Ultra Admin</a></h1>
|
||||
|
||||
<form name="loginform" id="loginform" action="{% url 'dashboard-register' %}" method="post" enctype="multipart/form-data">{% csrf_token %}
|
||||
<form name="loginform" id="loginform" action="{% url 'dashboard-register' %}" method="post"
|
||||
enctype="multipart/form-data">{% csrf_token %}
|
||||
<p>
|
||||
<label for="name">单位<br/>
|
||||
<select class="form-control" name="organization">
|
||||
|
@ -71,6 +72,15 @@
|
|||
<label for="name">姓名<br/>
|
||||
<input type="text" name="name" id="user_login" class="input" value="" size="20"/></label>
|
||||
</p>
|
||||
<p>
|
||||
<label for="sex">性别<br/>
|
||||
<label style="text-align: center">
|
||||
<input type="radio" name="sex" id="inlineRadio1" value="1" checked="checked">男
|
||||
<input type="radio" name="sex" id="inlineRadio2" value="2" style="margin-left: 50px"> 女
|
||||
</label>
|
||||
</label>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="email">邮箱<br/>
|
||||
<input type="text" name="email" id="user_login" class="input" value="" size="20"/></label>
|
||||
|
@ -169,7 +179,7 @@
|
|||
img = $(".captcha");
|
||||
id_captcha_0.attr("value", new_cptch_key);
|
||||
img.attr("src", new_cptch_image);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
})
|
||||
|
|
|
@ -9,4 +9,12 @@ urlpatterns = [
|
|||
path('refresh_captcha/', views.refresh_captcha, name='refresh-captcha'),
|
||||
path('logout/', views.user_logout, name='dashboard-logout'),
|
||||
path('register/', views.register, name='dashboard-register'),
|
||||
|
||||
#省市县地区级联菜单
|
||||
#获取省
|
||||
path('get/province/',views.get_province),
|
||||
path('get/city/',views.get_city),
|
||||
path('get/district/',views.get_district),
|
||||
path('get/town/',views.get_town),
|
||||
path('get/village/',views.get_village),
|
||||
]
|
||||
|
|
|
@ -10,7 +10,7 @@ import datetime
|
|||
|
||||
|
||||
# Create your views here.
|
||||
from dashboard.models import Userprofile, Organization
|
||||
from dashboard.models import Userprofile, Organization, Area_code_2020
|
||||
|
||||
|
||||
def refresh_captcha(request):
|
||||
|
@ -72,6 +72,7 @@ def register(request):
|
|||
image = None
|
||||
flag = False
|
||||
o = None
|
||||
sex = None
|
||||
hash_key = CaptchaStore.generate_key()
|
||||
image_url = captcha_image_url(hash_key)
|
||||
organization = Organization.objects.all()
|
||||
|
@ -110,6 +111,10 @@ def register(request):
|
|||
else:
|
||||
image = request.FILES.get('image')
|
||||
print(str(image)+"1111111111111111111111111111111111111111111")
|
||||
if request.POST.get('sex') == 0:
|
||||
sex = '男'
|
||||
else:
|
||||
sex = '女'
|
||||
captcha_input = request.POST.get('captcha_1')
|
||||
captcha_hashkey = request.POST.get('captcha_0')
|
||||
|
||||
|
@ -136,8 +141,49 @@ def register(request):
|
|||
user.is_staff = True
|
||||
user.first_name = phone
|
||||
user.save()
|
||||
userprofile = Userprofile(name=name,image=image,user_id=user.id,organization_id=o)
|
||||
userprofile = Userprofile(name=name,image=image,user_id=user.id,organization_id=o,sex=sex)
|
||||
userprofile.save()
|
||||
messages.success(request, '注册成功,请登录')
|
||||
return HttpResponseRedirect('/login/')
|
||||
return render(request, 'dashboard/register.html', {'hash_key': hash_key, 'image_url': image_url,'organization':organization})
|
||||
|
||||
def get_province(request):
|
||||
#省
|
||||
province = Area_code_2020.objects.filter(level=1)
|
||||
res = []
|
||||
for i in province:
|
||||
res.append([i.code,i.name,i.level,i.pcode])
|
||||
return JsonResponse({"province":res})
|
||||
def get_city(request):
|
||||
code = request.GET.get('code')
|
||||
print(code)
|
||||
#市
|
||||
cities = Area_code_2020.objects.filter(pcode=code)
|
||||
res = []
|
||||
for i in cities:
|
||||
res.append([i.code,i.name,i.level,i.pcode])
|
||||
return JsonResponse({"city": res})
|
||||
def get_district(request):
|
||||
code = request.GET.get('code')
|
||||
#县
|
||||
district = Area_code_2020.objects.filter(pcode=code)
|
||||
res = []
|
||||
for i in district:
|
||||
res.append([i.code, i.name, i.level, i.pcode])
|
||||
return JsonResponse({"district": res})
|
||||
def get_town(request):
|
||||
code = request.GET.get('code')
|
||||
# 乡
|
||||
town = Area_code_2020.objects.filter(pcode=code)
|
||||
res = []
|
||||
for i in town:
|
||||
res.append([i.code, i.name, i.level, i.pcode])
|
||||
return JsonResponse({"town": res})
|
||||
def get_village(request):
|
||||
code = request.GET.get('code')
|
||||
# 村
|
||||
village = Area_code_2020.objects.filter(pcode=code)
|
||||
res = []
|
||||
for i in village:
|
||||
res.append([i.code, i.name, i.level, i.pcode])
|
||||
return JsonResponse({"village": res})
|
||||
|
|
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
|
@ -0,0 +1,43 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import csv
|
||||
import re
|
||||
import uuid
|
||||
import os
|
||||
import psycopg2
|
||||
|
||||
from pip._vendor import chardet
|
||||
|
||||
# G1 = 'host=210.77.68.250 port=5432 dbname=g214_test user=g214 password=g214G214'
|
||||
G2 = 'host=210.77.68.250 port=5432 dbname=newmediaDB1 user=newmedia password=newmedia2020!@#'
|
||||
|
||||
|
||||
def insert_area(code, name,level, pcode):
|
||||
with psycopg2.connect(G2) as connection:
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute(
|
||||
'insert into dashboard_area_code_2020(code, name,level, pcode) values (%s,%s, %s,%s)'
|
||||
, (code, name,level, pcode))
|
||||
connection.commit()
|
||||
return code
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
f = open('D:/2020/荒漠植被调查/china_area-master/area_code_2020.sql/area_code_2020.sql',encoding='utf-8').read()
|
||||
|
||||
data = f.split('INSERT INTO dashboard_area_code_2020 (code, name, level, pcode)VALUES')
|
||||
for d in data:
|
||||
for i in d.split('\n'):
|
||||
list = i.split(');')[0].split('),')[0].split('(')
|
||||
# print(len(list))
|
||||
if len(list) > 1:
|
||||
success_data = list[1].split(',')
|
||||
try:
|
||||
code = success_data[0]
|
||||
name = re.sub("'","",success_data[1])
|
||||
level = success_data[2]
|
||||
pcode = success_data[3]
|
||||
print(code, name, level, pcode)
|
||||
insert_area(code, name,level, pcode)
|
||||
except:
|
||||
pass
|
|
@ -46,13 +46,67 @@
|
|||
<div class="row">
|
||||
<div class="col-md-8 col-sm-9 col-xs-10">
|
||||
<form method="post"
|
||||
action="{% url 'group-management-create' %}">{% csrf_token %}
|
||||
action="{% url 'group-management-create' %}" enctype="multipart/form-data">{% csrf_token %}
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="name">群组名</label>
|
||||
<label class="form-label" for="name">群组名称</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="form-control" name="name">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="presentation">群组介绍</label>
|
||||
<div class="controls">
|
||||
<textarea type="text" class="form-control"
|
||||
name="presentation"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="image">图标
|
||||
<div class="controls">
|
||||
<input type="file" name="image">
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="type">群组类型</label>
|
||||
<div class="controls">
|
||||
<select class="form-control" name="type">
|
||||
{% for g in group_type %}
|
||||
<option value="{{ g.id }}">{{ g.type }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="status">群组状态</label>
|
||||
<div class="controls">
|
||||
<select class="form-control" name="status">
|
||||
{% for g in group_status_choices_list %}
|
||||
<option value="{{ g }}">{{ g }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="administrativedivision">行政区划</label>
|
||||
<div class="controls">
|
||||
<select id="province" name="province">
|
||||
<option value="">请选择省</option>
|
||||
</select>
|
||||
<select id="city" name="city" style="margin-left: 20px">
|
||||
<option value="">请选择市</option>
|
||||
</select>
|
||||
<select id="district" name="district" style="margin-left: 20px">
|
||||
<option value="">请选择区/县</option>
|
||||
</select>
|
||||
<select id="town" name="town" style="margin-left: 20px">
|
||||
<option value="">请选择乡/镇</option>
|
||||
</select>
|
||||
<select id="village" name="village" style="margin-left: 20px">
|
||||
<option value="">请选择村/街道</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success">点击创建</button>
|
||||
|
||||
</form>
|
||||
|
@ -67,3 +121,77 @@
|
|||
</div>
|
||||
</body>
|
||||
{% endblock %}
|
||||
{% block add_js %}
|
||||
<script>
|
||||
$(function () {
|
||||
$.get('/get/province/', function (data) {
|
||||
for (var i = 0, len = data.province.length; i < len; i++) {
|
||||
$new = $("<option value=" + data.province[i][0] + ">" + data.province[i][1] + "</option>");
|
||||
$("#province").append($new);
|
||||
}
|
||||
})
|
||||
//当省份改变后
|
||||
$("#province").change(function () {
|
||||
$("#city").empty().append('<option value="">请选择市</option>');
|
||||
$("#district").empty().append('<option value="">请选择区/县</option>');
|
||||
$("#town").empty().append('<option value="">请选择乡/镇</option>');
|
||||
$("#village").empty().append('<option value="">请选择村/街道</option>');
|
||||
$.ajax({
|
||||
url: '/get/city/',
|
||||
type: 'get',
|
||||
data: {"code": $(this).val()}
|
||||
}).done(function (data) {
|
||||
for (var i = 0, len = data.city.length; i < len; i++) {
|
||||
$new = $("<option value=" + data.city[i][0] + ">" + data.city[i][1] + "</option>");
|
||||
$("#city").append($new);
|
||||
}
|
||||
})
|
||||
})
|
||||
//当城市改变后
|
||||
$("#city").change(function () {
|
||||
$("#district").empty().append('<option value="">请选择区/县</option>');
|
||||
$("#town").empty().append('<option value="">请选择乡/镇</option>');
|
||||
$("#village").empty().append('<option value="">请选择村/街道</option>');
|
||||
$.ajax({
|
||||
url: '/get/district/',
|
||||
type: 'get',
|
||||
data: {"code": $(this).val()}
|
||||
}).done(function (data) {
|
||||
for (var i = 0, len = data.district.length; i < len; i++) {
|
||||
$new = $("<option value=" + data.district[i][0] + ">" + data.district[i][1] + "</option>");
|
||||
$("#district").append($new);
|
||||
}
|
||||
})
|
||||
})
|
||||
//当县改变后
|
||||
$("#district").change(function () {
|
||||
$("#town").empty().append('<option value="">请选择乡/镇</option>');
|
||||
$("#village").empty().append('<option value="">请选择村/街道</option>');
|
||||
$.ajax({
|
||||
url: '/get/town/',
|
||||
type: 'get',
|
||||
data: {"code": $(this).val()}
|
||||
}).done(function (data) {
|
||||
for (var i = 0, len = data.town.length; i < len; i++) {
|
||||
$new = $("<option value=" + data.town[i][0] + ">" + data.town[i][1] + "</option>");
|
||||
$("#town").append($new);
|
||||
}
|
||||
})
|
||||
})
|
||||
//当乡改变后
|
||||
$("#district").change(function () {
|
||||
$("#village").empty().append('<option value="">请选择村/街道</option>');
|
||||
$.ajax({
|
||||
url: '/get/village/',
|
||||
type: 'get',
|
||||
data: {"code": $(this).val()}
|
||||
}).done(function (data) {
|
||||
for (var i = 0, len = data.village.length; i < len; i++) {
|
||||
$new = $("<option value=" + data.village[i][0] + ">" + data.village[i][1] + "</option>");
|
||||
$("#village").append($new);
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -36,24 +36,150 @@
|
|||
<section class="box ">
|
||||
<header class="panel_header">
|
||||
<h2 class="title pull-left">群组信息表单</h2>
|
||||
{# <div class="actions panel_actions pull-right">#}
|
||||
{# <i class="box_toggle fa fa-chevron-down"></i>#}
|
||||
{# <i class="box_setting fa fa-cog" data-toggle="modal" href="#section-settings"></i>#}
|
||||
{# <i class="box_close fa fa-times"></i>#}
|
||||
{# </div>#}
|
||||
</header>
|
||||
<div class="content-body">
|
||||
<div class="row">
|
||||
<div class="col-md-8 col-sm-9 col-xs-10">
|
||||
<form method="post"
|
||||
action="{% url 'group-management-update' group.id %}">{% csrf_token %}
|
||||
action="{% url 'group-management-update' group.id %}" enctype="multipart/form-data">{% csrf_token %}
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="name">群组名</label>
|
||||
<label class="form-label" for="name">群组名称</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="form-control" name="name"
|
||||
value="{{ group.name }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="presentation">群组介绍</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="form-control"
|
||||
name="presentation" value="{{ group.presentation }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="image">图标
|
||||
<div class="controls">
|
||||
<input type="file" name="image"><img
|
||||
src="{{ group.image.url }}"
|
||||
style="width: 80px;height: 80px;"
|
||||
class="img-circle">
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="type">群组类型</label>
|
||||
<div class="controls">
|
||||
<select class="form-control" name="type">
|
||||
<option value="{{ group.type.id }}">{{ group.type }}</option>
|
||||
{% for g in group_type %}
|
||||
<option value="{{ g.id }}">{{ g.type }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="status">群组状态</label>
|
||||
<div class="controls">
|
||||
<select class="form-control" name="status">
|
||||
<option value="{{ group.status }}">{{ group.status }}</option>
|
||||
{% for g in group_status_choices_list %}
|
||||
<option value="{{ g }}">{{ g }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="administrativedivision">行政区划</label>
|
||||
<div class="controls">
|
||||
<select id="province" name="province">
|
||||
<option value="{{ group.province }}">{{ group.province }}</option>
|
||||
</select>
|
||||
<select id="city" name="city" style="margin-left: 20px">
|
||||
<option value="{{ group.cities }}">{{ group.cities }}</option>
|
||||
</select>
|
||||
<select id="district" name="district" style="margin-left: 20px">
|
||||
<option value="{{ group.district }}">{{ group.district }}</option>
|
||||
</select>
|
||||
<select id="town" name="town" style="margin-left: 20px">
|
||||
<option value="{{ group.town }}">{{ group.town }}</option>
|
||||
</select>
|
||||
<select id="village" name="village" style="margin-left: 20px">
|
||||
<option value="{{ group.village }}">{{ group.village }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="stauts">管理员</label>
|
||||
<div class="controls" style="margin-left: 5%">
|
||||
<span class="glyphicon glyphicon-plus" aria-hidden="true">添加管理员</span>
|
||||
<table class="table table-hover" style="margin-top: 20px">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align: center">头像</th>
|
||||
<th style="text-align: center">用户名</th>
|
||||
<th style="text-align: center">姓名</th>
|
||||
<th style="text-align: center">单位名称</th>
|
||||
<th style="text-align: center">行政区划</th>
|
||||
<th style="text-align: center">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for g_a in g_a_list %}
|
||||
<tr>
|
||||
<td style="vertical-align: middle;text-align: center"><img
|
||||
src="{{ g_a.image }}"
|
||||
style="width: 80px;height: 80px;"
|
||||
class="img-circle"></td>
|
||||
<td style="vertical-align: middle;text-align: center">{{ g_a.username }}</td>
|
||||
<td style="vertical-align: middle;text-align: center">{{ g_a.name }}</td>
|
||||
<td style="vertical-align: middle;text-align: center">{{ g_a.organization }}</td>
|
||||
<td style="vertical-align: middle;text-align: center">{{ g_a.organization }}</td>
|
||||
<td style="vertical-align: middle;text-align: center">
|
||||
<a href=""
|
||||
class="btn btn-danger btn-mini">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="stauts">成员</label>
|
||||
<div class="controls" style="margin-left: 5%">
|
||||
<span class="glyphicon glyphicon-plus" aria-hidden="true">添加成员</span>
|
||||
<table class="table table-hover" style="margin-top: 20px">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align: center">头像</th>
|
||||
<th style="text-align: center">用户名</th>
|
||||
<th style="text-align: center">姓名</th>
|
||||
<th style="text-align: center">单位名称</th>
|
||||
<th style="text-align: center">行政区划</th>
|
||||
<th style="text-align: center">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for g_u in g_u_list %}
|
||||
<tr>
|
||||
<td style="vertical-align: middle;text-align: center"><img
|
||||
src="{{ g_u.image }}"
|
||||
style="width: 80px;height: 80px;"
|
||||
class="img-circle"></td>
|
||||
<td style="vertical-align: middle;text-align: center">{{ g_u.username }}</td>
|
||||
<td style="vertical-align: middle;text-align: center">{{ g_u.name }}</td>
|
||||
<td style="vertical-align: middle;text-align: center">{{ g_u.organization }}</td>
|
||||
<td style="vertical-align: middle;text-align: center">{{ g_u.organization }}</td>
|
||||
<td style="vertical-align: middle;text-align: center">
|
||||
<a href=""
|
||||
class="btn btn-danger btn-mini">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success">提交修改</button>
|
||||
|
||||
</form>
|
||||
|
@ -68,3 +194,77 @@
|
|||
</div>
|
||||
</body>
|
||||
{% endblock %}
|
||||
{% block add_js %}
|
||||
<script>
|
||||
$(function () {
|
||||
$.get('/get/province/', function (data) {
|
||||
for (var i = 0, len = data.province.length; i < len; i++) {
|
||||
$new = $("<option value=" + data.province[i][0] + ">" + data.province[i][1] + "</option>");
|
||||
$("#province").append($new);
|
||||
}
|
||||
})
|
||||
//当省份改变后
|
||||
$("#province").change(function () {
|
||||
$("#city").empty().append('<option value="">请选择市</option>');
|
||||
$("#district").empty().append('<option value="">请选择区/县</option>');
|
||||
$("#town").empty().append('<option value="">请选择乡/镇</option>');
|
||||
$("#village").empty().append('<option value="">请选择村/街道</option>');
|
||||
$.ajax({
|
||||
url: '/get/city/',
|
||||
type: 'get',
|
||||
data: {"code": $(this).val()}
|
||||
}).done(function (data) {
|
||||
for (var i = 0, len = data.city.length; i < len; i++) {
|
||||
$new = $("<option value=" + data.city[i][0] + ">" + data.city[i][1] + "</option>");
|
||||
$("#city").append($new);
|
||||
}
|
||||
})
|
||||
})
|
||||
//当城市改变后
|
||||
$("#city").change(function () {
|
||||
$("#district").empty().append('<option value="">请选择区/县</option>');
|
||||
$("#town").empty().append('<option value="">请选择乡/镇</option>');
|
||||
$("#village").empty().append('<option value="">请选择村/街道</option>');
|
||||
$.ajax({
|
||||
url: '/get/district/',
|
||||
type: 'get',
|
||||
data: {"code": $(this).val()}
|
||||
}).done(function (data) {
|
||||
for (var i = 0, len = data.district.length; i < len; i++) {
|
||||
$new = $("<option value=" + data.district[i][0] + ">" + data.district[i][1] + "</option>");
|
||||
$("#district").append($new);
|
||||
}
|
||||
})
|
||||
})
|
||||
//当县改变后
|
||||
$("#district").change(function () {
|
||||
$("#town").empty().append('<option value="">请选择乡/镇</option>');
|
||||
$("#village").empty().append('<option value="">请选择村/街道</option>');
|
||||
$.ajax({
|
||||
url: '/get/town/',
|
||||
type: 'get',
|
||||
data: {"code": $(this).val()}
|
||||
}).done(function (data) {
|
||||
for (var i = 0, len = data.town.length; i < len; i++) {
|
||||
$new = $("<option value=" + data.town[i][0] + ">" + data.town[i][1] + "</option>");
|
||||
$("#town").append($new);
|
||||
}
|
||||
})
|
||||
})
|
||||
//当乡改变后
|
||||
$("#district").change(function () {
|
||||
$("#village").empty().append('<option value="">请选择村/街道</option>');
|
||||
$.ajax({
|
||||
url: '/get/village/',
|
||||
type: 'get',
|
||||
data: {"code": $(this).val()}
|
||||
}).done(function (data) {
|
||||
for (var i = 0, len = data.village.length; i < len; i++) {
|
||||
$new = $("<option value=" + data.village[i][0] + ">" + data.village[i][1] + "</option>");
|
||||
$("#village").append($new);
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -42,52 +42,44 @@
|
|||
<section class="box ">
|
||||
<header class="panel_header">
|
||||
<h2 class="title pull-left">群组列表</h2>
|
||||
{# <div class="actions panel_actions pull-right">#}
|
||||
{# <i class="box_toggle fa fa-chevron-down"></i>#}
|
||||
{# <i class="box_setting fa fa-cog" data-toggle="modal" href="#section-settings"></i>#}
|
||||
{# <i class="box_close fa fa-times"></i>#}
|
||||
{# </div>#}
|
||||
</header>
|
||||
<div class="content-body">
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-sm-12 col-xs-12">
|
||||
<div class="row">
|
||||
<div class="col-sm-8 col-md-8 col-xs-12">
|
||||
<ul id="nestableList-1" class="uk-nestable">
|
||||
{% for g in group %}
|
||||
<li data-item="Item 1" data-item-id="1">
|
||||
<div class="uk-nestable-item">
|
||||
<div class="uk-nestable-handle"
|
||||
onclick="group_detail('{{ g.id }}')"></div>
|
||||
<div class="list-label">{{ g.name }}</div>
|
||||
|
||||
<div class="list-label" style="float: right">
|
||||
<a href="{% url 'group-management-delete' g.id %}">
|
||||
<button type="button" class="btn btn-danger">删除
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
<div class="list-label" style="float: right">
|
||||
<a href="{% url 'group-management-update' g.id %}">
|
||||
<button type="button" class="btn btn-success">修改
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-sm-4 col-md-4 col-xs-12">
|
||||
<div class="panel panel-success">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">群组信息</h3>
|
||||
</div>
|
||||
<div class="panel-body" id="group_detail" style="min-height: 100px">
|
||||
<p class="none">暂无数据,请点击左侧图标查询</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align: center">头像</th>
|
||||
<th style="text-align: center">群组名称</th>
|
||||
<th style="text-align: center">群组类型</th>
|
||||
<th style="text-align: center">管理员个数</th>
|
||||
<th style="text-align: center">成员个数</th>
|
||||
<th style="text-align: center">状态</th>
|
||||
<th style="text-align: center">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for r in res %}
|
||||
<tr>
|
||||
<td><img src="{{ r.image }}" style="width: 80px;height: 80px;"
|
||||
class="img-circle"></td>
|
||||
<td style="vertical-align: middle;text-align: center">{{ r.name }}</td>
|
||||
<td style="vertical-align: middle;text-align: center">{{ r.type }}</td>
|
||||
<td style="vertical-align: middle;text-align: center">{{ r.admin_count }}</td>
|
||||
<td style="vertical-align: middle;text-align: center">{{ r.admin_count }}</td>
|
||||
<td style="vertical-align: middle;text-align: center">{{ r.status }}</td>
|
||||
<td style="vertical-align: middle;text-align: center">
|
||||
<a href="{% url 'group-management-update' r.id %}"
|
||||
class="btn btn-primary btn-mini">编辑</a>
|
||||
<a href="{% url 'group-management-delete' r.id %}"
|
||||
class="btn btn-danger btn-mini">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="metadata-pagination">
|
||||
{% include 'dashboard/paginator/group-management-paginate.html' %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
<div class="row">
|
||||
<div class="col-md-8 col-sm-9 col-xs-10">
|
||||
<form method="post"
|
||||
action="{% url 'organization-management-create' %}">{% csrf_token %}
|
||||
action="{% url 'organization-management-create' %}" enctype="multipart/form-data">{% csrf_token %}
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="name">单位名</label>
|
||||
<div class="controls">
|
||||
|
@ -54,26 +54,43 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="group">群组</label>
|
||||
<label class="form-label" for="image">图标
|
||||
<div class="controls">
|
||||
<select class="form-control" name="group">
|
||||
{% for g in group %}
|
||||
<option value="{{ g.id }}">{{ g.name }}</option>
|
||||
<input type="file" name="image">
|
||||
</div></label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="organizationtype">单位类型</label>
|
||||
<div class="controls">
|
||||
<select class="form-control" name="organizationtype">
|
||||
{% for o in organizationtype %}
|
||||
<option value="{{ o.id }}">{{ o.organizationtype }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="level">权限</label>
|
||||
|
||||
<select class="form-control" name="level">
|
||||
{% for l in level %}
|
||||
<option value="{{ l.id }}">{{ l.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<label class="form-label" for="administrativedivision">行政区划</label>
|
||||
<div class="controls">
|
||||
<select id="province" name="province">
|
||||
<option value="">请选择省</option>
|
||||
</select>
|
||||
<select id="city" name="city" style="margin-left: 20px">
|
||||
<option value="">请选择市</option>
|
||||
</select>
|
||||
<select id="district" name="district" style="margin-left: 20px">
|
||||
<option value="">请选择区/县</option>
|
||||
</select>
|
||||
<select id="town" name="town" style="margin-left: 20px">
|
||||
<option value="">请选择乡/镇</option>
|
||||
</select>
|
||||
<select id="village" name="village" style="margin-left: 20px">
|
||||
<option value="">请选择村/街道</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success">点击新建</button>
|
||||
|
||||
<button type="submit" class="btn btn-success" style="margin-top: 50px">点击新建
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -86,3 +103,78 @@
|
|||
</div>
|
||||
</body>
|
||||
{% endblock %}
|
||||
|
||||
{% block add_js %}
|
||||
<script>
|
||||
$(function () {
|
||||
$.get('/get/province/', function (data) {
|
||||
for (var i = 0, len = data.province.length; i < len; i++) {
|
||||
$new = $("<option value=" + data.province[i][0] + ">" + data.province[i][1] + "</option>");
|
||||
$("#province").append($new);
|
||||
}
|
||||
})
|
||||
//当省份改变后
|
||||
$("#province").change(function () {
|
||||
$("#city").empty().append('<option value="">请选择市</option>');
|
||||
$("#district").empty().append('<option value="">请选择区/县</option>');
|
||||
$("#town").empty().append('<option value="">请选择乡/镇</option>');
|
||||
$("#village").empty().append('<option value="">请选择村/街道</option>');
|
||||
$.ajax({
|
||||
url: '/get/city/',
|
||||
type: 'get',
|
||||
data: {"code": $(this).val()}
|
||||
}).done(function (data) {
|
||||
for (var i = 0, len = data.city.length; i < len; i++) {
|
||||
$new = $("<option value=" + data.city[i][0] + ">" + data.city[i][1] + "</option>");
|
||||
$("#city").append($new);
|
||||
}
|
||||
})
|
||||
})
|
||||
//当城市改变后
|
||||
$("#city").change(function () {
|
||||
$("#district").empty().append('<option value="">请选择区/县</option>');
|
||||
$("#town").empty().append('<option value="">请选择乡/镇</option>');
|
||||
$("#village").empty().append('<option value="">请选择村/街道</option>');
|
||||
$.ajax({
|
||||
url: '/get/district/',
|
||||
type: 'get',
|
||||
data: {"code": $(this).val()}
|
||||
}).done(function (data) {
|
||||
for (var i = 0, len = data.district.length; i < len; i++) {
|
||||
$new = $("<option value=" + data.district[i][0] + ">" + data.district[i][1] + "</option>");
|
||||
$("#district").append($new);
|
||||
}
|
||||
})
|
||||
})
|
||||
//当县改变后
|
||||
$("#district").change(function () {
|
||||
$("#town").empty().append('<option value="">请选择乡/镇</option>');
|
||||
$("#village").empty().append('<option value="">请选择村/街道</option>');
|
||||
$.ajax({
|
||||
url: '/get/town/',
|
||||
type: 'get',
|
||||
data: {"code": $(this).val()}
|
||||
}).done(function (data) {
|
||||
for (var i = 0, len = data.town.length; i < len; i++) {
|
||||
$new = $("<option value=" + data.town[i][0] + ">" + data.town[i][1] + "</option>");
|
||||
$("#town").append($new);
|
||||
}
|
||||
})
|
||||
})
|
||||
//当乡改变后
|
||||
$("#district").change(function () {
|
||||
$("#village").empty().append('<option value="">请选择村/街道</option>');
|
||||
$.ajax({
|
||||
url: '/get/village/',
|
||||
type: 'get',
|
||||
data: {"code": $(this).val()}
|
||||
}).done(function (data) {
|
||||
for (var i = 0, len = data.village.length; i < len; i++) {
|
||||
$new = $("<option value=" + data.village[i][0] + ">" + data.village[i][1] + "</option>");
|
||||
$("#village").append($new);
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -46,7 +46,8 @@
|
|||
<div class="row">
|
||||
<div class="col-md-8 col-sm-9 col-xs-10">
|
||||
<form method="post"
|
||||
action="{% url 'organization-management-update' organization.id %}">{% csrf_token %}
|
||||
action="{% url 'organization-management-update' organization.id %}"
|
||||
enctype="multipart/form-data">{% csrf_token %}
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="name">单位名</label>
|
||||
<div class="controls">
|
||||
|
@ -55,25 +56,45 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="group">群组</label>
|
||||
<label class="form-label" for="image">图标
|
||||
<div class="controls">
|
||||
<input type="file" name="image"><img
|
||||
src="{{ organization.image.url }}"
|
||||
style="width: 80px;height: 80px;"
|
||||
class="img-circle">
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="organizationtype">单位类型</label>
|
||||
<div class="controls">
|
||||
<select class="form-control" name="group">
|
||||
<option value="{{ organization.group.id }}">{{ organization.group.name }}</option>
|
||||
{% for g in group %}
|
||||
<option value="{{ g.id }}">{{ g.name }}</option>
|
||||
<select class="form-control" name="organizationtype">
|
||||
<option value="{{ organization.organizationtype.id }}">{{ organization.organizationtype.organizationtype }}</option>
|
||||
{% for o in organizationtype %}
|
||||
<option value="{{ o.id }}">{{ o.organizationtype }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="level">权限</label>
|
||||
|
||||
<select class="form-control" name="level">
|
||||
<option value="{{ organization.level.id }}">{{ organization.level.name }}</option>
|
||||
{% for l in level %}
|
||||
<option value="{{ l.id }}">{{ l.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<label class="form-label" for="administrativedivision">行政区划</label>
|
||||
<div class="controls">
|
||||
<select id="province" name="province">
|
||||
<option value="{{ organization.province }}">{{ organization.province }}</option>
|
||||
</select>
|
||||
<select id="city" name="city" style="margin-left: 20px">
|
||||
<option value="{{ organization.province }}">{{ organization.cities }}</option>
|
||||
</select>
|
||||
<select id="district" name="district" style="margin-left: 20px">
|
||||
<option value="{{ organization.province }}">{{ organization.district }}</option>
|
||||
</select>
|
||||
<select id="town" name="town" style="margin-left: 20px">
|
||||
<option value="{{ organization.province }}">{{ organization.town }}</option>
|
||||
</select>
|
||||
<select id="village" name="village" style="margin-left: 20px">
|
||||
<option value="{{ organization.province }}">{{ organization.village }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success">提交修改</button>
|
||||
|
||||
|
@ -89,3 +110,77 @@
|
|||
</div>
|
||||
</body>
|
||||
{% endblock %}
|
||||
{% block add_js %}
|
||||
<script>
|
||||
$(function () {
|
||||
$.get('/get/province/', function (data) {
|
||||
for (var i = 0, len = data.province.length; i < len; i++) {
|
||||
$new = $("<option value=" + data.province[i][0] + ">" + data.province[i][1] + "</option>");
|
||||
$("#province").append($new);
|
||||
}
|
||||
})
|
||||
//当省份改变后
|
||||
$("#province").change(function () {
|
||||
$("#city").empty().append('<option value="">请选择市</option>');
|
||||
$("#district").empty().append('<option value="">请选择区/县</option>');
|
||||
$("#town").empty().append('<option value="">请选择乡/镇</option>');
|
||||
$("#village").empty().append('<option value="">请选择村/街道</option>');
|
||||
$.ajax({
|
||||
url: '/get/city/',
|
||||
type: 'get',
|
||||
data: {"code": $(this).val()}
|
||||
}).done(function (data) {
|
||||
for (var i = 0, len = data.city.length; i < len; i++) {
|
||||
$new = $("<option value=" + data.city[i][0] + ">" + data.city[i][1] + "</option>");
|
||||
$("#city").append($new);
|
||||
}
|
||||
})
|
||||
})
|
||||
//当城市改变后
|
||||
$("#city").change(function () {
|
||||
$("#district").empty().append('<option value="">请选择区/县</option>');
|
||||
$("#town").empty().append('<option value="">请选择乡/镇</option>');
|
||||
$("#village").empty().append('<option value="">请选择村/街道</option>');
|
||||
$.ajax({
|
||||
url: '/get/district/',
|
||||
type: 'get',
|
||||
data: {"code": $(this).val()}
|
||||
}).done(function (data) {
|
||||
for (var i = 0, len = data.district.length; i < len; i++) {
|
||||
$new = $("<option value=" + data.district[i][0] + ">" + data.district[i][1] + "</option>");
|
||||
$("#district").append($new);
|
||||
}
|
||||
})
|
||||
})
|
||||
//当县改变后
|
||||
$("#district").change(function () {
|
||||
$("#town").empty().append('<option value="">请选择乡/镇</option>');
|
||||
$("#village").empty().append('<option value="">请选择村/街道</option>');
|
||||
$.ajax({
|
||||
url: '/get/town/',
|
||||
type: 'get',
|
||||
data: {"code": $(this).val()}
|
||||
}).done(function (data) {
|
||||
for (var i = 0, len = data.town.length; i < len; i++) {
|
||||
$new = $("<option value=" + data.town[i][0] + ">" + data.town[i][1] + "</option>");
|
||||
$("#town").append($new);
|
||||
}
|
||||
})
|
||||
})
|
||||
//当乡改变后
|
||||
$("#district").change(function () {
|
||||
$("#village").empty().append('<option value="">请选择村/街道</option>');
|
||||
$.ajax({
|
||||
url: '/get/village/',
|
||||
type: 'get',
|
||||
data: {"code": $(this).val()}
|
||||
}).done(function (data) {
|
||||
for (var i = 0, len = data.village.length; i < len; i++) {
|
||||
$new = $("<option value=" + data.village[i][0] + ">" + data.village[i][1] + "</option>");
|
||||
$("#village").append($new);
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -52,41 +52,42 @@
|
|||
<div class="row">
|
||||
<div class="col-md-12 col-sm-12 col-xs-12">
|
||||
<div class="row">
|
||||
<div class="col-sm-8 col-md-8 col-xs-12">
|
||||
<ul id="nestableList-1" class="uk-nestable">
|
||||
{% for o in organization %}
|
||||
<li data-item="Item 1" data-item-id="1">
|
||||
<div class="uk-nestable-item">
|
||||
<div class="uk-nestable-handle"
|
||||
onclick="organization_detail('{{ o.id }}')"></div>
|
||||
<div class="list-label">{{ o.name }}</div>
|
||||
|
||||
<div class="list-label" style="float: right">
|
||||
<a href="{% url 'organization-management-delete' o.id %}">
|
||||
<button type="button" class="btn btn-danger">删除
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
<div class="list-label" style="float: right">
|
||||
<a href="{% url 'organization-management-update' o.id %}">
|
||||
<button type="button" class="btn btn-success">修改
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<div class="col-sm-12 col-md-12 col-xs-12">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align: center">图标</th>
|
||||
<th style="text-align: center">单位名称</th>
|
||||
<th style="text-align: center">行政区划</th>
|
||||
<th style="text-align: center">类型</th>
|
||||
<th style="text-align: center">成员数量</th>
|
||||
<th style="text-align: center">新媒体数量</th>
|
||||
<th style="text-align: center">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for r in res %}
|
||||
<tr>
|
||||
<td style="vertical-align: middle;text-align: center"><img
|
||||
src="{{ r.image }}" style="width: 80px;height: 80px;"
|
||||
class="img-circle"></td>
|
||||
<td style="vertical-align: middle;text-align: center">{{ r.name }}</td>
|
||||
<td style="vertical-align: middle;text-align: center">{{ r.organizationtype }}</td>
|
||||
<td style="vertical-align: middle;text-align: center">{{ r.administrativedivision }}</td>
|
||||
<td style="vertical-align: middle;text-align: center">{{ r.usercount }}</td>
|
||||
<td style="vertical-align: middle;text-align: center">{{ r.mediacount }}</td>
|
||||
<td style="vertical-align: middle;text-align: center">
|
||||
<a href="{% url 'organization-management-update' r.id %}"
|
||||
class="btn btn-primary btn-mini">编辑</a>
|
||||
<a href="{% url 'organization-management-delete' r.id %}"
|
||||
class="btn btn-danger btn-mini">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-sm-4 col-md-4 col-xs-12">
|
||||
<div class="panel panel-success">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">群组信息</h3>
|
||||
</div>
|
||||
<div class="panel-body" id="organization_detail"
|
||||
style="min-height: 100px">
|
||||
<p class="none">暂无数据,请点击左侧图标查询</p>
|
||||
</div>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="metadata-pagination">
|
||||
{% include 'dashboard/paginator/organization-management-paginate.html' %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -106,19 +107,5 @@
|
|||
<script src="{% static 'management/js/uikit.min.js' %}" type="text/javascript"></script>
|
||||
<script src="{% static 'management/js/nestable.min.js' %}" type="text/javascript"></script>
|
||||
<script>
|
||||
function organization_detail(id) {
|
||||
console.log(id)
|
||||
$.getJSON('/management/organization/detail/' + id, function (res) {
|
||||
console.log(res)
|
||||
if (res) {
|
||||
$(".none").html("")
|
||||
$("#organization_detail").html("")
|
||||
$("#organization_detail").append("<p>单位名:" + res.name + "</p><p>所属群组:" + res.group + "</p><p>权限等级:" + res.level + "</p><p>创建时间:" + res.created + "</p>")
|
||||
|
||||
} else {
|
||||
$("#organization_detail").append("暂无数据")
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,174 +1,80 @@
|
|||
{% extends 'dashboard/base/base.html' %}
|
||||
{% load static %}
|
||||
{% block css %}
|
||||
<!-- OTHER SCRIPTS INCLUDED ON THIS PAGE - START -->
|
||||
<link href="{% static 'management/css/uikit.min.css' %}" rel="stylesheet" type="text/css" media="screen"/>
|
||||
<link href="{% static 'management/css/nestable.min.css' %}" rel="stylesheet" type="text/css" media="screen"/>
|
||||
<!-- OTHER SCRIPTS INCLUDED ON THIS PAGE - END -->
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<body class=" "><!-- START TOPBAR -->
|
||||
<!-- START CONTAINER -->
|
||||
<body class=" ">
|
||||
<div class="page-container row-fluid">
|
||||
|
||||
<!-- SIDEBAR - START -->
|
||||
<div class="page-sidebar ">
|
||||
|
||||
|
||||
<!-- MAIN MENU - START -->
|
||||
{% include 'dashboard/base/left.html' %}
|
||||
|
||||
</div>
|
||||
<!-- SIDEBAR - END -->
|
||||
<!-- START CONTENT -->
|
||||
<section id="main-content" class=" ">
|
||||
<section class="wrapper" style='margin-top:60px;display:inline-block;width:100%;padding:15px 0 0 15px;'>
|
||||
|
||||
|
||||
<div class='col-lg-12 col-md-12 col-sm-12 col-xs-12'>
|
||||
<div class="page-title">
|
||||
|
||||
<div class="pull-left">
|
||||
<h1 class="title">用户管理</h1></div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
|
||||
|
||||
<div class="col-lg-12">
|
||||
<section class="box ">
|
||||
<header class="panel_header">
|
||||
<h2 class="title pull-left">成员列表</h2>
|
||||
{# <div class="actions panel_actions pull-right">#}
|
||||
{# <i class="box_toggle fa fa-chevron-down"></i>#}
|
||||
{# <i class="box_setting fa fa-cog" data-toggle="modal" href="#section-settings"></i>#}
|
||||
{# <i class="box_close fa fa-times"></i>#}
|
||||
{# </div>#}
|
||||
</header>
|
||||
<div class="content-body">
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-sm-12 col-xs-12">
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-8 col-md-8 col-xs-12">
|
||||
|
||||
<ul id="nestableList-1" class="uk-nestable">
|
||||
{% for u in userallinfo %}
|
||||
<li data-item="Item 1" data-item-id="1">
|
||||
<div class="uk-nestable-item">
|
||||
<div class="uk-nestable-handle"
|
||||
onclick="user_detail({{ u.id }})"></div>
|
||||
{# <div data-nestable-action="toggle"></div>#}
|
||||
<div class="list-label">{{ u.username }}</div>
|
||||
<div class="list-label" style="float: right">
|
||||
<a href="{% url 'user-management-delete' u.id %}"><button type="button" class="btn btn-danger">删除</button></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="col-sm-4 col-md-4 col-xs-12">
|
||||
<div class="panel panel-success">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">用户信息</h3>
|
||||
</div>
|
||||
<div class="panel-body" id="user_detail" style="min-height: 250px">
|
||||
<p class="none">暂无数据,请点击左侧图标查询</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align: center">头像</th>
|
||||
<th style="text-align: center">姓名</th>
|
||||
<th style="text-align: center">电话</th>
|
||||
<th style="text-align: center">单位名称</th>
|
||||
<th style="text-align: center">单位类型</th>
|
||||
<th style="text-align: center">行政区划</th>
|
||||
<th style="text-align: center">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for u in userallinfo %}
|
||||
<tr>
|
||||
<td><img src="{{ u.image }}" style="width: 80px;height: 80px;"
|
||||
class="img-circle"></td>
|
||||
<td style="vertical-align: middle;text-align: center">{{ u.name }}</td>
|
||||
<td style="vertical-align: middle;text-align: center">{{ u.phone }}</td>
|
||||
<td style="vertical-align: middle;text-align: center">{{ u.organization }}</td>
|
||||
<td style="vertical-align: middle;text-align: center">{{ u.type }}</td>
|
||||
<td style="vertical-align: middle;text-align: center">{{ u.administrativedivision }}</td>
|
||||
<td style="vertical-align: middle;text-align: center">
|
||||
<a href="{% url 'user-management-delete' u.id %}"
|
||||
class="btn btn-danger btn-mini">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="metadata-pagination">
|
||||
{% include 'dashboard/paginator/user-management-paginate.html' %}
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
{# <div class="col-lg-12">#}
|
||||
{# <section class="box ">#}
|
||||
{# <header class="panel_header">#}
|
||||
{# <h2 class="title pull-left">Disable Nesting</h2>#}
|
||||
{# <div class="actions panel_actions pull-right">#}
|
||||
{# <i class="box_toggle fa fa-chevron-down"></i>#}
|
||||
{# <i class="box_setting fa fa-cog" data-toggle="modal" href="#section-settings"></i>#}
|
||||
{# <i class="box_close fa fa-times"></i>#}
|
||||
{# </div>#}
|
||||
{# </header>#}
|
||||
{# <div class="content-body">#}
|
||||
{# <div class="row">#}
|
||||
{# <div class="col-md-12 col-sm-12 col-xs-12">#}
|
||||
{##}
|
||||
{##}
|
||||
{# <ul class="uk-nestable" data-uk-nestable="{maxDepth:1}">#}
|
||||
{# <li>#}
|
||||
{# <div class="uk-nestable-item">#}
|
||||
{# <div class="uk-nestable-handle"></div>#}
|
||||
{# <div data-nestable-action="toggle"></div>#}
|
||||
{# <div class="list-label">Item 1</div>#}
|
||||
{# </div>#}
|
||||
{# </li>#}
|
||||
{# <li>#}
|
||||
{# <div class="uk-nestable-item">#}
|
||||
{# <div class="uk-nestable-handle"></div>#}
|
||||
{# <div data-nestable-action="toggle"></div>#}
|
||||
{# <div class="list-label">Item 2</div>#}
|
||||
{# </div>#}
|
||||
{# </li>#}
|
||||
{# <li>#}
|
||||
{# <div class="uk-nestable-item">#}
|
||||
{# <div class="uk-nestable-handle"></div>#}
|
||||
{# <div data-nestable-action="toggle"></div>#}
|
||||
{# <div class="list-label">Item 3</div>#}
|
||||
{# </div>#}
|
||||
{# </li>#}
|
||||
{# </ul>#}
|
||||
{##}
|
||||
{# </div>#}
|
||||
{# </div>#}
|
||||
{# </div>#}
|
||||
{# </section>#}
|
||||
{# </div>#}
|
||||
|
||||
|
||||
</section>
|
||||
</section>
|
||||
<!-- END CONTENT -->
|
||||
|
||||
|
||||
<div class="chatapi-windows ">
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- OTHER SCRIPTS INCLUDED ON THIS PAGE - START -->
|
||||
</body>
|
||||
{% endblock %}
|
||||
{% block add_js %}
|
||||
<script src="{% static 'management/js/uikit.min.js' %}" type="text/javascript"></script>
|
||||
<script src="{% static 'management/js/nestable.min.js' %}" type="text/javascript"></script>
|
||||
<!-- OTHER SCRIPTS INCLUDED ON THIS PAGE - END -->
|
||||
<script>
|
||||
function user_detail(id) {
|
||||
console.log(id)
|
||||
$.getJSON('/management/user/detail/' + id, function (res) {
|
||||
console.log(res)
|
||||
if (res) {
|
||||
$(".none").html("")
|
||||
$("#user_detail").html("")
|
||||
$("#user_detail").append("<p>用户名:" + res.username + "</p>" + "<p>姓名:" + res.name + "</p>" + "<p>电话:" + res.first_name + "</p>" + "<p>单位:" + res.organization + "</p>" + "<p>注册时间:" + res.date_joined + "</p>" + "<p>上次登录:" + res.last_login + "</p>")
|
||||
|
||||
} else {
|
||||
$("#user_detail").append("暂无数据")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -5,18 +5,18 @@ from management import views
|
|||
urlpatterns = [
|
||||
# 用户管理
|
||||
path('user/management/', views.user_management, name='user-management-management'),
|
||||
path('user/detail/<str:pk>/', views.user_detail, name='user-management-detail'),
|
||||
path('user/delete/<str:pk>/', views.user_delete, name='user-management-delete'),
|
||||
# 群组管理
|
||||
path('group/management/', views.group_management, name='group-management-management'),
|
||||
path('group/create/', views.group_create, name='group-management-create'),
|
||||
path('group/detail/<str:pk>/', views.group_detail, name='group-management-detail'),
|
||||
path('group/update/<str:pk>/', views.group_update, name='group-management-update'),
|
||||
path('group/delete/<str:pk>/', views.group_delete, name='group-management-delete'),
|
||||
|
||||
#添加管理员
|
||||
|
||||
#主体单位管理
|
||||
path('organization/management/',views.organization_management,name='organization-management-management'),
|
||||
path('organization/create/',views.organization_create,name='organization-management-create'),
|
||||
path('organization/detail/<str:pk>/',views.organization_detail,name='organization-management-detail'),
|
||||
path('organization/delete/<str:pk>/',views.organization_delete,name='organization-management-delete'),
|
||||
path('organization/update/<str:pk>/',views.organization_update,name='organization-management-update'),
|
||||
|
||||
|
|
|
@ -2,114 +2,343 @@ import json
|
|||
|
||||
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
|
||||
from django.shortcuts import render
|
||||
|
||||
|
||||
from dashboard.models import Userprofile, Group, Organization, Level
|
||||
from dashboard.models import Userprofile, Group, Organization, Level, Organizationtype, Area_code_2020, Weixin, Weibo, \
|
||||
Toutiao, Qita, Group_type, Group_admin, Group_user
|
||||
|
||||
|
||||
def user_management(request):
|
||||
user = User.objects.all()
|
||||
return render(request,'management/user-management.html',{'userallinfo':user})
|
||||
def user_detail(request,pk):
|
||||
user = User.objects.get(id=pk)
|
||||
userprofile = Userprofile.objects.get(user_id=pk)
|
||||
return HttpResponse(json.dumps({
|
||||
"status":"1",
|
||||
"id":str(user.id),
|
||||
"username":user.username,
|
||||
"first_name":user.first_name,
|
||||
"last_login":str(user.last_login).split('.')[0],
|
||||
"date_joined":str(user.date_joined).split('.')[0],
|
||||
"name":userprofile.name,
|
||||
"organization":userprofile.organization.name,
|
||||
}))
|
||||
def user_delete(request,pk):
|
||||
userpaginator = User.objects.all().order_by('-date_joined')
|
||||
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)
|
||||
userallinfo = []
|
||||
for u in userpaginator:
|
||||
o = dict()
|
||||
o['id'] = str(u.id)
|
||||
o['image'] = u.userprofile_set.get(user_id=u.id).image.url
|
||||
o['name'] = u.userprofile_set.get(user_id=u.id).name
|
||||
o['phone'] = u.first_name
|
||||
o['organization'] = u.userprofile_set.get(user_id=u.id).organization.name
|
||||
o['type'] = u.userprofile_set.get(user_id=u.id).organization.organizationtype.organizationtype
|
||||
organization_id = Userprofile.objects.get(user_id=u.id).organization_id
|
||||
print(organization_id)
|
||||
o['administrativedivision'] = str(str(Organization.objects.get(id=organization_id).province) + '-' + str(
|
||||
Organization.objects.get(id=organization_id).cities) + '-' + str(
|
||||
Organization.objects.get(id=organization_id).district) + '-' + str(
|
||||
Organization.objects.get(id=organization_id).town) + '-' + str(
|
||||
Organization.objects.get(id=organization_id).village)).replace('None', '')
|
||||
userallinfo.append(o)
|
||||
print(userallinfo)
|
||||
return render(request, 'management/user-management.html',
|
||||
{'userallinfo': userallinfo, 'userpaginator': userpaginator})
|
||||
|
||||
|
||||
def user_delete(request, pk):
|
||||
user = User.objects.get(id=pk)
|
||||
user.delete()
|
||||
return HttpResponseRedirect('/management/user/management/')
|
||||
|
||||
|
||||
def group_management(request):
|
||||
group = Group.objects.all()
|
||||
return render(request,'management/group-management.html',{'group':group})
|
||||
def group_detail(request,pk):
|
||||
group = Group.objects.get(id=pk)
|
||||
print(group)
|
||||
return HttpResponse(json.dumps({
|
||||
"status":"1",
|
||||
"id": str(group.id),
|
||||
"name":group.name,
|
||||
"created":str(group.created)
|
||||
}))
|
||||
def group_update(request,pk):
|
||||
group = Group.objects.all().order_by('-created')
|
||||
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 = []
|
||||
for g in group:
|
||||
o = dict()
|
||||
o['id'] = str(g.id)
|
||||
o['image'] = g.image.url
|
||||
o['name'] = g.name
|
||||
o['type'] = g.type
|
||||
o['admin_count'] = Group_admin.objects.filter(group_id=g.id).count()
|
||||
o['user_count'] = Group_user.objects.filter(group_id=g.id).count()
|
||||
o['status'] = g.status
|
||||
res.append(o)
|
||||
return render(request, 'management/group-management.html', {'res': res, 'group': group})
|
||||
|
||||
|
||||
def group_update(request, pk):
|
||||
group = Group.objects.get(id=pk)
|
||||
GROUP_STATUS_CHOICES = Group.GROUP_STATUS_CHOICES
|
||||
group_status_choices_list = []
|
||||
for g in GROUP_STATUS_CHOICES:
|
||||
group_status_choices_list.append(list(g)[1])
|
||||
group_type = Group_type.objects.all()
|
||||
group_admin = Group_admin.objects.filter(group_id=pk)
|
||||
g_a_list = []
|
||||
for g_a in group_admin:
|
||||
o = dict()
|
||||
o['id'] = str(g_a.id)
|
||||
o['image'] = Userprofile.objects.get(user_id=g_a.user.id).image.url
|
||||
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)
|
||||
g_a_list.append(o)
|
||||
group_user = Group_user.objects.filter(group_id=pk)
|
||||
g_u_list = []
|
||||
for g_u in group_user:
|
||||
i = dict()
|
||||
i['id'] = str(g_u.id)
|
||||
i['image'] = Userprofile.objects.get(user_id=g_u.user.id).image.url
|
||||
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)
|
||||
g_u_list.append(i)
|
||||
if request.method == 'POST':
|
||||
name = request.POST.get('name')
|
||||
Group.objects.filter(id=pk).update(name=name)
|
||||
messages.success(request,'修改成功')
|
||||
return HttpResponseRedirect('/management/group/management/')
|
||||
return render(request,'management/group-management-update.html',{'group':group})
|
||||
presentation = request.POST.get('presentation')
|
||||
image = request.FILES.get('image')
|
||||
type = request.POST.get('type')
|
||||
status = request.POST.get('status')
|
||||
province = request.POST.get('province')
|
||||
print(str(province) + "66666666666666666666666666")
|
||||
if province != '' and province.isdigit():
|
||||
province_r = Area_code_2020.objects.get(code=province).name
|
||||
else:
|
||||
province_r = province
|
||||
city = request.POST.get('city')
|
||||
if city != '' and city.isdigit():
|
||||
city_r = Area_code_2020.objects.get(code=city).name
|
||||
else:
|
||||
city_r = city
|
||||
district = request.POST.get('district')
|
||||
if district != '' and district.isdigit():
|
||||
district_r = Area_code_2020.objects.get(code=district).name
|
||||
else:
|
||||
district_r = district
|
||||
town = request.POST.get('town')
|
||||
if town != '' and town.isdigit():
|
||||
town_r = Area_code_2020.objects.get(code=town).name
|
||||
else:
|
||||
town_r = town
|
||||
village = request.POST.get('village')
|
||||
if village != '' and village.isdigit():
|
||||
village_r = Area_code_2020.objects.get(code=village).name
|
||||
else:
|
||||
village_r = village
|
||||
if image is not None:
|
||||
Group.objects.filter(id=pk).update(name=name, presentation=presentation, type_id=type, status=status,
|
||||
province=province_r, cities=city_r, district=district_r, town=town_r,
|
||||
village=village_r)
|
||||
g = Group.objects.get(id=pk)
|
||||
g.image = image
|
||||
g.save()
|
||||
messages.success(request, '修改成功')
|
||||
return HttpResponseRedirect('/management/group/management/')
|
||||
else:
|
||||
Group.objects.filter(id=pk).update(name=name, presentation=presentation, type_id=type, status=status,
|
||||
province=province_r, cities=city_r, district=district_r, town=town_r,
|
||||
village=village_r)
|
||||
messages.success(request, '修改成功')
|
||||
return HttpResponseRedirect('/management/group/management/')
|
||||
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})
|
||||
|
||||
|
||||
def group_create(request):
|
||||
GROUP_STATUS_CHOICES = Group.GROUP_STATUS_CHOICES
|
||||
group_status_choices_list = []
|
||||
for g in GROUP_STATUS_CHOICES:
|
||||
group_status_choices_list.append(list(g)[1])
|
||||
group_type = Group_type.objects.all()
|
||||
if request.method == 'POST':
|
||||
name = request.POST.get('name')
|
||||
if name is not None:
|
||||
group = Group(name=name)
|
||||
group.save()
|
||||
messages.success(request,'添加成功')
|
||||
presentation = request.POST.get('presentation')
|
||||
image = request.FILES.get('image')
|
||||
type = request.POST.get('type')
|
||||
status = request.POST.get('status')
|
||||
province = request.POST.get('province')
|
||||
if province != '':
|
||||
province_r = Area_code_2020.objects.get(code=province).name
|
||||
else:
|
||||
messages.error(request,'群组名不能为空')
|
||||
messages.error(request, '请选择行政区划')
|
||||
return HttpResponseRedirect('/management/organization/create/')
|
||||
city = request.POST.get('city')
|
||||
if city != '':
|
||||
city_r = Area_code_2020.objects.get(code=city).name
|
||||
else:
|
||||
city_r = city
|
||||
district = request.POST.get('district')
|
||||
if district != '':
|
||||
district_r = Area_code_2020.objects.get(code=district).name
|
||||
else:
|
||||
district_r = district
|
||||
town = request.POST.get('town')
|
||||
if town != '':
|
||||
town_r = Area_code_2020.objects.get(code=town).name
|
||||
else:
|
||||
town_r = town
|
||||
village = request.POST.get('village')
|
||||
if village != '':
|
||||
village_r = Area_code_2020.objects.get(code=village).name
|
||||
else:
|
||||
village_r = village
|
||||
print(name, presentation, image, type, status, province, city, district, town, village)
|
||||
if name is not None:
|
||||
group = Group(name=name, presentation=presentation, image=image, type_id=type, status=status,
|
||||
province=province_r, cities=city_r, district=district_r, town=town_r, village=village_r)
|
||||
group.save()
|
||||
messages.success(request, '添加成功')
|
||||
else:
|
||||
messages.error(request, '群组名不能为空')
|
||||
return HttpResponseRedirect('/management/group/management/')
|
||||
return render(request,'management/group-management-create.html')
|
||||
def group_delete(request,pk):
|
||||
return render(request, 'management/group-management-create.html',
|
||||
{'group_status_choices_list': group_status_choices_list, 'group_type': group_type})
|
||||
|
||||
|
||||
def group_delete(request, pk):
|
||||
group = Group.objects.get(id=pk)
|
||||
group.delete()
|
||||
messages.success(request,'删除成功')
|
||||
messages.success(request, '删除成功')
|
||||
return HttpResponseRedirect('/management/group/management/')
|
||||
|
||||
|
||||
def organization_management(request):
|
||||
organization = Organization.objects.all()
|
||||
return render(request,'management/organization-management.html',{"organization":organization})
|
||||
def organization_detail(request,pk):
|
||||
organization = Organization.objects.get(id=pk)
|
||||
return HttpResponse(json.dumps({
|
||||
"status":"1",
|
||||
"id":str(organization.id),
|
||||
"name":organization.name,
|
||||
"group":organization.group.name,
|
||||
"level":organization.level.name,
|
||||
"created":str(organization.created).split('.')[0],
|
||||
}))
|
||||
def organization_delete(request,pk):
|
||||
organization = Organization.objects.all().order_by('-created')
|
||||
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)
|
||||
res = []
|
||||
for i in organization:
|
||||
o = dict()
|
||||
o['id'] = str(i.id)
|
||||
o['name'] = i.name
|
||||
o['image'] = i.image.url
|
||||
o['organizationtype'] = i.organizationtype.organizationtype
|
||||
o['administrativedivision'] = str(i.province) + '-' + str(i.cities) + '-' + str(i.district) + '-' + str(
|
||||
i.town) + '-' + str(i.village)
|
||||
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})
|
||||
|
||||
|
||||
def organization_delete(request, pk):
|
||||
organization = Organization.objects.get(id=pk)
|
||||
organization.delete()
|
||||
messages.success(request, '删除成功')
|
||||
return HttpResponseRedirect('/management/organization/management/')
|
||||
|
||||
def organization_update(request,pk):
|
||||
|
||||
def organization_update(request, pk):
|
||||
organization = Organization.objects.get(id=pk)
|
||||
group = Group.objects.all()
|
||||
level = Level.objects.all()
|
||||
organizationtype = Organizationtype.objects.all()
|
||||
if request.method == 'POST':
|
||||
name = request.POST.get('name')
|
||||
group = request.POST.get('group')
|
||||
level = request.POST.get('level')
|
||||
Organization.objects.filter(id=pk).update(name=name,group=group,level=level)
|
||||
messages.success(request, '修改成功')
|
||||
return HttpResponseRedirect('/management/organization/management/')
|
||||
return render(request,'management/organization-management-update.html',{'organization':organization,'level':level,'group':group})
|
||||
def organization_create(request):
|
||||
group = Group.objects.all()
|
||||
level = Level.objects.all()
|
||||
if request.method == 'POST':
|
||||
name = request.POST.get('name')
|
||||
group = request.POST.get('group')
|
||||
level = request.POST.get('level')
|
||||
if name is not None:
|
||||
organization = Organization(name=name,group_id=group,level_id=level)
|
||||
organization.save()
|
||||
messages.success(request,'添加成功')
|
||||
image = request.FILES.get('image')
|
||||
organizationtype = request.POST.get('organizationtype')
|
||||
province = request.POST.get('province')
|
||||
if province != '' and province.isdigit():
|
||||
province_r = Area_code_2020.objects.get(code=province).name
|
||||
else:
|
||||
messages.error(request,'单位名不能为空')
|
||||
province_r = province
|
||||
city = request.POST.get('city')
|
||||
if city != '' and city.isdigit():
|
||||
city_r = Area_code_2020.objects.get(code=city).name
|
||||
else:
|
||||
city_r = city
|
||||
district = request.POST.get('district')
|
||||
if district != '' and district.isdigit():
|
||||
district_r = Area_code_2020.objects.get(code=district).name
|
||||
else:
|
||||
district_r = district
|
||||
town = request.POST.get('town')
|
||||
if town != '' and town.isdigit():
|
||||
town_r = Area_code_2020.objects.get(code=town).name
|
||||
else:
|
||||
town_r = town
|
||||
village = request.POST.get('village')
|
||||
if village != '' and village.isdigit():
|
||||
village_r = Area_code_2020.objects.get(code=village).name
|
||||
else:
|
||||
village_r = village
|
||||
if name is not None:
|
||||
if image is not None:
|
||||
Organization.objects.filter(id=pk).update(name=name, organizationtype_id=organizationtype,
|
||||
province=province_r, cities=city_r, district=district_r,
|
||||
town=town_r, village=village_r)
|
||||
o = Organization.objects.get(id=pk)
|
||||
o.image = image
|
||||
o.save()
|
||||
messages.success(request, '修改成功')
|
||||
return HttpResponseRedirect('/management/organization/management/')
|
||||
else:
|
||||
Organization.objects.filter(id=pk).update(name=name, organizationtype_id=organizationtype,
|
||||
province=province_r, cities=city_r, district=district_r,
|
||||
town=town_r, village=village_r)
|
||||
messages.success(request, '修改成功')
|
||||
return HttpResponseRedirect('/management/organization/management/')
|
||||
return render(request, 'management/organization-management-update.html',
|
||||
{'organization': organization, 'organizationtype': organizationtype})
|
||||
|
||||
|
||||
def organization_create(request):
|
||||
organizationtype = Organizationtype.objects.all()
|
||||
if request.method == 'POST':
|
||||
name = request.POST.get('name')
|
||||
image = request.FILES.get('image')
|
||||
organizationtype = request.POST.get('organizationtype')
|
||||
province = request.POST.get('province')
|
||||
if province != '':
|
||||
province_r = Area_code_2020.objects.get(code=province).name
|
||||
else:
|
||||
messages.error(request, '请选择行政区划')
|
||||
return HttpResponseRedirect('/management/organization/create/')
|
||||
city = request.POST.get('city')
|
||||
if city != '':
|
||||
city_r = Area_code_2020.objects.get(code=city).name
|
||||
else:
|
||||
city_r = city
|
||||
district = request.POST.get('district')
|
||||
if district != '':
|
||||
district_r = Area_code_2020.objects.get(code=district).name
|
||||
else:
|
||||
district_r = district
|
||||
town = request.POST.get('town')
|
||||
if town != '':
|
||||
town_r = Area_code_2020.objects.get(code=town).name
|
||||
else:
|
||||
town_r = town
|
||||
village = request.POST.get('village')
|
||||
if village != '':
|
||||
village_r = Area_code_2020.objects.get(code=village).name
|
||||
else:
|
||||
village_r = village
|
||||
print(province, city)
|
||||
if name is not None:
|
||||
organization = Organization(name=name, image=image, organizationtype_id=organizationtype,
|
||||
province=province_r, cities=city_r, district=district_r, town=town_r,
|
||||
village=village_r)
|
||||
organization.save()
|
||||
messages.success(request, '添加成功')
|
||||
else:
|
||||
messages.error(request, '单位名不能为空')
|
||||
return HttpResponseRedirect('/management/organization/management/')
|
||||
return render(request,'management/organization-management-create.html',{'level':level,'group':group})
|
||||
return render(request, 'management/organization-management-create.html', {'organizationtype': organizationtype})
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 162 KiB |
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
Loading…
Reference in New Issue