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
29e835c9
Commit
29e835c9
authored
May 18, 2020
by
Xu Zhou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加了用户article的发布和未发布的按钮功能。
parent
f12f4069
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
9 deletions
+73
-9
admin.css
hunter/static/hunter/admin.css
+5
-1
admin.html
hunter/templates/hunter/admin.html
+2
-2
user.html
hunter/templates/hunter/user.html
+49
-6
urls.py
hunter/urls.py
+2
-0
views.py
hunter/views.py
+15
-0
No files found.
hunter/static/hunter/admin.css
View file @
29e835c9
...
...
@@ -12,7 +12,11 @@ button{
border
:
none
;
}
a
{
color
:
#ff9800
;
color
:
#ff9800
;
text-decoration
:
none
;
}
a
:hover
{
text-decoration
:
none
;
}
ul
{
list-style
:
none
;
...
...
hunter/templates/hunter/admin.html
View file @
29e835c9
...
...
@@ -5,8 +5,8 @@
<meta
charset=
"UTF-8"
>
<title>
管理员面板
</title>
<link
rel=
"icon"
href=
"{% static 'hunter/images/logo.ico' %}"
type=
"text/icon"
>
<link
rel=
"stylesheet"
href=
"{% static 'hunter/bootstrap.css' %}"
>
<link
rel=
"stylesheet"
href=
"{% static 'hunter/admin.css' %}"
>
<link
rel=
"stylesheet"
href=
"{% static 'hunter/bootstrap.css' %}"
>
<script
src=
"{% static 'hunter/jquery-1.9.1.min.js' %}"
></script>
<script
src=
"{% static 'hunter/jquery.form.js' %}"
></script>
<script
type=
"text/javascript"
src=
"{% static 'hunter/md/showdown.js' %}"
></script>
...
...
@@ -15,7 +15,7 @@
</head>
<body>
<nav
class=
"navbar"
>
<div
id=
"hunterLogo"
>
Hunter
</div>
<div
id=
"hunterLogo"
>
<span><a
href=
"/"
>
HUNTER
</a></span>
</div>
<a
class=
"logout"
onclick=
"logout()"
>
EXIT
</a>
<div
id=
"adminname"
></div>
</nav>
...
...
hunter/templates/hunter/user.html
View file @
29e835c9
...
...
@@ -152,7 +152,7 @@
<blockquote><p>
{{ year }}
</p></blockquote>
{% if arts %}
{% for art in arts %}
<ul
id=
"articleid{{ art.articleID }}"
>
<ul
id=
"articleid{{ art.articleID }}"
>
<li
class=
"big_text"
>
{% if art.url %}
<a
href=
"{{ art.url }}"
target=
"_blank"
>
{{ art.title }}
</a>
...
...
@@ -161,12 +161,22 @@
{% endif %}
</li>
<li>
{{ art.author }}
</li>
<li
class=
"right"
><button
onclick=
"deleArt({{ art.articleID }})"
><svg
t=
"1587713476030"
class=
"icon"
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
p-id=
"4730"
width=
"20"
height=
"20"
><path
d=
"M864 128H544v-16a32 32 0 0 0-64 0v16H160a32 32 0 0 0 0 64h704a32 32 0 0 0 0-64z m-64 128a32 32 0 0 0-32 32v592H256V288a32 32 0 0 0-64 0v624a32 32 0 0 0 32 32h576a32 32 0 0 0 32-32V288a32 32 0 0 0-32-32zM416 784V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z"
fill=
"#b34340"
p-id=
"4731"
></path></svg>
</button></li>
<li
class=
"right"
><a
href=
"{% url 'hunter:edit_art' art.articleID %}"
target=
"_blank"
class=
"edit_img"
style=
"display:block"
></a></li>
<li
class=
"middle_text right"
>
{{ art.editDateTime }}
</li>
<li
class=
"small_text right"
><a
target=
"_blank"
download=
"{{ art.attachment }}"
href=
"{% static 'hunter/articles/' %}{{ art.attachment }}"
>
{{ art.attachment }}
</a></li>
</ul>
<li
class=
"right"
><a
href=
"{% url 'hunter:edit_art' art.articleID %}"
target=
"_blank"
class=
"edit_img"
style=
"display:block"
></a></li>
<button
class=
"change_open right"
onclick=
"change_art_open(this, {{ art.articleID }})"
>
{% if art.publish == '2' %}
取消发布
{% else %}
发布
{% endif %}
</button>
<li
class=
"middle_text right"
>
{{ art.editDateTime }}
</li>
</ul>
{% endfor %}
{% endif %}
{% endfor %}
...
...
@@ -759,7 +769,7 @@
$
(
'#edit_div'
).
addClass
(
'show_edit'
);
}
function
change_open
(
thisBtn
,
pubID
){
function
change_open
(
thisBtn
,
pubID
){
if
(
thisBtn
.
innerText
===
'取消发布'
){
isOpen
=
'0'
;
console
.
log
(
isOpen
);
...
...
@@ -792,6 +802,39 @@
}
})
}
function
change_art_open
(
thisBtn
,
art_id
){
if
(
thisBtn
.
innerText
===
'取消发布'
){
publish
=
'0'
;
console
.
log
(
isOpen
);
}
else
{
publish
=
'2'
}
$
.
ajax
({
url
:
'/update_article/'
,
type
:
'post'
,
data
:{
'art_id'
:
art_id
,
'publish'
:
publish
,
},
success
:
function
(
response
){
if
(
response
[
'message'
]){
console
.
log
(
thisBtn
);
if
(
publish
===
'2'
){
$
(
thisBtn
).
empty
();
$
(
thisBtn
).
append
(
'取消发布'
);
}
else
{
$
(
thisBtn
).
empty
();
$
(
thisBtn
).
append
(
'发布'
);
}
}
else
{
console
.
log
(
response
[
'error'
]);
}
},
error
:
function
(
xhr
){
console
.
log
(
"something went wrong..."
);
}
})
}
</script>
</body>
...
...
hunter/urls.py
View file @
29e835c9
...
...
@@ -34,4 +34,5 @@ urlpatterns = [
path
(
'ht/admin/'
,
views
.
admin
,
name
=
'admin'
),
path
(
'operator/'
,
views
.
operator
,
name
=
'operator'
),
path
(
'add_user/'
,
views
.
add_user
,
name
=
'add_user'
),
path
(
'update_article/'
,
views
.
update_article
,
name
=
'update_article'
),
]
\ No newline at end of file
hunter/views.py
View file @
29e835c9
...
...
@@ -742,6 +742,7 @@ def check_admin_privilage(user_id):
# 管理员
def
admin
(
request
):
admin_id
=
request
.
session
.
get
(
'admin_id'
)
admin_id
=
4
if
admin_id
==
None
:
if
request
.
method
!=
'POST'
:
return
HttpResponseNotFound
(
'<h1>Page not found</h1>'
)
...
...
@@ -889,3 +890,17 @@ def add_user(request):
else
:
return
render
(
request
,
'admin.html'
,{
'message'
:
'添加失败'
})
return
render
(
request
,
'admin.html'
)
@csrf_exempt
def
update_article
(
request
):
art_id
=
request
.
POST
[
'art_id'
]
print
(
'update_article, art_id = '
,
art_id
)
art
=
Articles
.
objects
.
get
(
articleID
=
int
(
art_id
))
print
(
art
)
art_pub
=
request
.
POST
.
get
(
'publish'
)
if
art_pub
!=
None
:
art
.
publish
=
art_pub
art
.
save
()
return
JsonResponse
({
"message"
:
"success"
})
return
JsonResponse
({
"message"
:
"failed"
})
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