make a json format for view of journal_p
This commit is contained in:
parent
048e8dd7ab
commit
4ce10d2fd9
|
@ -43,13 +43,30 @@ class DesktopPublicationsController< ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def getjournals
|
def getjournals
|
||||||
@journals = current_user.journals
|
publications = WritingJournal.where(:create_user_id => current_user.id)
|
||||||
|
|
||||||
|
sort_publications= Hash.new
|
||||||
data = Array.new
|
data = Array.new
|
||||||
@journals.each do |journal|
|
|
||||||
@papers = journal.papers.all
|
publications.each do |publication|
|
||||||
data << {"title" => journal.title, "papers" => @papers}
|
if sort_publications[publication.journal_title].nil?
|
||||||
|
sort_publications[publication.journal_title] = Array.new
|
||||||
end
|
end
|
||||||
render :json=>data.to_json
|
sort_publications[publication.journal_title] <<
|
||||||
|
{ title: publication.paper_title,
|
||||||
|
keywords: publication.keywords,
|
||||||
|
abstract: publication.abstract,
|
||||||
|
level: publication.journal_paper_type_id,
|
||||||
|
coauthors: publication.authors,
|
||||||
|
year: publication.year
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
sort_publications.each do |journal, papers|
|
||||||
|
data << {title: journal, papers: papers}
|
||||||
|
end
|
||||||
|
|
||||||
|
render json: JSON.pretty_generate(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_journal
|
def delete_journal
|
||||||
|
|
Reference in New Issue