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
f56f7c45
Commit
f56f7c45
authored
May 16, 2020
by
Xu Zhou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
管理员页面使用session保持认证。
parent
b451c0a0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
28 deletions
+44
-28
admin.css
hunter/static/hunter/admin.css
+5
-0
admin.html
hunter/templates/hunter/admin.html
+25
-17
views.py
hunter/views.py
+14
-11
No files found.
hunter/static/hunter/admin.css
View file @
f56f7c45
...
...
@@ -291,6 +291,11 @@ svg{
height
:
45px
;
line-height
:
45px
;
}
.list_private_art
{
width
:
100%
;
height
:
50px
;
line-height
:
50px
;
}
.user_score_List
>
.list_head
>
ul
>
li
,
.list_score_body
>
li
{
width
:
25%
;
float
:
left
;
...
...
hunter/templates/hunter/admin.html
View file @
f56f7c45
...
...
@@ -55,7 +55,7 @@
</div>
</div>
</div>
<table
class=
"table tableList"
>
<table
class=
"table tableList"
>
<thead>
<tr>
<th>
用户名
</th>
...
...
@@ -80,7 +80,7 @@
</div>
<!--Publication列表-->
<div
id=
"paperadmin"
class=
"userlist"
>
<div
id=
"paperadmin"
class=
"userlist"
style=
"border:1px solid #000;"
>
<table
class=
"table tableList"
>
<thead>
...
...
@@ -107,20 +107,24 @@
</table>
</div>
<div
id=
"privateArtadmin"
class=
"userlist"
>
<ul
id=
"articleList"
class=
"node-list"
>
{% for article in articles %}
<li>
<div
class=
"article-content"
>
<button
class=
"title"
onclick=
getArticle({{
article
.
articleID
}})
>
{{ article.title }}
</button>
<span>
{{ article.publish }}
</span>
<span>
{{ article.editDateTime }}
</span>
<a
class=
"editbtn"
title=
"编辑"
target=
"_blank"
href=
"/write/?title={{ article.title }}"
>
<?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=
"1538270903865"
class=
"icon"
style=
""
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
p-id=
"3673"
xmlns:xlink=
"http://www.w3.org/1999/xlink"
width=
"200"
height=
"200"
><defs><style
type=
"text/css"
></style></defs><path
d=
"M607.232 896a32 32 0 1 1 0 64H192a96 96 0 0 1-96-96V160a96 96 0 0 1 96-96h544a96 96 0 0 1 96 96 32 32 0 0 1-64 0 32 32 0 0 0-32-32H192a32 32 0 0 0-32 32v704a32 32 0 0 0 32 32h415.232zM832 585.76v146.656c0 42.656-64 42.656-64 0v-146.656c0-42.688 64-42.688 64 0z"
p-id=
"3674"
fill=
"#ea6f5a"
></path><path
d=
"M288 320a32 32 0 1 1 0-64h224a32 32 0 0 1 0 64H288zM288 480a32 32 0 0 1 0-64h128a32 32 0 0 1 0 64H288zM639.424 926.592a32 32 0 1 1-64 0L576 800a96 96 0 0 1 96-96l127.744 1.152a32 32 0 1 1 0 64L672 768a32 32 0 0 0-32 32l-0.576 126.592z"
p-id=
"3675"
fill=
"#ea6f5a"
></path><path
d=
"M637.92 947.648a32 32 0 1 1-44.32-46.208l180.384-172.992a32 32 0 1 1 44.288 46.176l-180.352 173.024zM880.896 334.528a31.424 31.424 0 0 0 3.328-44.416l-0.416-0.512a32 32 0 0 0-44.896-3.36L408.32 652.288l-15.2 51.84 58.336-4.544 429.44-365.056z m51.616-86.4a95.36 95.36 0 0 1-9.408 134.496l-438.08 372.448a32 32 0 0 1-18.24 7.52l-114.944 8.896a32 32 0 0 1-33.184-40.928l30.944-105.472a32 32 0 0 1 9.984-15.36L797.408 237.504a96 96 0 0 1 134.688 10.112l0.416 0.512z"
p-id=
"3676"
fill=
"#ea6f5a"
></path></svg></a>
<button
class=
"delebtn"
title=
"删除"
onclick=
"deleteArt(this)"
>
<?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=
"1539054739914"
class=
"icon"
style=
""
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
p-id=
"2718"
xmlns:xlink=
"http://www.w3.org/1999/xlink"
width=
"200"
height=
"200"
><defs><style
type=
"text/css"
></style></defs><path
d=
"M861.012317 164.091494C765.809507 68.885661 639.229448 16.455901 504.590713 16.455901S243.372927 68.885661 148.170117 164.091494C52.965291 259.293296 0.534525 385.874363 0.534525 520.51209c0 134.639743 52.430767 261.217786 147.635592 356.422612 95.20281 95.20281 221.782869 147.633577 356.420596 147.633577s261.217786-52.430767 356.420596-147.633577c95.204825-95.204825 147.635592-221.783877 147.635592-356.422612C1008.646902 385.874363 956.217143 259.293296 861.012317 164.091494zM791.219829 810.54584c-4.394084 4.393077-10.152441 6.590623-15.910797 6.590623-5.759364 0-11.518728-2.197546-15.911805-6.590623L504.590713 555.740334 249.785207 810.54584c-4.394084 4.393077-10.152441 6.590623-15.911805 6.590623-5.758356 0-11.516713-2.197546-15.910797-6.590623-8.788169-8.788169-8.788169-23.036448 0-31.824617L472.767104 523.916725 219.336953 270.485566c-8.788169-8.788169-8.788169-23.036448 0-31.824617 8.788169-8.785146 23.035441-8.785146 31.823609 0l253.431158 253.431158 253.431158-253.431158c8.788169-8.785146 23.035441-8.785146 31.823609 0 8.788169 8.788169 8.788169 23.036448 0 31.824617L536.41533 523.916725l254.804499 254.805506C800.007998 787.509392 800.007998 801.757672 791.219829 810.54584z"
p-id=
"2719"
fill=
"#ea6f5a"
></path></svg></button>
</div>
</li>
{% endfor %}
</ul>
<!--内部文章管理-->
<div
id=
"privateArtadmin"
class=
"userlist"
style=
"border:1px solid #000;"
>
<div
class=
"list_private_art"
>
<ul
id=
"articleList"
class=
"node-list"
>
{% for article in articles %}
<li>
<div
class=
"article-content"
>
<button
class=
"title"
onclick=
getArticle({{
article
.
articleID
}})
>
{{ article.title }}
</button>
<span>
{{ article.publish }}
</span>
<span>
{{ article.editDateTime }}
</span>
<a
class=
"editbtn"
title=
"编辑"
target=
"_blank"
href=
"/write/?title={{ article.title }}"
>
<?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=
"1538270903865"
class=
"icon"
style=
""
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
p-id=
"3673"
xmlns:xlink=
"http://www.w3.org/1999/xlink"
width=
"200"
height=
"200"
><defs><style
type=
"text/css"
></style></defs><path
d=
"M607.232 896a32 32 0 1 1 0 64H192a96 96 0 0 1-96-96V160a96 96 0 0 1 96-96h544a96 96 0 0 1 96 96 32 32 0 0 1-64 0 32 32 0 0 0-32-32H192a32 32 0 0 0-32 32v704a32 32 0 0 0 32 32h415.232zM832 585.76v146.656c0 42.656-64 42.656-64 0v-146.656c0-42.688 64-42.688 64 0z"
p-id=
"3674"
fill=
"#ea6f5a"
></path><path
d=
"M288 320a32 32 0 1 1 0-64h224a32 32 0 0 1 0 64H288zM288 480a32 32 0 0 1 0-64h128a32 32 0 0 1 0 64H288zM639.424 926.592a32 32 0 1 1-64 0L576 800a96 96 0 0 1 96-96l127.744 1.152a32 32 0 1 1 0 64L672 768a32 32 0 0 0-32 32l-0.576 126.592z"
p-id=
"3675"
fill=
"#ea6f5a"
></path><path
d=
"M637.92 947.648a32 32 0 1 1-44.32-46.208l180.384-172.992a32 32 0 1 1 44.288 46.176l-180.352 173.024zM880.896 334.528a31.424 31.424 0 0 0 3.328-44.416l-0.416-0.512a32 32 0 0 0-44.896-3.36L408.32 652.288l-15.2 51.84 58.336-4.544 429.44-365.056z m51.616-86.4a95.36 95.36 0 0 1-9.408 134.496l-438.08 372.448a32 32 0 0 1-18.24 7.52l-114.944 8.896a32 32 0 0 1-33.184-40.928l30.944-105.472a32 32 0 0 1 9.984-15.36L797.408 237.504a96 96 0 0 1 134.688 10.112l0.416 0.512z"
p-id=
"3676"
fill=
"#ea6f5a"
></path></svg></a>
<button
class=
"delebtn"
title=
"删除"
onclick=
"deleteArt(this)"
>
<?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=
"1539054739914"
class=
"icon"
style=
""
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
p-id=
"2718"
xmlns:xlink=
"http://www.w3.org/1999/xlink"
width=
"200"
height=
"200"
><defs><style
type=
"text/css"
></style></defs><path
d=
"M861.012317 164.091494C765.809507 68.885661 639.229448 16.455901 504.590713 16.455901S243.372927 68.885661 148.170117 164.091494C52.965291 259.293296 0.534525 385.874363 0.534525 520.51209c0 134.639743 52.430767 261.217786 147.635592 356.422612 95.20281 95.20281 221.782869 147.633577 356.420596 147.633577s261.217786-52.430767 356.420596-147.633577c95.204825-95.204825 147.635592-221.783877 147.635592-356.422612C1008.646902 385.874363 956.217143 259.293296 861.012317 164.091494zM791.219829 810.54584c-4.394084 4.393077-10.152441 6.590623-15.910797 6.590623-5.759364 0-11.518728-2.197546-15.911805-6.590623L504.590713 555.740334 249.785207 810.54584c-4.394084 4.393077-10.152441 6.590623-15.911805 6.590623-5.758356 0-11.516713-2.197546-15.910797-6.590623-8.788169-8.788169-8.788169-23.036448 0-31.824617L472.767104 523.916725 219.336953 270.485566c-8.788169-8.788169-8.788169-23.036448 0-31.824617 8.788169-8.785146 23.035441-8.785146 31.823609 0l253.431158 253.431158 253.431158-253.431158c8.788169-8.785146 23.035441-8.785146 31.823609 0 8.788169 8.788169 8.788169 23.036448 0 31.824617L536.41533 523.916725l254.804499 254.805506C800.007998 787.509392 800.007998 801.757672 791.219829 810.54584z"
p-id=
"2719"
fill=
"#ea6f5a"
></path></svg></button>
</div>
</li>
{% endfor %}
</ul>
</div>
<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>
...
...
@@ -128,7 +132,11 @@
<div
id=
"content"
></div>
</div>
</div>
<div
id=
"scoreRecords"
class=
"userlist"
>
<!--学习积分-->
<div
id=
"scoreRecords"
class=
"userlist"
style=
"border:1px solid #000;"
>
<div
style=
"width:100%;height:50px;"
>
<span
id=
"user_score_List"
style=
"color:#ff9800"
onclick=
"changeScoreList(this)"
>
积分列表
</span>
<span
id=
"score_history_List"
onclick=
"changeScoreList(this)"
>
详细记录
</span>
...
...
hunter/views.py
View file @
f56f7c45
from
django.shortcuts
import
render
,
get_object_or_404
from
django.http
import
HttpResponse
,
Http404
from
django.http
import
HttpResponse
,
Http404
,
HttpResponseNotFound
from
.models
import
*
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.http
import
JsonResponse
...
...
@@ -725,16 +725,19 @@ def check_admin_privilage(user_id):
# 管理员
def
admin
(
request
):
if
request
.
method
!=
'POST'
:
return
HttpResponse
(
status
=
404
)
user_id
=
request
.
POST
.
get
(
'user_id'
,
''
)
if
user_id
==
''
:
return
HttpResponse
(
status
=
404
)
print
(
"admin user_id = "
,
user_id
)
if
not
check_admin_privilage
(
user_id
):
return
HttpResponse
(
status
=
404
)
admin_id
=
request
.
session
.
get
(
'admin_id'
)
if
admin_id
==
None
:
if
request
.
method
!=
'POST'
:
return
HttpResponseNotFound
(
'<h1>Page not found</h1>'
)
user_id
=
request
.
POST
.
get
(
'user_id'
,
''
)
if
user_id
==
''
:
return
HttpResponse
(
status
=
404
)
print
(
"admin user_id = "
,
user_id
)
if
not
check_admin_privilage
(
user_id
):
return
HttpResponse
(
status
=
404
)
request
.
session
[
'admin_id'
]
=
user_id
if
User
.
objects
.
last
():
if
User
.
objects
.
last
()
.
userID
>
0
:
...
...
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