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
7eb522de
Commit
7eb522de
authored
May 07, 2020
by
liuyingying
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改publication
parent
20708780
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
162 additions
and
22 deletions
+162
-22
style.css
Hunter_ht/hunter/static/hunter/style.css
+1
-1
user.html
Hunter_ht/hunter/templates/hunter/user.html
+70
-21
urls.py
Hunter_ht/hunter/urls.py
+1
-0
views.py
Hunter_ht/hunter/views.py
+90
-0
No files found.
Hunter_ht/hunter/static/hunter/style.css
View file @
7eb522de
...
@@ -515,7 +515,7 @@ ul:after{
...
@@ -515,7 +515,7 @@ ul:after{
.right
{
.right
{
float
:
right
!important
;
float
:
right
!important
;
height
:
20px
!important
;
height
:
20px
!important
;
margin
:
0
5px
10px
;
margin
:
0
5px
;
z-index
:
-999
;
z-index
:
-999
;
font-size
:
14px
;
font-size
:
14px
;
}
}
...
...
Hunter_ht/hunter/templates/hunter/user.html
View file @
7eb522de
...
@@ -76,8 +76,7 @@
...
@@ -76,8 +76,7 @@
<ul
id=
"pubid{{ publication.pubID }}"
>
<ul
id=
"pubid{{ publication.pubID }}"
>
<li
class=
"big_text li_long"
><a
href=
"{% static 'hunter/publications/' %}{{ publication.link }}"
target=
"_blank"
>
{{ publication.title }}
</a></li>
<li
class=
"big_text li_long"
><a
href=
"{% static 'hunter/publications/' %}{{ publication.link }}"
target=
"_blank"
>
{{ publication.title }}
</a></li>
<li
class=
"right"
><button
class=
"dele_img"
onclick=
"delePub({{ publication.pubID }})"
></button></li>
<li
class=
"right"
><button
class=
"dele_img"
onclick=
"delePub({{ publication.pubID }})"
></button></li>
{#
<li
class=
"right"
><button
onclick=
"editPublication({{ publication.pubID }})"
><svg
t=
"1587711451871"
class=
"icon"
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
p-id=
"2741"
width=
"20"
height=
"20"
><path
d=
"M863.079412 351.09129a29.2569 29.2569 0 0 1 58.5138 0v555.881108a117.027602 117.027602 0 0 1-117.027601 117.027602H219.427602a117.027602 117.027602 0 0 1-117.027602-117.027602V146.292987a117.027602 117.027602 0 0 1 117.027602-117.027602h380.339706a29.2569 29.2569 0 0 1 0 58.513801H219.427602a58.513801 58.513801 0 0 0-58.513801 58.513801v760.679411a58.513801 58.513801 0 0 0 58.513801 58.513801h585.138009a58.513801 58.513801 0 0 0 58.513801-58.513801V351.09129zM855.414104 10.306913a29.2569 29.2569 0 1 1 44.587516 37.916943l-248.683654 292.569005a29.2569 29.2569 0 1 1-44.587516-37.916943l248.683654-292.569005zM307.198303 526.632692h263.312104a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z m0 175.541403h409.596606a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z"
p-id=
"2742"
fill=
"#6e829e"
></path></svg>
#}
<li
class=
"right"
><button
class=
"edit_img"
onclick=
"editPublication({{ publication.pubID }})"
></button></li>
{#
</button></li>
#}
<li
class=
"right"
>
<li
class=
"right"
>
<button
class=
"change_open"
onclick=
"change_open(this,{{ publication.pubID }})"
>
<button
class=
"change_open"
onclick=
"change_open(this,{{ publication.pubID }})"
>
{% if publication.isOpen == '1' %}
{% if publication.isOpen == '1' %}
...
@@ -162,7 +161,6 @@
...
@@ -162,7 +161,6 @@
{% else %}
{% else %}
<a
href=
"{% url 'hunter:article' art.articleID %}"
target=
"_blank"
>
{{ art.title }}
</a>
<a
href=
"{% url 'hunter:article' art.articleID %}"
target=
"_blank"
>
{{ art.title }}
</a>
{% endif %}
{% endif %}
</li>
</li>
<li>
{{ art.author }}
</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>
<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>
...
@@ -248,10 +246,7 @@
...
@@ -248,10 +246,7 @@
$
(
'#edit_title'
).
empty
();
$
(
'#edit_title'
).
empty
();
$
(
'#edit_title'
).
append
(
'添加出版'
);
$
(
'#edit_title'
).
append
(
'添加出版'
);
}
}
function
editPublication
(
pubid
){
console
.
log
(
pubid
);
create_html
();
}
function
submit_publication
(){
function
submit_publication
(){
let
title
=
$
(
'input[name="title"]'
).
val
();
let
title
=
$
(
'input[name="title"]'
).
val
();
let
authors
=
$
(
'input[name="authors"]'
).
val
();
let
authors
=
$
(
'input[name="authors"]'
).
val
();
...
@@ -273,7 +268,7 @@
...
@@ -273,7 +268,7 @@
formatData
.
append
(
"isPublish"
,
isPublish
);
formatData
.
append
(
"isPublish"
,
isPublish
);
$
.
ajax
({
$
.
ajax
({
url
:
"{% url 'hunter:add_publication' %}
"
,
url
:
"{% url 'hunter:add_publication' %}
"
,
type
:
'post'
,
type
:
'post'
,
data
:
formatData
,
data
:
formatData
,
contentType
:
false
,
contentType
:
false
,
...
@@ -281,23 +276,77 @@
...
@@ -281,23 +276,77 @@
success
:
function
(
response
){
success
:
function
(
response
){
if
(
response
[
'message'
]){
if
(
response
[
'message'
]){
hide_edit
();
hide_edit
();
let
isFind
=
0
;
let
year
=
date
.
substr
(
0
,
4
);
let
date_month
=
date
.
substr
(
5
,
10
);
$
(
'#publish blockquote'
).
each
(
function
(){
if
(
this
.
children
[
0
].
innerText
===
year
){
isFind
=
1
;
var
$h1
=
' <ul><li class="big_text li_long"><a href="/static/hunter/publications/'
+
myfile
.
name
+
'" target="_blank">'
+
title
+
'</a></li><li class="right"><button class="dele_img" onclick="delePub('
+
response
[
'pubID'
]
+
')"></button></li><li class="middle_text right">'
+
date_month
+
'</li><li class="right">'
+
journalname
+
'</li><li class="right">'
+
type
+
'</li><li class="small_text">'
+
authors
+
'</li></ul>'
;
$
(
this
).
after
(
$h1
);
window
.
location
.
reload
();
window
.
location
.
reload
();
}
else
{
$
(
'#error_log'
).
append
(
response
[
'error'
]);
}
},
error
:
function
(
xhr
){
}
}
});
});
if
(
!
isFind
){
var
$h2
=
'<blockquote><p>'
+
year
+
'</p></blockquote><ul><li class="big_text li_long"><a href="/static/hunter/publications/'
+
myfile
.
name
+
'" target="_blank">'
+
title
+
'</a></li> <li class="right"><button class="dele_img" onclick="delePub('
+
response
[
'pubID'
]
+
')"></button></li><li class="middle_text right">'
+
date_month
+
'</li><li class="right">'
+
journalname
+
'</li><li class="right">'
+
type
+
'</li><li class="small_text">'
+
authors
+
'</li></ul>'
;
$
(
'#publish .wrap'
)[
0
].
prepend
(
$h2
);
window
.
location
.
reload
();
}
}
function
editPublication
(
pubID
){
show_edit
();
let
html
=
' <button id="cancel_btn" onclick="hide_edit()">
\
n'
+
' 取消
\
n'
+
' </button>
\
n'
+
' <button id="submit_btn" onclick="submit_edit_publication(
\'
/edit/publication/
\'
,'
+
pubID
+
')">
\
n'
+
' 提交
\
n'
+
' </button>
\
n'
;
$
(
'#btn_edit'
).
empty
();
$
(
'#btn_edit'
).
append
(
html
);
create_publication_html
();
let
node
=
document
.
getElementById
(
'pubid'
+
pubID
);
$
(
'input[name="title"]'
).
val
(
node
.
children
[
0
].
children
[
0
].
innerText
);
$
(
'input[name="authors"]'
).
val
(
node
.
children
[
7
].
innerText
);
$
(
'input[name="date"]'
).
val
(
node
.
parentElement
.
children
[
0
].
children
[
0
].
innerText
+
'-'
+
node
.
children
[
4
].
innerText
);
$
(
'input[name="journalname"]'
).
val
(
node
.
children
[
5
].
innerText
);
$
(
'select[name="type"]'
).
val
(
node
.
children
[
6
].
innerText
);
if
(
node
.
children
[
3
].
innerText
===
'发布'
){
$
(
'#isPublish'
).
val
(
'0'
);
}
else
{
$
(
'#isPublish'
).
val
(
'1'
);
}
}
function
submit_edit_publication
(
url_edit
,
pubID
){
let
title
=
$
(
'input[name="title"]'
).
val
();
let
authors
=
$
(
'input[name="authors"]'
).
val
();
let
journalname
=
$
(
'input[name="journalname"]'
).
val
();
let
date
=
$
(
'#date_input'
).
val
();
let
type
=
$
(
'select[name="type"] option:selected'
).
val
();
let
storage
=
window
.
localStorage
;
let
username
=
storage
.
username
;
let
isPublish
=
$
(
'#isPublish option:selected'
).
val
();
let
formatData
=
new
FormData
();
let
files
=
$
(
'input[name="myfile"]'
)[
0
].
files
;
if
(
files
.
length
>
0
){
let
myfile
=
files
[
0
];
formatData
.
append
(
"myfile"
,
myfile
);
formatData
.
append
(
"isHaveFile"
,
"1"
);
}
else
{
formatData
.
append
(
"isHaveFile"
,
"0"
);
}
formatData
.
append
(
"title"
,
title
);
formatData
.
append
(
"pubID"
,
pubID
);
formatData
.
append
(
"authors"
,
authors
);
formatData
.
append
(
"journalname"
,
journalname
);
formatData
.
append
(
"date"
,
date
);
formatData
.
append
(
"type"
,
type
);
formatData
.
append
(
"username"
,
username
);
formatData
.
append
(
"isPublish"
,
isPublish
);
$
.
ajax
({
url
:
url_edit
,
type
:
'post'
,
data
:
formatData
,
contentType
:
false
,
processData
:
false
,
success
:
function
(
response
){
if
(
response
[
'message'
]){
hide_edit
();
window
.
location
.
reload
();
}
else
{
}
else
{
$
(
'#error_log'
).
append
(
response
[
'error'
]);
$
(
'#error_log'
).
append
(
response
[
'error'
]);
}
}
...
...
Hunter_ht/hunter/urls.py
View file @
7eb522de
...
@@ -25,6 +25,7 @@ urlpatterns = [
...
@@ -25,6 +25,7 @@ urlpatterns = [
path
(
'delete/cve/'
,
views
.
delete_cve
,
name
=
'delete_cve'
),
path
(
'delete/cve/'
,
views
.
delete_cve
,
name
=
'delete_cve'
),
path
(
'delete/article/'
,
views
.
delete_article
,
name
=
'delete_article'
),
path
(
'delete/article/'
,
views
.
delete_article
,
name
=
'delete_article'
),
path
(
'add/publication/'
,
views
.
add_publication
,
name
=
'add_publication'
),
path
(
'add/publication/'
,
views
.
add_publication
,
name
=
'add_publication'
),
path
(
'edit/publication/'
,
views
.
edit_publication
,
name
=
'edit_publication'
),
path
(
'add/cve/'
,
views
.
add_cve
,
name
=
'add_cve'
),
path
(
'add/cve/'
,
views
.
add_cve
,
name
=
'add_cve'
),
path
(
'edit/cve/'
,
views
.
edit_cve
,
name
=
'edit_cve'
),
path
(
'edit/cve/'
,
views
.
edit_cve
,
name
=
'edit_cve'
),
path
(
'add/article/'
,
views
.
add_article
,
name
=
'add_article'
),
path
(
'add/article/'
,
views
.
add_article
,
name
=
'add_article'
),
...
...
Hunter_ht/hunter/views.py
View file @
7eb522de
...
@@ -424,6 +424,7 @@ def change_pub_status(request):
...
@@ -424,6 +424,7 @@ def change_pub_status(request):
except
ObjectDoesNotExist
as
e
:
except
ObjectDoesNotExist
as
e
:
return
JsonResponse
({
'message'
:
0
,
'error'
:
e
})
return
JsonResponse
({
'message'
:
0
,
'error'
:
e
})
@csrf_exempt
@csrf_exempt
def
add_publication
(
request
):
def
add_publication
(
request
):
title
=
request
.
POST
[
'title'
]
title
=
request
.
POST
[
'title'
]
...
@@ -506,6 +507,95 @@ def add_publication(request):
...
@@ -506,6 +507,95 @@ def add_publication(request):
@csrf_exempt
@csrf_exempt
def
edit_publication
(
request
):
pubID
=
request
.
POST
[
'pubID'
]
title
=
request
.
POST
[
'title'
]
authors
=
request
.
POST
[
'authors'
]
uploadby
=
request
.
POST
[
'username'
]
publishType
=
request
.
POST
[
'type'
]
isHaveFile
=
request
.
POST
[
'isHaveFile'
]
s
=
','
authors
=
authors
.
replace
(
s
,
','
)
journalname
=
request
.
POST
.
get
(
'journalname'
)
date
=
request
.
POST
.
get
(
'date'
)
index
=
request
.
POST
.
get
(
'index'
)
isPublish
=
request
.
POST
[
'isPublish'
]
origin_author
=
Publications
.
objects
.
get
(
pubID
=
pubID
)
.
authors
if
Publications
.
objects
.
filter
(
pubID
=
pubID
)
.
count
()
<=
0
:
return
JsonResponse
({
'message'
:
0
,
"error"
:
"该出版不存在"
})
if
isHaveFile
==
'1'
:
myfile
=
request
.
FILES
[
'myfile'
]
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
destination
=
os
.
path
.
join
(
BASE_DIR
,
'hunter'
,
'static'
,
'hunter/publications'
,
myfile
.
name
)
if
os
.
path
.
exists
(
destination
):
os
.
remove
(
destination
)
with
open
(
destination
,
'wb+'
)
as
dest
:
for
chunk
in
myfile
.
chunks
():
dest
.
write
(
chunk
)
dest
.
close
()
link
=
myfile
.
name
try
:
Publications
.
objects
.
filter
(
pubID
=
pubID
)
.
update
(
title
=
title
,
link
=
link
,
authors
=
authors
,
journalname
=
journalname
,
uploadByUser
=
uploadby
,
date
=
date
,
publishType
=
publishType
,
isOpen
=
isPublish
)
response
=
JsonResponse
({
"message"
:
1
,
'pubID'
:
pubID
})
except
ProgrammingError
as
e
:
return
JsonResponse
({
"message"
:
0
})
else
:
try
:
Publications
.
objects
.
filter
(
pubID
=
pubID
)
.
update
(
title
=
title
,
authors
=
authors
,
journalname
=
journalname
,
uploadByUser
=
uploadby
,
date
=
date
,
publishType
=
publishType
,
isOpen
=
isPublish
)
response
=
JsonResponse
({
"message"
:
1
,
'pubID'
:
pubID
})
except
ProgrammingError
as
e
:
return
JsonResponse
({
"message"
:
0
})
authorArr
=
authors
.
split
(
','
)
originArr
=
origin_author
.
split
(
','
)
if
authorArr
!=
originArr
:
print
(
authorArr
)
print
(
originArr
)
PubToUser
.
objects
.
filter
(
pubID
=
pubID
)
.
delete
()
for
author
in
authorArr
:
users_list
=
User
.
objects
.
all
()
.
values
(
'name'
)
user_list
=
[]
for
user
in
users_list
:
user_list
.
append
(
user
[
'name'
])
author
=
str
(
author
)
.
lower
()
.
strip
()
if
' '
in
author
:
author_version1
=
author
.
replace
(
' '
,
''
)
author_version2
=
author
.
split
(
' '
)[
1
]
+
str
(
author
)
.
lower
()
.
strip
()
.
split
(
' '
)[
0
]
else
:
author_version1
=
author
.
replace
(
' '
,
''
)
author_version2
=
author
print
(
user_list
)
print
(
author_version1
)
print
(
author_version2
)
if
author_version1
in
user_list
:
userID
=
User
.
objects
.
filter
(
name
=
author_version1
)
.
values
(
'userID'
)[
0
][
'userID'
]
try
:
PubToUser
.
objects
.
create
(
pubID
=
pubID
,
username
=
author
,
userID
=
userID
)
response
=
JsonResponse
({
"message"
:
1
,
'pubID'
:
pubID
})
except
ProgrammingError
as
e
:
return
JsonResponse
({
"message"
:
0
})
else
:
if
author_version2
in
user_list
:
userID
=
User
.
objects
.
filter
(
name
=
author_version2
)
.
values
(
'userID'
)[
0
][
'userID'
]
try
:
PubToUser
.
objects
.
create
(
pubID
=
pubID
,
username
=
author
,
userID
=
userID
)
response
=
JsonResponse
({
"message"
:
1
,
'pubID'
:
pubID
})
except
ProgrammingError
as
e
:
return
JsonResponse
({
"message"
:
0
})
else
:
try
:
PubToUser
.
objects
.
create
(
pubID
=
pubID
,
username
=
author
)
response
=
JsonResponse
({
"message"
:
1
,
'pubID'
:
pubID
})
except
ProgrammingError
as
e
:
return
JsonResponse
({
"message"
:
0
})
return
response
@csrf_exempt
def
add_cve
(
request
):
def
add_cve
(
request
):
owner
=
request
.
POST
[
'owner'
]
owner
=
request
.
POST
[
'owner'
]
bugType
=
request
.
POST
[
'bugType'
]
bugType
=
request
.
POST
[
'bugType'
]
...
...
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