This commit is contained in:
xieshen 2021-01-07 18:54:35 +08:00
commit fa875390dc
4 changed files with 131 additions and 1 deletions

View File

@ -0,0 +1,59 @@
{% extends 'dashboard/base/base.html' %}
{% load static %}
{% block content %}
<body class=" ">
<!-- START TOPBAR -->
<!-- START CONTAINER -->
<div class="page-container row-fluid">
<div class="page-sidebar ">
{% include 'dashboard/base/left.html' %}
</div>
<section id="main-content" class=" ">
<section class="wrapper" style='margin-top:60px;display:inline-block;width:100%;padding:15px 0 0 15px;'>
{% if messages %}
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert">
<span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
</button>
{% for message in messages %}
{{ message }}.<br/>
{% endfor %}
</div>
{% endif %}
</section>
<div class="chatapi-windows "></div>
<div class="panel panel-default">
<div class="panel-body">
<div class="panel panel-default">
<div class="panel-heading">单位数据更新</div>
<div class="panel panel-default">
<!-- Default panel contents -->
<form action="{% url 'backstage-organization_update' %}" method="post"
enctype="multipart/form-data">{% csrf_token %}
{# <div class="form-group col-md-4">#}
{# <label for="date">时间</label>#}
{# <input type="date" class="form-control" id="source"#}
{# name="date">#}
{# </div>#}
<div class="form-group">
<label for="exampleInputFile">点击上传文件</label>
<input type="file" id="exampleInputFile" name="file">
</div>
<button type="submit" class="btn btn-success">点击上传</button>
</form>
</div>
</div>
</div>
</div>
</section>
</div>
</body>
{% endblock %}

View File

@ -8,4 +8,5 @@ urlpatterns = [
path('backstage/error/',views.backstage_error,name='backstage-error'),
path('backstage/comment/',views.backstage_comment,name='backstage-comment'),
path('backstage/user/',views.backstage_user,name='backstage-user'),
path('backstage/organization/update/',views.backstage_organization_update,name='backstage-organization_update'),
]

View File

@ -129,3 +129,46 @@ def backstage_comment(request):
def backstage_user(request):
return render(request, '')
def backstage_organization_update(request):
if request.method == 'POST':
filename = request.FILES.get('file')
date = request.POST.get("date")
date_length = request.POST.get("date_length")
if not os.path.exists(settings.MEDIA_ROOT):
os.makedirs(settings.MEDIA_ROOT)
if filename is None:
messages.error(request, '请选择要上传的文件!!!')
return HttpResponseRedirect('/backstage/backstage/organization/update/')
data = xlrd.open_workbook(filename=None, file_contents=filename.read())
table = data.sheets()[0]
for row in range(table.nrows):
v = table.row_values(row)[1]
if v != '单位全称':
try:
identificationcode = table.row_values(row)[3]
n_type = table.row_values(row)[7]
results = table.row_values(row)[21]
update = table.row_values(row)[22]
silent = table.row_values(row)[23]
start_data = table.row_values(row)[24]
d = datetime(*xldate_as_tuple(start_data, 0))
cell_start = d.strftime('%Y-%m-%d')
end_data = table.row_values(row)[25]
e = datetime(*xldate_as_tuple(end_data, 0))
cell_end = e.strftime('%Y-%m-%d')
city = table.row_values(row)[10]
cell_city = Area_code_2020.objects.get(name=city).code
district = table.row_values(row)[11]
cell_district = Area_code_2020.objects.get(name=district).code
timelinessmonitoring = TimelinessMonitoring(identificationcode=identificationcode, n_type=n_type,
results=results, update=update, silent=silent,
start_data=cell_start, end_data=cell_end, date=date,
date_length=date_length,city=cell_city,district=cell_district)
timelinessmonitoring.save()
except:
pass
messages.success(request,"上传成功")
return render(request, 'backstage/backstage-organization-update.html')

View File

@ -33,7 +33,7 @@
<!-- USER INFO - END -->
<ul class='wraplist'>
<ul class='wraplist' style="min-height: 1500px">
{% for u in user.userprofile_set.all %}
{% if u.organization.level.level == 9 %}
<li {% if url_name == 'monitor-new-media-public-opinion-weixin' %} class="open" {% endif %} >
@ -189,6 +189,33 @@
<li>
<a {% if url_name == 'backstage-comment' %} class="active" {% endif %}
href="{% url 'backstage-comment' %}">评论</a>
</li>
<li>
<a {% if url_name == 'backstage-comment' %} class="active" {% endif %}
href="{% url 'backstage-organization_update' %}">单位更新</a>
</li>
<li>
<a {% if url_name == 'backstage-comment' %} class="active" {% endif %}
href="{% url 'backstage-comment' %}">微信更新</a>
</li>
<li>
<a {% if url_name == 'backstage-comment' %} class="active" {% endif %}
href="{% url 'backstage-comment' %}">头条更新</a>
</li>
<li>
<a {% if url_name == 'backstage-comment' %} class="active" {% endif %}
href="{% url 'backstage-comment' %}">抖音更新</a>
</li>
<li>
<a {% if url_name == 'backstage-comment' %} class="active" {% endif %}
href="{% url 'backstage-comment' %}">微博更新</a>
</li>
<li>
<a {% if url_name == 'backstage-comment' %} class="active" {% endif %}
href="{% url 'backstage-comment' %}">其他更新</a>
</li>
<li>
</li>
{# <li>#}
{# <a {% if url_name == 'backstage-user' %} class="active" {% endif %}#}