Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hunter-ht.cn
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘莹莹
hunter-ht.cn
Commits
f085c875
Commit
f085c875
authored
Jun 09, 2020
by
Duanbj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改管理员内部文章相关逻辑,加入获取和删除内部文章的代码,修改相关css
parent
17c52334
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
34 deletions
+82
-34
admin.css
hunter/static/admin.css
+11
-7
admin.html
hunter/templates/admin.html
+35
-27
view_page.py
hunter/views/view_page.py
+36
-0
No files found.
hunter/static/admin.css
View file @
f085c875
...
...
@@ -192,19 +192,21 @@ svg{
}
.title
{
width
:
60%
;
font-size
:
20
px
;
font-size
:
18
px
;
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
{
...
...
hunter/templates/admin.html
View file @
f085c875
...
...
@@ -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...'
);
...
...
hunter/views/view_page.py
View file @
f085c875
...
...
@@ -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
())
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment