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
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
11 deletions
+19
-11
admin.css
hunter/static/hunter/admin.css
+5
-0
admin.html
hunter/templates/hunter/admin.html
+0
-0
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
This diff is collapsed.
Click to expand it.
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