Merge branch 'master' of http://git.eanbo.cn/xieshen/newmediamonitoring
This commit is contained in:
commit
30c6b55370
|
@ -159,7 +159,6 @@ MEDIA_ROOT = '/var/www/p3/newmediamonitoring/media/'
|
||||||
"""用户模块扩展部分"""
|
"""用户模块扩展部分"""
|
||||||
AUTH_PROFILE_MODULE = 'djangoadmin.myadmin.UserProfile'
|
AUTH_PROFILE_MODULE = 'djangoadmin.myadmin.UserProfile'
|
||||||
"""用户模块扩展完成"""
|
"""用户模块扩展完成"""
|
||||||
UPLOAD_ROOT = os.path.join(BASE_DIR,'/static/upload')
|
|
||||||
CORS_ORIGIN_ALLOW_ALL = True
|
CORS_ORIGIN_ALLOW_ALL = True
|
||||||
|
|
||||||
CORS_URLS_REGEX = r'^/polls/.*$'
|
CORS_URLS_REGEX = r'^/polls/.*$'
|
||||||
|
|
|
@ -32,11 +32,17 @@
|
||||||
<div class="panel-heading">新媒体舆情数据录入</div>
|
<div class="panel-heading">新媒体舆情数据录入</div>
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<!-- Default panel contents -->
|
<!-- Default panel contents -->
|
||||||
<form action="{% url 'backstage-new-media-public-opinion' %}" method="post" enctype="multipart/form-data" >{% csrf_token %}
|
<form action="{% url 'backstage-new-media-public-opinion' %}" 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">
|
<div class="form-group">
|
||||||
<label for="exampleInputFile">点击上传文件</label>
|
<label for="exampleInputFile">点击上传文件</label>
|
||||||
<input type="file" id="exampleInputFile" name="file">
|
<input type="file" id="exampleInputFile" name="file">
|
||||||
<p class="help-block">请上传excel文件</p>
|
<p class="help-block">请上传csv文件(文件表头依次为:新媒体类型,新媒体名称,主体类型,代表主体名称,市,县/区,备注,结果,更新次数,最大连续静默日数,开始时间,结束时间。时间格式为(2020/11/17).更新次数和最大连续静默日必须是数字)</p>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-success">点击上传</button>
|
<button type="submit" class="btn btn-success">点击上传</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -4,5 +4,6 @@ from django.urls import path
|
||||||
from backstage import views
|
from backstage import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('backstage/newmedia/public/opinion/',views.backstage_new_media_public_opinion,name='backstage-new-media-public-opinion')
|
path('backstage/newmedia/public/opinion/',views.backstage_new_media_public_opinion,name='backstage-new-media-public-opinion'),
|
||||||
|
path('backstage/error/',views.backstage_error,name='backstage-error'),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,24 +1,80 @@
|
||||||
|
import csv
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
import xlrd
|
import xlrd
|
||||||
from django.http import HttpResponse
|
from django.contrib import messages
|
||||||
|
from django.http import HttpResponse, HttpResponseRedirect
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
from NewMediaMonitoring import settings
|
from NewMediaMonitoring import settings
|
||||||
|
from dashboard.models import TimelinessMonitoring
|
||||||
|
|
||||||
|
|
||||||
def backstage_new_media_public_opinion(request):
|
def backstage_new_media_public_opinion(request):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
filename = request.FILES.get('file')
|
filename = request.FILES.get('file')
|
||||||
workbook = xlrd.open_workbook(settings.UPLOAD_ROOT + "/" + str(filename))
|
date = request.POST.get("date")
|
||||||
# sheet = readboot.sheet_by_index(0)
|
print(filename)
|
||||||
# # 获取excel的行和列
|
if not os.path.exists(settings.MEDIA_ROOT):
|
||||||
# nrows = sheet.nrows
|
os.makedirs(settings.MEDIA_ROOT)
|
||||||
# ncols = sheet.ncols
|
if filename is None:
|
||||||
table = workbook.sheets()[0]
|
messages.error(request,'请选择要上传的文件!!!')
|
||||||
for row in range(table.nrows):
|
return HttpResponseRedirect('/backstage/backstage/newmedia/public/opinion/')
|
||||||
v = table.row_values(row)[0]
|
if str(filename).split('.')[1] == 'csv':
|
||||||
if v != '账号名称':
|
data = filename.read().decode("utf-8")
|
||||||
print(table.row_values(row)[0])
|
line = str(data).split('\n')
|
||||||
return render(request,'backstage/backstage_new_media_public_opinion.html')
|
for l in line:
|
||||||
|
v = l.split(',')
|
||||||
|
# print(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11])
|
||||||
|
# if str(v[0]) != '新媒体类型' or str(v[1]) != '新媒体名称' or str(v[2]) != '主体类型' or str(v[3]) != '代表主体名称' or str(v[4]) != '市' or str(v[6]) != '备注' or str(v[7]) != '结果' or str(v[8]) != '更新次数' or str(v[9]) != '最大连续静默日数' or str(v[10]) != '开始时间' or str(v[11]) != '结束时间':
|
||||||
|
# messages.error(request, '请上传正确的文件格式!!!')
|
||||||
|
# return HttpResponseRedirect('/backstage/backstage/newmedia/public/opinion/')
|
||||||
|
mat1 = None
|
||||||
|
mat2 = None
|
||||||
|
# if v[10] is not None and v[11] is not None:
|
||||||
|
# mat1 = re.search(r"(\d{4}/\d{1,2}/\d{1,2})", v[10])
|
||||||
|
# mat2 = re.search(r"(\d{4}/\d{1,2}/\d{1,2})", v[11])
|
||||||
|
# if mat1 is None or mat2 is None:
|
||||||
|
# messages.error(request, '请上传正确的时间格式!!!')
|
||||||
|
# return HttpResponseRedirect('/backstage/backstage/newmedia/public/opinion/')
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
if v[8] != '更新次数':
|
||||||
|
# if v[8].isdigit():
|
||||||
|
n_type = v[0]
|
||||||
|
n_name = v[1]
|
||||||
|
o_type = v[2]
|
||||||
|
o_name = v[3]
|
||||||
|
city = v[4]
|
||||||
|
counties = v[5]
|
||||||
|
remark = v[6]
|
||||||
|
results = v[7]
|
||||||
|
update = v[8]
|
||||||
|
silet = v[9]
|
||||||
|
start_data = v[10]
|
||||||
|
end_data = v[11]
|
||||||
|
timelinessmonitoring = TimelinessMonitoring(n_type=n_type, n_name=n_name, o_type=o_type,
|
||||||
|
o_name=o_name,
|
||||||
|
city=city, counties=counties, remark=remark,
|
||||||
|
results=results, update=update, silet=silet,
|
||||||
|
start_data=start_data, end_data=end_data,
|
||||||
|
comment=0, date=date)
|
||||||
|
print(timelinessmonitoring.n_type)
|
||||||
|
timelinessmonitoring.save()
|
||||||
|
# else:
|
||||||
|
# messages.error(request, '更新次数只能为数字!!!')
|
||||||
|
# return HttpResponseRedirect('/backstage/backstage/newmedia/public/opinion/')
|
||||||
|
except:
|
||||||
|
print(v)
|
||||||
|
|
||||||
|
else:
|
||||||
|
messages.error(request, '请上传正确的文件类型!!!')
|
||||||
|
return HttpResponseRedirect('/backstage/backstage/newmedia/public/opinion/')
|
||||||
|
|
||||||
|
return render(request, 'backstage/backstage_new_media_public_opinion.html')
|
||||||
|
|
||||||
|
def backstage_error(resquest):
|
||||||
|
pass
|
|
@ -731,7 +731,7 @@ class NewmediaSentimentToutiao(models.Model):
|
||||||
|
|
||||||
|
|
||||||
class TimelinessMonitoring(models.Model):
|
class TimelinessMonitoring(models.Model):
|
||||||
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4())
|
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
|
||||||
n_type = models.CharField('新媒体类型', max_length=256, null=True, blank=True)
|
n_type = models.CharField('新媒体类型', max_length=256, null=True, blank=True)
|
||||||
n_name = models.CharField('新媒体名称', max_length=256, null=True, blank=True)
|
n_name = models.CharField('新媒体名称', max_length=256, null=True, blank=True)
|
||||||
o_type = models.CharField('主体类型', max_length=256, null=True, blank=True)
|
o_type = models.CharField('主体类型', max_length=256, null=True, blank=True)
|
||||||
|
@ -766,3 +766,6 @@ class Wrongly(models.Model):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.title
|
return self.title
|
||||||
|
#时效性监测文件存储表
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@
|
||||||
<ul class="sub-menu">
|
<ul class="sub-menu">
|
||||||
<li>
|
<li>
|
||||||
<a {% if url_name == 'backstage-new-media-public-opinion' %} class="active" {% endif %}
|
<a {% if url_name == 'backstage-new-media-public-opinion' %} class="active" {% endif %}
|
||||||
href="{% url 'backstage-new-media-public-opinion' %}">新媒体舆情</a>
|
href="{% url 'backstage-new-media-public-opinion' %}">时效性监测</a>
|
||||||
</li>
|
</li>
|
||||||
{# <li>#}
|
{# <li>#}
|
||||||
{# <a {% if url_name == 'group-management-management-init' %} class="active" {% endif %}#}
|
{# <a {% if url_name == 'group-management-management-init' %} class="active" {% endif %}#}
|
||||||
|
|
|
@ -471,6 +471,7 @@ def user_search_by_keyword(request):
|
||||||
for u in userpaginator[:30]:
|
for u in userpaginator[:30]:
|
||||||
o = dict()
|
o = dict()
|
||||||
o['id'] = str(u.id)
|
o['id'] = str(u.id)
|
||||||
|
o['user_id'] = str(u.user_id)
|
||||||
if u.image:
|
if u.image:
|
||||||
o['image'] = u.image
|
o['image'] = u.image
|
||||||
o['name'] = u.name
|
o['name'] = u.name
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<select class="form-control" name="keytype">
|
<select class="form-control" name="keytype">
|
||||||
<option value="1">新媒体名称</option>
|
<option value="1">新媒体名称</option>
|
||||||
<option value="2">责任主体</option>
|
<option value="2">责任主体</option>
|
||||||
{# <option value="3">行政区划</option>#}
|
{# <option value="3">行政区划</option>#}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-6 title">
|
<div class="col-lg-6 title">
|
||||||
|
@ -62,7 +62,9 @@
|
||||||
{% for w in res %}
|
{% for w in res %}
|
||||||
<tr>
|
<tr>
|
||||||
<td style="vertical-align: middle;text-align: center">{{ forloop.counter }}</td>
|
<td style="vertical-align: middle;text-align: center">{{ forloop.counter }}</td>
|
||||||
<td style="text-align: center"><img src="{{ w.image.url }}"
|
<td style="text-align: center"><img {% if w.image.url %}
|
||||||
|
src="{{ w.image.url }}"{% else %}
|
||||||
|
src="{% static 'dashboard/image/douyin.jpg' %}" {% endif %}
|
||||||
style="width: 60px;height: 60px;margin: auto"
|
style="width: 60px;height: 60px;margin: auto"
|
||||||
class="img-circle"></td>
|
class="img-circle"></td>
|
||||||
<td style="vertical-align: middle;text-align: center">{{ w.code }}</td>
|
<td style="vertical-align: middle;text-align: center">{{ w.code }}</td>
|
||||||
|
|
|
@ -64,7 +64,9 @@
|
||||||
{% for w in res %}
|
{% for w in res %}
|
||||||
<tr>
|
<tr>
|
||||||
<td style="vertical-align: middle;text-align: center">{{ forloop.counter }}</td>
|
<td style="vertical-align: middle;text-align: center">{{ forloop.counter }}</td>
|
||||||
<td style="text-align: center"><img src="{{ w.image.url }}"
|
<td style="text-align: center"><img {% if w.image.url %}
|
||||||
|
src="{{ w.image.url }}"{% else %}
|
||||||
|
src="{% static 'dashboard/image/qita.png' %}" {% endif %}
|
||||||
style="width: 60px;height: 60px;margin: auto"
|
style="width: 60px;height: 60px;margin: auto"
|
||||||
class="img-circle"></td>
|
class="img-circle"></td>
|
||||||
<td style="vertical-align: middle;text-align: center">{{ w.type }}</td>
|
<td style="vertical-align: middle;text-align: center">{{ w.type }}</td>
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<select class="form-control" name="keytype">
|
<select class="form-control" name="keytype">
|
||||||
<option value="1">新媒体名称</option>
|
<option value="1">新媒体名称</option>
|
||||||
<option value="2">责任主体</option>
|
<option value="2">责任主体</option>
|
||||||
{# <option value="3">行政区划</option>#}
|
{# <option value="3">行政区划</option>#}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-6 title">
|
<div class="col-lg-6 title">
|
||||||
|
@ -62,7 +62,9 @@
|
||||||
{% for w in res %}
|
{% for w in res %}
|
||||||
<tr>
|
<tr>
|
||||||
<td style="vertical-align: middle;text-align: center">{{ forloop.counter }}</td>
|
<td style="vertical-align: middle;text-align: center">{{ forloop.counter }}</td>
|
||||||
<td style="text-align: center"><img src="{{ w.image.url }}"
|
<td style="text-align: center"><img {% if w.image.url %}
|
||||||
|
src="{{ w.image.url }}"{% else %}
|
||||||
|
src="{% static 'dashboard/image/toutiao.png' %}" {% endif %}
|
||||||
style="width: 60px;height: 60px;margin: auto"
|
style="width: 60px;height: 60px;margin: auto"
|
||||||
class="img-circle"></td>
|
class="img-circle"></td>
|
||||||
<td style="vertical-align: middle;text-align: center">{{ w.code }}</td>
|
<td style="vertical-align: middle;text-align: center">{{ w.code }}</td>
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<select class="form-control" name="keytype">
|
<select class="form-control" name="keytype">
|
||||||
<option value="1">新媒体名称</option>
|
<option value="1">新媒体名称</option>
|
||||||
<option value="2">责任主体</option>
|
<option value="2">责任主体</option>
|
||||||
{# <option value="3">行政区划</option>#}
|
{# <option value="3">行政区划</option>#}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-6 title">
|
<div class="col-lg-6 title">
|
||||||
|
@ -63,7 +63,9 @@
|
||||||
{% for w in res %}
|
{% for w in res %}
|
||||||
<tr>
|
<tr>
|
||||||
<td style="vertical-align: middle;text-align: center">{{ forloop.counter }}</td>
|
<td style="vertical-align: middle;text-align: center">{{ forloop.counter }}</td>
|
||||||
<td style="text-align: center"><img src="{{ w.image.url }}"
|
<td style="text-align: center"><img {% if w.image.url %}
|
||||||
|
src="{{ w.image.url }}"{% else %}
|
||||||
|
src="{% static 'dashboard/image/weibo.png' %}" {% endif %}
|
||||||
style="width: 60px;height: 60px;margin: auto"
|
style="width: 60px;height: 60px;margin: auto"
|
||||||
class="img-circle"></td>
|
class="img-circle"></td>
|
||||||
<td style="vertical-align: middle;text-align: center">{{ w.code }}</td>
|
<td style="vertical-align: middle;text-align: center">{{ w.code }}</td>
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<select class="form-control" name="keytype">
|
<select class="form-control" name="keytype">
|
||||||
<option value="1">新媒体名称</option>
|
<option value="1">新媒体名称</option>
|
||||||
<option value="2">责任主体</option>
|
<option value="2">责任主体</option>
|
||||||
{# <option value="3">行政区划</option>#}
|
{# <option value="3">行政区划</option>#}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-6 title">
|
<div class="col-lg-6 title">
|
||||||
|
@ -62,7 +62,9 @@
|
||||||
{% for w in res %}
|
{% for w in res %}
|
||||||
<tr>
|
<tr>
|
||||||
<td style="vertical-align: middle;text-align: center">{{ forloop.counter }}</td>
|
<td style="vertical-align: middle;text-align: center">{{ forloop.counter }}</td>
|
||||||
<td style="text-align: center"><img src="{{ w.image.url }}"
|
<td style="text-align: center"><img {% if w.image.url %}
|
||||||
|
src="{{ w.image.url }}"{% else %}
|
||||||
|
src="{% static 'dashboard/image/weixin.png' %}" {% endif %}
|
||||||
style="width: 60px;height: 60px;margin: auto"
|
style="width: 60px;height: 60px;margin: auto"
|
||||||
class="img-circle"></td>
|
class="img-circle"></td>
|
||||||
<td style="vertical-align: middle;text-align: center">{{ w.code }}</td>
|
<td style="vertical-align: middle;text-align: center">{{ w.code }}</td>
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
<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">电话<a href="{% url 'user-management-management-sort' %}">^</a></th>
|
<th style="text-align: center">电话<a href="{% url 'user-management-management-sort' %}"></a></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>
|
||||||
|
@ -71,7 +71,7 @@
|
||||||
{# <td style="vertical-align: middle;text-align: center">{{ u.type }}</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">{{ u.administrativedivision }}</td>
|
||||||
<td style="vertical-align: middle;text-align: center">
|
<td style="vertical-align: middle;text-align: center">
|
||||||
<a href="{% url 'user-management-delete' u.id %}"
|
<a href="{% url 'user-management-delete' u.user_id %}"
|
||||||
class="btn btn-danger btn-mini">删除</a>
|
class="btn btn-danger btn-mini">删除</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -58,7 +58,7 @@ urlpatterns = [
|
||||||
#新闻管理
|
#新闻管理
|
||||||
path('news/management/',views.new_management,name='news-management'),
|
path('news/management/',views.new_management,name='news-management'),
|
||||||
path('news/management/create/', views.news_management_create, name='news-management-create'),
|
path('news/management/create/', views.news_management_create, name='news-management-create'),
|
||||||
path('news/management/updaye/<str:pk>/', views.news_management_update, name='news-management-update'),
|
path('news/management/update/<str:pk>/', views.news_management_update, name='news-management-update'),
|
||||||
path('news/management/detail/<str:pk>/', views.news_management_detail, name='news-management-detail'),
|
path('news/management/detail/<str:pk>/', views.news_management_detail, name='news-management-detail'),
|
||||||
path('news/management/delete/<str:pk>/', views.news_management_delete, name='news-management-delete'),
|
path('news/management/delete/<str:pk>/', views.news_management_delete, name='news-management-delete'),
|
||||||
]
|
]
|
||||||
|
|
|
@ -24,16 +24,16 @@ def user_management(request):
|
||||||
district = o.district
|
district = o.district
|
||||||
userpaginator = None
|
userpaginator = None
|
||||||
if level == 1:
|
if level == 1:
|
||||||
userpaginator = User.objects.filter(userprofile__organization__province=province).order_by('-date_joined')
|
userpaginator = Userprofile.objects.filter(organization__province=province).order_by('-created')
|
||||||
elif level == 2:
|
elif level == 2:
|
||||||
userpaginator = User.objects.filter(userprofile__organization__province=province,
|
userpaginator = Userprofile.objects.filter(organization__province=province,
|
||||||
userprofile__organization__cities=cities).order_by('-date_joined')
|
organization__cities=cities).order_by('-created')
|
||||||
elif level == 3:
|
elif level == 3:
|
||||||
userpaginator = User.objects.filter(userprofile__organization__province=province,
|
userpaginator = Userprofile.objects.filter(organization__province=province,
|
||||||
userprofile__organization__cities=cities,
|
organization__cities=cities,
|
||||||
userprofile__organization__district=district).order_by('-date_joined')
|
organization__district=district).order_by('-created')
|
||||||
elif level == 9:
|
elif level == 9:
|
||||||
userpaginator = User.objects.all().order_by('-date_joined')
|
userpaginator = Userprofile.objects.all().order_by('-created')
|
||||||
userallinfo = []
|
userallinfo = []
|
||||||
if userpaginator is not None:
|
if userpaginator is not None:
|
||||||
paginator = Paginator(userpaginator, 6)
|
paginator = Paginator(userpaginator, 6)
|
||||||
|
@ -48,12 +48,13 @@ def user_management(request):
|
||||||
for u in userpaginator:
|
for u in userpaginator:
|
||||||
o = dict()
|
o = dict()
|
||||||
o['id'] = str(u.id)
|
o['id'] = str(u.id)
|
||||||
if u.userprofile_set.get(user_id=u.id).image:
|
o['user_id'] = str(u.user_id)
|
||||||
o['image'] = u.userprofile_set.get(user_id=u.id).image
|
if u.image:
|
||||||
o['name'] = u.userprofile_set.get(user_id=u.id).name
|
o['image'] = u.image
|
||||||
o['phone'] = u.username
|
o['name'] = u.name
|
||||||
o['organization'] = u.userprofile_set.get(user_id=u.id).organization.name
|
o['phone'] = u.user.username
|
||||||
organization_id = Userprofile.objects.get(user_id=u.id).organization_id
|
o['organization'] = u.organization.name
|
||||||
|
organization_id = u.organization.id
|
||||||
print(organization_id)
|
print(organization_id)
|
||||||
if Organization.objects.get(id=organization_id).province and Organization.objects.get(
|
if Organization.objects.get(id=organization_id).province and Organization.objects.get(
|
||||||
id=organization_id).cities and Organization.objects.get(
|
id=organization_id).cities and Organization.objects.get(
|
||||||
|
@ -100,8 +101,9 @@ def user_management(request):
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def user_delete(request, pk):
|
def user_delete(request, pk):
|
||||||
|
print(pk)
|
||||||
user = User.objects.get(id=pk)
|
user = User.objects.get(id=pk)
|
||||||
user.delete()
|
# user.delete()
|
||||||
return HttpResponseRedirect('/management/user/management/')
|
return HttpResponseRedirect('/management/user/management/')
|
||||||
|
|
||||||
|
|
||||||
|
|
40
test.py
40
test.py
|
@ -1,38 +1,4 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import csv
|
|
||||||
import re
|
import re
|
||||||
import uuid
|
s = '2020-10-9'
|
||||||
import os
|
mat = re.search(r"(\d{4}-\d{1,2}-\d{1,2})",s)
|
||||||
import psycopg2
|
print(mat)
|
||||||
|
|
||||||
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(title,date, code,content):
|
|
||||||
with psycopg2.connect(G2) as connection:
|
|
||||||
with connection.cursor() as cursor:
|
|
||||||
id = uuid.uuid4()
|
|
||||||
cursor.execute(
|
|
||||||
'insert into monitor_test(id, title,date, code,content) values (%s,%s, %s,%s,%s)'
|
|
||||||
, (str(id),title,date, code,content))
|
|
||||||
connection.commit()
|
|
||||||
return code
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
|
|
||||||
with open('D:/2020/舆论监测平台/新媒体监测数据/天水/天水20200822-20200922/天水20200822-20200922数据整理/天水微信正文.csv',encoding='utf8') as csvfile:
|
|
||||||
reader = csv.reader(csvfile)
|
|
||||||
try:
|
|
||||||
for r in reader:
|
|
||||||
print(r)
|
|
||||||
title = r[0]
|
|
||||||
date = r[1]
|
|
||||||
code = r[2]
|
|
||||||
content = r[5]
|
|
||||||
insert_area(title, date, code, content)
|
|
||||||
except:
|
|
||||||
pass
|
|
Loading…
Reference in New Issue