Commit 607c7610 by liuyingying
parents 6a38b066 27368a3d
......@@ -192,19 +192,21 @@ svg{
}
.title{
width:60%;
font-size:20px;
font-size:18px;
text-align: left;
}
#articles{
position: relative;
}
#articleList{
position:absolute;
width:50%;
/* position:absolute;
width:50%; */
margin-bottom: 0;
}
.lastStep{
width:30px;
height:30px;
height:30px;
margin-top: 12px;
}
#writenoticeLi>a{
color:black;
......@@ -215,20 +217,22 @@ svg{
line-height: 50px;
text-align: center;
font-size:24px;
font-weight: bold;
font-weight: bold;
float: left;
}
#authorName{
width:100%;
height:30px;
margin-top:10px;
line-height: 30px;
padding-right: 5%;
text-align: right;
font-style: italic;
}
#content{
width:100%;
margin-top:50px;
background-color: #eaeaea;
/* background-color: #eaeaea; */
padding: 20px;
}
#addScore{
......
......@@ -111,7 +111,7 @@
<!--内部文章管理-->
<div id="privateArtadmin" class="userlist" style="border:1px solid #000;">
<span id="user_score_List" style="color:#ff9800" >内部文章</span>
<table class="table tableList">
<table class="table tableList" id="articleList">
<thead>
</thead>
<tbody>
......@@ -138,7 +138,7 @@
<div id="articleView" class="hide" >
<button class="lastStep" onclick="returnToList()"><?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1541063213171" class="icon" style="" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2135" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M939.880137 487.72513l-782.215258 0 358.804922-318.92975c12.389168-11.011798 13.505595-29.980825 2.492774-42.369993-11.011798-12.386098-29.977755-13.505595-42.367947-2.492774L64.602344 490.13911c-6.407943 5.693676-10.073426 13.858636-10.073426 22.430872s3.665483 16.737196 10.073426 22.430872l411.993309 366.204449c5.717212 5.083785 12.83533 7.580652 19.925818 7.580652 8.274454 0 16.514115-3.403516 22.442128-10.07445 11.011798-12.387122 9.896394-31.357172-2.492774-42.367947L169.687704 548.100196 939.880137 548.100196c16.57449 0 30.011524-13.613042 30.011524-30.187533S956.454628 487.72513 939.880137 487.72513z" p-id="2136" fill="#FF9800"></path></svg></button>
<div id="artTitle"><h1></h1></div>
<div id="artTitle"></div>
<div id="authorName"></div>
<div id="content"></div>
</div>
......@@ -242,49 +242,57 @@
$("#articleView").addClass("hide");
}
function getArticle (articleID){
console.log('articleID', articleID);
$.ajax({
url:'/index/',
type:'get',
data:{
"articleID":articleID,
url: '/operator/',
type: 'get',
data: {
"articleID": articleID,
"actiontype": '5',
'csrfmiddlewaretoken': '{{ csrf_token }}'
},
success:function(response){
{#var result = $.parseJSON(response);#}
// {#var result = $.parseJSON(response);#}
var result=response;
$("#articleList").addClass("hide");
$("#articleView").removeClass("hide");
var converter = new showdown.Converter();
var content = converter.makeHtml(result["content"]);
$("#content").empty();
$("#content").append(content);
$("#artTitle").empty();
$("#artTitle").append(result["title"]);
$("#authorName").empty();
$("#authorName").append(result["authorname"]);
if(result["success"]){
$("#articleList").addClass("hide");
$("#articleView").removeClass("hide");
var converter = new showdown.Converter();
var content = converter.makeHtml(result["content"]);
console.log('content', articleID, content, result["content"]);
$("#content").empty();
$("#content").append(content);
$("#artTitle").empty();
$("#artTitle").append(result["title"]);
$("#authorName").empty();
$("#authorName").append(result["authorname"]);
} else {
alert(result["warning"])
}
},
error:function (xhr) {
console.error('something went wrong...');
console.error('something went wrong...',xhr);
}
})
}
function deleteArt(thisbtn){
var title = thisbtn.parentElement.firstElementChild.innerHTML;
var title = thisbtn.parentElement.parentElement.firstElementChild.firstElementChild.innerHTML;
var res = confirm('确定要删除"'+title+'"吗?该操作不可撤销。')
if(!res) return;
$.ajax({
url:'/index/',
type:'post',
data:{
"title":title,
url: '/operator/',
type: 'post',
data: {
"title": title,
"actiontype": '6',
'csrfmiddlewaretoken': '{{ csrf_token }}'
},
success:function(response){
if (response["warning"]=="文章删除成功"){
if (response["warning"]=="删除成功"){
thisbtn.parentElement.parentElement.remove();
}else{
alert(response["warning"]);
}
alert(response["warning"]);
},
error:function (xhr) {
console.error('something went wrong...');
......
......@@ -328,6 +328,10 @@ def operator(request):
if request.is_ajax():
# 判断操作类型
actiontype = request.POST.get('actiontype')
if request.method == 'POST':
actiontype = request.POST.get('actiontype')
elif request.method == 'GET':
actiontype = request.GET.get('actiontype')
# 创建用户
if actiontype == '0':
username = request.POST.get('username')
......@@ -415,4 +419,36 @@ def operator(request):
except ObjectDoesNotExist:
message["warning"] = "2"
return HttpResponse(json.dumps(message), content_type='application/json')
# 查看内部文章
if actiontype == '5':
try:
articleID = request.GET.get('articleID')
arti = Articles.objects.get(articleID=articleID)
message["success"] = True
message["content"]=arti.content
message["title"]=arti.title
authorID = arti.authorID
author = User.objects.get(userID=authorID)
message["authorname"]=author.name
return HttpResponse(json.dumps(message), content_type='application/json')
except ObjectDoesNotExist:
message["success"] = False
message["warning"] = "文章不存在"
return HttpResponse(json.dumps(message), content_type='application/json')
# 删除内部文章
if actiontype == '6':
title = request.POST.get('title')
try:
delrestlt = Articles.objects.filter(title=title).delete()
print("delrestlt", title, delrestlt)
message["warning"] = "删除成功"
return HttpResponse(json.dumps(message), content_type='application/json')
except:
message["warning"]="删除出错"
return HttpResponse(json.dumps(message), content_type='application/json')
return render('admin.html', locals())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment