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
f12f4069
Commit
f12f4069
authored
May 18, 2020
by
Xu Zhou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
内部文章在index中不可见;修改文章列表样式未table。
parent
f56f7c45
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
47 additions
and
6 deletions
+47
-6
models.cpython-37.pyc
hunter/__pycache__/models.cpython-37.pyc
+0
-0
models.py
hunter/models.py
+1
-1
admin.css
hunter/static/hunter/admin.css
+1
-1
admin.html
hunter/templates/hunter/admin.html
+0
-0
index.html
hunter/templates/hunter/index.html
+28
-4
urls.py
hunter/urls.py
+1
-0
views.py
hunter/views.py
+16
-0
No files found.
hunter/__pycache__/models.cpython-37.pyc
deleted
100644 → 0
View file @
f56f7c45
File deleted
hunter/models.py
View file @
f12f4069
...
...
@@ -55,7 +55,7 @@ class PubToUser(models.Model):
username
=
models
.
CharField
(
max_length
=
50
)
userID
=
models
.
IntegerField
(
default
=
0
)
#publish=0 用户私有,publish=1 组内可见,publish=2 公开
class
Articles
(
models
.
Model
):
articleID
=
models
.
BigIntegerField
(
primary_key
=
True
)
authorID
=
models
.
IntegerField
()
...
...
hunter/static/hunter/admin.css
View file @
f12f4069
...
...
@@ -293,7 +293,7 @@ svg{
}
.list_private_art
{
width
:
100%
;
height
:
5
0px
;
height
:
10
0px
;
line-height
:
50px
;
}
.user_score_List
>
.list_head
>
ul
>
li
,
.list_score_body
>
li
{
...
...
hunter/templates/hunter/admin.html
View file @
f12f4069
This diff is collapsed.
Click to expand it.
hunter/templates/hunter/index.html
View file @
f12f4069
...
...
@@ -339,13 +339,15 @@
$
(
'#former_member'
).
css
(
'left'
,
'-100%'
);
}
/*
function logout(){
let storage = window.localStorage;
storage['username']="";
storage
[
'password'
]
=
""
;
storage['password']="";
$('#top_bar').empty();
$('#top_bar').append("<ul><li onclick='login()'>登录</li></ul>");
}
*/
function
click_bar
(
index
){
let
a_list
=
document
.
getElementsByClassName
(
"main_bar"
);
$
(
a_list
[
pre_clicked
]).
removeClass
(
'active'
);
...
...
@@ -407,14 +409,36 @@
$
(
'#error_log'
).
append
(
message
);
}
function
keylogin
(){
if
(
event
.
keyCode
===
13
)
{
login
();
}
if
(
event
.
keyCode
===
13
)
{
login
();
}
}
function
logout
(){
$
(
'#top_bar'
).
empty
();
$
(
'#top_bar'
).
append
(
'<button onclick="show_log()">登录</button>'
);
let
storage
=
window
.
localStorage
;
user_id
=
storage
[
"userID"
];
$
.
ajax
({
url
:
'/logout/'
,
type
:
'post'
,
dataType
:
'json'
,
data
:{
"user_id"
:
user_id
,
},
success
:
function
(
response
){
console
.
log
(
response
);
if
(
response
[
'message'
]
===
"success"
){
console
.
log
(
"logout OK, ret: "
);
console
.
log
(
response
);
location
.
reload
();
}
else
{
console
.
log
(
response
);
}
},
error
:
function
(
xhr
)
{
console
.
error
(
'something went wrong when logout...'
);
}
})
storage
.
clear
();
console
.
log
(
storage
);
}
...
...
hunter/urls.py
View file @
f12f4069
...
...
@@ -20,6 +20,7 @@ urlpatterns = [
path
(
'add/article/url/'
,
views
.
add_url_article
,
name
=
'add_url_article'
),
path
(
'login/'
,
views
.
login
,
name
=
'login'
),
path
(
'logout/'
,
views
.
logout
,
name
=
'logout'
),
path
(
'delete/publication/'
,
views
.
delete_publication
,
name
=
'delete_publication'
),
path
(
'change/publication/status/'
,
views
.
change_pub_status
,
name
=
'change_pub_status'
),
path
(
'delete/cve/'
,
views
.
delete_cve
,
name
=
'delete_cve'
),
...
...
hunter/views.py
View file @
f12f4069
...
...
@@ -21,6 +21,8 @@ from django.views.decorators.csrf import ensure_csrf_cookie
def
index
(
request
):
user_id
=
request
.
session
.
get
(
'user_id'
)
print
(
"request index.html, user_id = "
,
user_id
)
user_list
=
User
.
objects
.
filter
(
isCurrent
=
1
)
.
all
()
user_type_list
=
{
"Academic STAFF"
:
[],
"Phd"
:
[],
"Master"
:
[],
"Engineer STAFF"
:
[]}
for
u
in
user_list
:
...
...
@@ -77,6 +79,13 @@ def index(request):
article_list
=
Articles
.
objects
.
order_by
(
'-editDateTime'
)
article_year_list
=
{}
for
art
in
article_list
:
#print(art.title, art.publish)
pub_type
=
int
(
art
.
publish
)
if
pub_type
==
0
:
#article is private
continue
elif
pub_type
==
1
and
user_id
==
None
:
#internal article
continue
year
=
str
(
art
.
editDateTime
)[
0
:
4
]
art
.
editDateTime
=
str
(
art
.
editDateTime
)[
5
:
10
]
u
=
User
.
objects
.
filter
(
userID
=
art
.
authorID
)
.
values
(
'name'
)
...
...
@@ -134,11 +143,18 @@ def login(request):
else
:
if
db_info
.
pwd
==
password
:
user_id
=
db_info
.
userID
request
.
session
[
'user_id'
]
=
user_id
response
=
JsonResponse
({
"message"
:
"success"
,
"userid"
:
user_id
})
else
:
response
=
JsonResponse
({
"message"
:
"密码错误"
})
return
response
@csrf_exempt
def
logout
(
request
):
print
(
'call logout'
)
request
.
session
[
'user_id'
]
=
None
response
=
JsonResponse
({
"message"
:
"success"
})
return
response
def
user
(
request
,
user_id
):
usr
=
get_object_or_404
(
User
,
pk
=
user_id
)
...
...
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