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
8463fee0
Commit
8463fee0
authored
May 07, 2020
by
liuyingying
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
publication
parent
d893c9e8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
26 deletions
+46
-26
user.html
Hunter_ht/hunter/templates/hunter/user.html
+45
-25
views.py
Hunter_ht/hunter/views.py
+1
-1
No files found.
Hunter_ht/hunter/templates/hunter/user.html
View file @
8463fee0
...
...
@@ -253,37 +253,57 @@
let
journalname
=
$
(
'input[name="journalname"]'
).
val
();
let
date
=
$
(
'#date_input'
).
val
();
let
type
=
$
(
'select[name="type"] option:selected'
).
val
();
let
myfile
=
$
(
"input[name='myfile']"
)[
0
].
files
[
0
];
let
storage
=
window
.
localStorage
;
let
username
=
storage
.
username
;
let
isPublish
=
$
(
'#isPublish option:selected'
).
val
();
let
myfile
=
$
(
"input[name='myfile']"
)[
0
].
files
[
0
];
let
formatData
=
new
FormData
();
formatData
.
append
(
"myfile"
,
myfile
);
formatData
.
append
(
"title"
,
title
);
formatData
.
append
(
"authors"
,
authors
);
formatData
.
append
(
"journalname"
,
journalname
);
formatData
.
append
(
"date"
,
date
);
formatData
.
append
(
"type"
,
type
);
formatData
.
append
(
"username"
,
username
);
formatData
.
append
(
"isPublish"
,
isPublish
);
console
.
log
(
$
(
"input[name='myfile']"
)[
0
].
files
.
length
);
console
.
log
(
$
(
'select[name="type"] option:selected'
).
val
());
if
(
$
(
"input[name='myfile']"
)[
0
].
files
.
length
<=
0
){
$
(
'#error_log'
).
empty
();
$
(
'#error_log'
).
append
(
'请上传文件'
);
return
;
}
else
if
(
type
==
0
){
$
(
'#error_log'
).
empty
();
$
(
'#error_log'
).
append
(
'请选择发表物类型'
);
return
;
}
else
if
(
!
title
||!
authors
||!
journalname
||!
date
){
$
(
'#error_log'
).
empty
();
$
(
'#error_log'
).
append
(
'请填写所有信息'
);
return
;
}
else
{
$
(
'#error_log'
).
empty
();
formatData
.
append
(
"myfile"
,
myfile
);
formatData
.
append
(
"title"
,
title
);
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 'hunter:add_publication' %}"
,
type
:
'post'
,
data
:
formatData
,
contentType
:
false
,
processData
:
false
,
success
:
function
(
response
){
if
(
response
[
'message'
]){
hide_edit
();
window
.
location
.
reload
();
}
else
{
$
(
'#error_log'
).
append
(
response
[
'error'
]);
$
.
ajax
({
url
:
"{% url 'hunter:add_publication' %}"
,
type
:
'post'
,
data
:
formatData
,
contentType
:
false
,
processData
:
false
,
success
:
function
(
response
){
if
(
response
[
'message'
]){
hide_edit
();
window
.
location
.
reload
();
}
else
{
$
(
'#error_log'
).
append
(
response
[
'error'
]);
}
},
error
:
function
(
xhr
){
}
}
,
error
:
function
(
xhr
){
}
});
}
);
}
}
function
editPublication
(
pubID
){
show_edit
();
...
...
Hunter_ht/hunter/views.py
View file @
8463fee0
...
...
@@ -461,7 +461,7 @@ def add_publication(request):
Publications
.
objects
.
create
(
pubID
=
pubID
,
title
=
title
,
link
=
link
,
messages
=
'kidding'
,
authors
=
authors
,
journalname
=
journalname
,
uploadByUser
=
uploadby
,
date
=
date
,
publishType
=
publishType
,
isOpen
=
isPublish
)
except
ProgrammingError
as
e
:
return
JsonResponse
({
"message"
:
0
})
authorArr
=
authors
.
split
(
','
)
.
strip
()
authorArr
=
authors
.
split
(
','
)
print
(
authorArr
)
for
author
in
authorArr
:
users_list
=
User
.
objects
.
all
()
.
values
(
'name'
)
...
...
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