Commit 8463fee0 by liuyingying

publication

parent d893c9e8
......@@ -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();
......
......@@ -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')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment