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
1bcfb3c0
Commit
1bcfb3c0
authored
Apr 24, 2020
by
liuyingying
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
天呐好饿
parent
65e908e1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
272 additions
and
21 deletions
+272
-21
style.css
Hunter_ht/hunter/static/hunter/style.css
+33
-4
index.html
Hunter_ht/hunter/templates/hunter/index.html
+1
-0
user.html
Hunter_ht/hunter/templates/hunter/user.html
+177
-16
urls.py
Hunter_ht/hunter/urls.py
+4
-1
views.py
Hunter_ht/hunter/views.py
+57
-0
No files found.
Hunter_ht/hunter/static/hunter/style.css
View file @
1bcfb3c0
...
...
@@ -82,7 +82,7 @@ button{
color
:
white
;
}
#login_btn
,
#submit_btn
{
background
:
#
ffffff
;
background
:
#
6e829e
;
font-size
:
16px
;
}
...
...
@@ -443,7 +443,7 @@ footer .copyright a:hover{
width
:
100%
;
height
:
50px
;
}
#edit_content
span
{
#edit_content
label
{
width
:
25%
;
height
:
45px
;
float
:
left
;
...
...
@@ -451,7 +451,7 @@ footer .copyright a:hover{
line-height
:
45px
;
text-align
:
right
;
}
#edit_content
input
{
#edit_content
>
form
>
div
>
input
{
width
:
65%
;
height
:
45px
;
font-size
:
16px
;
...
...
@@ -532,7 +532,6 @@ section > .smaller_box{
.smaller_wrap
button
{
border
:
none
;
outline
:
none
;
background-image
:
url("./images/logo.ico")
;
}
.smaller_wrap
blockquote
{
padding
:
10px
0
;
...
...
@@ -540,3 +539,32 @@ section > .smaller_box{
.smaller_wrap
blockquote
>
p
{
font-size
:
18px
;
}
.add_one
{
width
:
100%
;
height
:
40px
;
}
.add_one
button
{
width
:
30px
;
height
:
30px
;
float
:
right
;
border-radius
:
15px
;
}
.add_one
button
svg
{
margin
:
5px
;
}
.add_one
button
:hover
svg
{
width
:
30px
;
height
:
30px
;
border-radius
:
15px
;
margin
:
0
;
}
.myfile
{
float
:
right
;
}
.myfile
>
input
{
background
:
transparent
!important
;
border
:
none
!important
;
outline
:
none
!important
;
display
:
block
;
}
\ No newline at end of file
Hunter_ht/hunter/templates/hunter/index.html
View file @
1bcfb3c0
...
...
@@ -66,6 +66,7 @@
</ul>
{% endfor %}
{% endif %}
</div>
{% endfor %}
</div>
...
...
Hunter_ht/hunter/templates/hunter/user.html
View file @
1bcfb3c0
...
...
@@ -7,6 +7,7 @@
<link
rel=
"icon"
href=
"{% static 'hunter/images/logo.ico' %}"
type=
"text/icon"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static 'hunter/style.css' %}"
>
<script
src=
"{% static 'hunter/jquery-1.9.1.min.js' %}"
></script>
<script
src=
"{% static 'hunter/jquery.form.js' %}"
></script>
</head>
<body>
<div
id=
"edit_div"
class=
""
>
...
...
@@ -14,15 +15,39 @@
<div
id=
"edit_title"
>
修改
</div>
<div
id=
"edit_content"
>
<div>
<span>
名字:
</span
>
<input
type=
"text"
>
<label
for=
"title"
>
标题:
</label
>
<input
type=
"text"
placeholder=
""
name=
"title"
required
>
</div>
<div>
<span>
名字:
</span
>
<input
type=
"text"
>
<label
for=
"authors"
>
作者:
</label
>
<input
type=
"text"
placeholder=
"Example:Tom,Bob,Jane"
name=
"authors"
required
>
</div>
<div>
<label>
<select
class=
"col-sm-2 control-select"
name=
"type"
>
<option
value=
"0"
>
请选择
</option>
<option
value=
"会议"
>
会议
</option>
<option
value=
"期刊"
>
期刊
</option>
<option
value=
"专利"
>
专利
</option>
<option
value=
"软著"
>
软著
</option>
</select>
</label>
<input
type=
"text"
class=
"form-control"
name=
"journalname"
placeholder=
"名称"
required
>
</div>
<div>
<label
for=
"date"
>
日期
</label>
<input
type=
"datetime-local"
name=
"date"
>
{#
<div
class=
"input-group date form_date "
data-date=
""
data-date-format=
"yyyy-MM-dd"
data-link-field=
"dtp_input2"
data-link-format=
"yyyymmdd"
>
#}
{#
<input
size=
"16"
type=
"text"
name=
"date"
value=
""
readonly=
""
required
>
#}
{#
<span
class=
"input-group-addon"
><span
class=
"glyphicon glyphicon-calendar"
></span></span>
#}
{#
</div>
#}
{#
<input
type=
"hidden"
id=
"dtp_input2"
value=
""
/><br/>
#}
</div>
<div
class=
"myfile"
>
<input
type=
"file"
name=
"myfile"
required
>
</div>
<div
id=
"error_log"
></div>
</div>
<div
id=
"error_log"
>
{{ error_message }}
</div>
<div
id=
"btn_edit"
>
{#
<button
id=
"cancel_btn"
onclick=
"hide_edit()"
>
#}
{# 取消#}
...
...
@@ -62,7 +87,10 @@
{% for publication in publications %}
<ul>
<li
class=
"big_text li_long"
><a
href=
"{% static 'hunter/publications/' %}{{ publication.link }}"
target=
"_blank"
>
{{ publication.title }}
</a></li>
<li
class=
"right"
><a
onclick=
"editPublication({{ publication.pubID }})"
>
修改
</a></li>
<li
class=
"right"
><button
onclick=
"delePub({{ 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"
><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>
</button></li>
<li
class=
"middle_text right"
>
{{ publication.date }}
</li>
<li
class=
"right"
>
{{ publication.journalname }}
</li>
<li
class=
"right"
>
{{ publication.publishType }}
</li>
...
...
@@ -71,6 +99,12 @@
{% endfor %}
{% endif %}
<div
class=
"add_one"
>
<button
onclick=
"addPub()"
>
<svg
t=
"1587711895133"
class=
"icon"
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
p-id=
"3772"
width=
"20"
height=
"20"
><path
d=
"M512 1024C229.2224 1024 0 794.7776 0 512 0 229.2224 229.2224 0 512 0 794.7776 0 1024 229.2224 1024 512 1024 794.7776 794.7776 1024 512 1024ZM716.8 486.4 537.6 486.4 537.6 307.2 486.4 307.2 486.4 486.4 307.2 486.4 307.2 537.6 486.4 537.6 486.4 716.8 537.6 716.8 537.6 537.6 716.8 537.6 716.8 486.4Z"
p-id=
"3773"
fill=
"#6e829e"
></path></svg>
</button>
</div>
{% endfor %}
</div>
</section>
...
...
@@ -89,7 +123,10 @@
{% for cve in cves %}
<ul>
<li
class=
"cve_big_text"
><a
href=
"{{ cve.url }}"
target=
"_blank"
>
{{ cve.identifier }}
</a></li>
<li
class=
"li_right"
><button
onclick=
"editCVE('{{ cve.identifier }}')"
>
修改
</button></li>
<li
class=
"li_right"
><button
onclick=
"deleCVE({{ 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=
"li_right"
><button
onclick=
"editCVE('{{ cve.identifier }}')"
><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>
</button></li>
<li
class=
"li_right"
>
{{ cve.datetime }}
</li>
<li
class=
"li_right"
>
{{ cve.software }}
</li>
<li
class=
"li_right"
>
{{ cve.bugType }}
</li>
...
...
@@ -98,6 +135,11 @@
{% endfor %}
{% endif %}
<div
class=
"add_one"
>
<button
onclick=
"addCVE()"
>
<svg
t=
"1587711895133"
class=
"icon"
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
p-id=
"3772"
width=
"20"
height=
"20"
><path
d=
"M512 1024C229.2224 1024 0 794.7776 0 512 0 229.2224 229.2224 0 512 0 794.7776 0 1024 229.2224 1024 512 1024 794.7776 794.7776 1024 512 1024ZM716.8 486.4 537.6 486.4 537.6 307.2 486.4 307.2 486.4 486.4 307.2 486.4 307.2 537.6 486.4 537.6 486.4 716.8 537.6 716.8 537.6 537.6 716.8 537.6 716.8 486.4Z"
p-id=
"3773"
fill=
"#6e829e"
></path></svg>
</button>
</div>
{% endfor %}
</div>
...
...
@@ -120,12 +162,20 @@
<a
href=
"{% url 'hunter:article' art.articleID %}"
target=
"_blank"
>
{{ art.title }}
</a>
</li>
<li>
{{ art.author }}
</li>
<li
class=
"right"
><a
onclick=
"editArt({{ art.articleID }})"
>
修改
</a></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"
><button
onclick=
"editArt({{ art.articleID }})"
><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>
</button></li>
<li
class=
"middle_text right"
>
{{ art.editDateTime }}
</li>
<li
class=
"small_text right"
>
{{ art.authorID }}
</li>
</ul>
{% endfor %}
{% endif %}
<div
class=
"add_one"
>
<button
onclick=
"addArt()"
>
<svg
t=
"1587711895133"
class=
"icon"
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
p-id=
"3772"
width=
"20"
height=
"20"
><path
d=
"M512 1024C229.2224 1024 0 794.7776 0 512 0 229.2224 229.2224 0 512 0 794.7776 0 1024 229.2224 1024 512 1024 794.7776 794.7776 1024 512 1024ZM716.8 486.4 537.6 486.4 537.6 307.2 486.4 307.2 486.4 486.4 307.2 486.4 307.2 537.6 486.4 537.6 486.4 716.8 537.6 716.8 537.6 537.6 716.8 537.6 716.8 486.4Z"
p-id=
"3773"
fill=
"#6e829e"
></path></svg>
</button>
</div>
{% endfor %}
</div>
...
...
@@ -137,14 +187,124 @@
<strong><a
href=
"//www.hunter-ht.cn/"
target=
"_blank"
>
hunter-ht.cn
</a></strong>
All Rights Reserved. 备案号:
<a
target=
"_blank"
rel=
"nofollow"
href=
"http://www.beian.miit.gov.cn"
>
湘ICP备18008562号
</a>
</div>
</footer>
<script>
<script
type=
"text/javascript"
src=
"{% static 'hunter/bootstrap.min.js' %}"
></script>
<script
type=
"text/javascript"
src=
"{% static 'hunter/bootstrap-datetimepicker.js' %}"
charset=
"UTF-8"
></script>
<script
type=
"text/javascript"
src=
"{% static 'hunter//bootstrap-datetimepicker.zh-CN.js' %}"
charset=
"UTF-8"
></script>
<script
type=
"text/javascript"
>
$
(
'.form_datetime'
).
datetimepicker
({
//language: 'fr',
weekStart
:
1
,
todayBtn
:
1
,
autoclose
:
1
,
todayHighlight
:
1
,
startView
:
2
,
forceParse
:
0
,
showMeridian
:
1
});
$
(
'.form_date'
).
datetimepicker
({
language
:
'zh-CN'
,
weekStart
:
1
,
todayBtn
:
1
,
autoclose
:
1
,
todayHighlight
:
1
,
startView
:
2
,
minView
:
2
,
forceParse
:
0
});
$
(
'.form_time'
).
datetimepicker
({
language
:
'fr'
,
weekStart
:
1
,
todayBtn
:
1
,
autoclose
:
1
,
todayHighlight
:
1
,
startView
:
1
,
minView
:
0
,
maxView
:
1
,
forceParse
:
0
});
</script>
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
(){
});
var
submit_what
=
''
;
function
addPub
(){
create_html
();
$
(
'#edit_title'
).
empty
();
$
(
'#edit_title'
).
append
(
'添加出版'
);
submit_what
=
'publication'
;
}
function
submit_pub
(){
var
title
=
$
(
'input[name="title"]'
).
val
();
var
authors
=
$
(
'input[name="authors"]'
).
val
();
var
journalname
=
$
(
'input[name="journalname"]'
).
val
();
var
date
=
$
(
'input[name="date"]'
).
val
();
var
type
=
$
(
'select[name="type"] option:selected'
).
val
();
var
formatData
=
new
FormData
();
formatData
.
append
(
"myfile"
,
$
(
"input[name='myfile']"
)[
0
].
files
[
0
]);
formatData
.
append
(
"title"
,
title
);
formatData
.
append
(
"authors"
,
authors
);
formatData
.
append
(
"journalname"
,
journalname
);
formatData
.
append
(
"date"
,
date
);
formatData
.
append
(
"type"
,
type
);
$
.
ajax
({
url
:
'/add/publication/'
,
type
:
'post'
,
data
:
formatData
,
contentType
:
false
,
processData
:
false
,
success
:
function
(
response
){
console
.
log
(
response
);
},
error
:
function
(
xhr
){
console
.
error
(
'something wrong'
);
}
});
}
function
addArt
(){
}
function
addCVE
(){
$
(
'#edit_title'
).
empty
();
$
(
'#edit_title'
).
append
(
'添加CVE'
);
create_html
()
}
function
delePub
(
pubid
){
let
is_sure
=
alert
(
"确定要删除吗?"
);
if
(
is_sure
){
$
.
ajax
({
url
:
'/delete/publication/'
,
type
:
'post'
,
data
:{
"pub_id"
:
pubid
,
},
success
:
function
(
response
)
{
alert
(
response
[
'message'
]);
if
(
response
[
'message'
]){
this
.
parentElement
.
parentElement
.
style
.
display
=
'none'
;
this
.
parentElement
.
parentElement
.
innerHTML
=
''
;
}
},
error
:
function
(
xhr
)
{
console
.
error
(
'something went wrong...'
);
login_fail
(
"something went wrong..."
);
}
})
}
}
function
deleArt
(
artid
){
}
function
deleCVE
(
cveid
)
{
}
function
editPublication
(
pubid
){
console
.
log
(
pubid
);
create_html
();
}
function
editArt
(
artid
){
console
.
log
(
artid
);
create_html
();
}
function
editCVE
(
cveid
){
console
.
log
(
cveid
);
...
...
@@ -154,7 +314,6 @@
$
(
'#edit_div'
).
addClass
(
'show_edit'
)
}
function
create_html
(){
$
(
'#edit_content'
).
empty
();
show_edit
();
let
html
=
' <button id="cancel_btn" onclick="hide_edit()">
\
n'
+
...
...
@@ -173,11 +332,13 @@
' </div>'
;
$
(
'#edit_content'
).
append
(
input_html
);
}
function
create_publication_html
(){
$
(
'#edit_content'
).
empty
();
let
html
=
""
;
}
function
submit_edit
(){
if
(
'success'
){
hide_edit
();
}
else
{
login_fail
(
"fail"
)
if
(
submit_what
===
'publication'
)
{
submit_pub
();
}
}
function
login_fail
(
message
){
...
...
Hunter_ht/hunter/urls.py
View file @
1bcfb3c0
...
...
@@ -9,5 +9,7 @@ urlpatterns = [
# path('<int:pk>/article/', views.ArticleDetail.as_view(), name='article'),
path
(
'user/<int:user_id>/'
,
views
.
user
,
name
=
'user'
),
path
(
'article/<int:article_id>/'
,
views
.
article
,
name
=
'article'
),
path
(
'login/'
,
views
.
login
,
name
=
'login'
)
path
(
'login/'
,
views
.
login
,
name
=
'login'
),
path
(
'delete/publication/<int:pub_id>'
,
views
.
delete_publication
,
name
=
'delete_publication'
),
path
(
'add/publication/'
,
views
.
add_publication
,
name
=
'add_publication'
),
]
\ No newline at end of file
Hunter_ht/hunter/views.py
View file @
1bcfb3c0
...
...
@@ -4,6 +4,10 @@ from .models import *
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.http
import
JsonResponse
from
django.views.decorators.csrf
import
csrf_exempt
import
os
from
django.db.utils
import
ProgrammingError
from
django.shortcuts
import
redirect
from
django.core.exceptions
import
ValidationError
import
json
from
django.views
import
generic
from
django.db.models.aggregates
import
Count
...
...
@@ -144,3 +148,56 @@ def user(request, user_id):
def
article
(
request
,
article_id
):
art
=
get_object_or_404
(
Articles
,
pk
=
article_id
)
return
render
(
request
,
'hunter/article.html'
,
{
'article'
:
art
})
def
delete_publication
(
request
,
pub_id
):
print
(
pub_id
)
try
:
PubToUser
.
objects
.
filter
(
pubID
=
pub_id
)
.
delete
()
Publications
.
objects
.
filter
(
pubID
=
pub_id
)
.
delete
()
except
ObjectDoesNotExist
as
e
:
response
=
JsonResponse
({
"message"
:
0
})
return
response
response
=
JsonResponse
({
"message"
:
1
})
return
response
@csrf_exempt
def
add_publication
(
request
):
title
=
request
.
POST
[
'title'
]
print
(
title
)
authors
=
request
.
POST
[
'authors'
]
myfile
=
request
.
FILES
[
'myfile'
]
str
=
','
.
decode
(
'utf-8'
)
authors
=
authors
.
replace
(
str
,
','
)
journalname
=
request
.
POST
.
get
(
'journalname'
)
date
=
request
.
POST
.
get
(
'date'
)
index
=
request
.
POST
.
get
(
'index'
)
if
Publications
.
objects
.
last
()
is
None
:
pubID
=
1
else
:
pubID
=
Publications
.
objects
.
last
()
.
pubID
+
1
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
=
os
.
path
.
join
(
'static'
,
'publications'
,
myfile
.
name
)
try
:
Publications
.
objects
.
create
(
pubID
=
pubID
,
title
=
title
,
link
=
link
,
messages
=
'kidding'
,
authors
=
authors
,
journalname
=
journalname
,
date
=
date
,
indexType
=
index
)
except
ProgrammingError
as
e
:
return
render
(
request
,
'user.html'
,
{
'message'
:
'Publications表错误:'
+
e
})
authorArr
=
authors
.
split
(
','
)
for
author
in
authorArr
:
try
:
PubToUser
.
objects
.
create
(
pubID
=
pubID
,
username
=
author
)
return
redirect
(
request
,
'index.html'
,
{
'uploadMessage'
:
'文件上传成功'
})
except
ProgrammingError
as
e
:
return
render
(
request
,
'index.html'
,
{
'uploadError'
:
'PubToUser数据表错误:'
+
e
})
# message["warning"] = "上传成功"
# return HttpResponse(json.dumps(message), content_type='application/json')
return
redirect
(
request
,
'index.html'
)
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