diff --git a/app/controllers/admin/journal_papers_controller.rb b/app/controllers/admin/journal_papers_controller.rb index 7166af5..9e552f0 100644 --- a/app/controllers/admin/journal_papers_controller.rb +++ b/app/controllers/admin/journal_papers_controller.rb @@ -23,14 +23,50 @@ class Admin::JournalPapersController < OrbitMemberController end def create - @member = MemberProfile.find(journal_paper_params['member_profile_id']) rescue nil - @journal_paper = JournalPaper.new(journal_paper_params) - @journal_paper.save - if params[:desktop] == "true" - render json: {"data" => get_paper_list}.to_json - else + + if !journal_paper_params['member_profile_id'].blank? + + @member = MemberProfile.find(journal_paper_params['member_profile_id']) rescue nil + @journal_paper = JournalPaper.new(journal_paper_params) + @journal_paper.save + + if params[:desktop] == "true" + render json: {"data" => get_paper_list}.to_json + else + redirect_to params['referer_url'] + end + + elsif !params[:author_members].blank? + + params[:author_members].each do |author_member| + + journal_paper_params['member_profile_id'] = author_member + @journal_paper = JournalPaper.new(journal_paper_params) + @journal_paper.save + + if params[:desktop] == "true" + render json: {"data" => get_paper_list}.to_json + end + + end + redirect_to params['referer_url'] + + else + + journal_paper_params['member_profile_id'] = User.find(current_user.id).member_profile_id + + @journal_paper = JournalPaper.new(journal_paper_params) + @journal_paper.save + + if params[:desktop] == "true" + render json: {"data" => get_paper_list}.to_json + end + + redirect_to params['referer_url'] + end + end def edit diff --git a/app/views/admin/journal_papers/_form.html.erb b/app/views/admin/journal_papers/_form.html.erb index 082e7bb..a1bab4b 100644 --- a/app/views/admin/journal_papers/_form.html.erb +++ b/app/views/admin/journal_papers/_form.html.erb @@ -117,14 +117,27 @@