move journal code to persional_journal modulaar
This commit is contained in:
1 parent
284bf34fec
commit
758cab5ecd
27 files changed
-4
No files matched your search
@@ -1,63 +0,0 @@
|
||||
class Desktop::CoAuthorRelationsController < ApplicationController
|
||||
def index
|
||||
@co_author_relations = CoAuthorRelation.all
|
||||
new
|
||||
|
||||
respond_to do |format|
|
||||
format.html {render layout: false }
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@co_author_relation = CoAuthorRelation.find(params[:id])
|
||||
respond_to do |format|
|
||||
format.html { render :layout => false}
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@co_author_relation = CoAuthorRelation.new
|
||||
end
|
||||
|
||||
def create
|
||||
@co_author_relation = CoAuthorRelation.new(params[:co_author_relation])
|
||||
@co_author_relations = CoAuthorRelation.all
|
||||
|
||||
if @co_author_relation.save
|
||||
newv = render_to_string partial: "show_form", object: @co_author_relations
|
||||
render json: {success: true, msg: "New Relation successfully saved!", newvalue: newv}.to_json
|
||||
else
|
||||
error_msg = @co_author_relation.errors.full_messages.join("<br />")
|
||||
render json: {success: false, msg: error_msg}.to_json
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@co_author_relation = CoAuthorRelation.find(params[:id])
|
||||
if @co_author_relation.update_attributes(params[:co_author_relation])
|
||||
@co_author_relations = CoAuthorRelation.all
|
||||
newv = render_to_string partial: "show_form", object: @co_author_relations
|
||||
render json: {success: true, msg: "New Relation successfully updated!", newvalue: newv}.to_json
|
||||
else
|
||||
error_msg = @co_author.errors.full_messages.join("<br />")
|
||||
render json: {success: false, msg: error_msg}.to_json
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@co_author_relation = CoAuthorRelation.find(params[:id])
|
||||
@co_author_relation.destroy
|
||||
reset_co_author_relation
|
||||
|
||||
render :json => {success: true, msg: "deleted successfully!"}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def reset_co_author_relation
|
||||
co_author = CoAuthor.where(co_author_relations_id: @co_author_relation.id)
|
||||
co_author.map do |c|
|
||||
c.update_attributes(co_author_relations_id: nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,59 +0,0 @@
|
||||
class Desktop::CoAuthorsController < ApplicationController
|
||||
def index
|
||||
nils, not_nils = CoAuthor.where(name_id: current_user.id)\
|
||||
.asc(:co_author).partition{|p| p.email.nil?}
|
||||
@co_authors = not_nils + nils
|
||||
@co_author_relations = CoAuthorRelation.all
|
||||
|
||||
respond_to do |format|
|
||||
format.html { render :layout => false}
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@co_author = CoAuthor.new
|
||||
@co_author_relations = CoAuthorRelation.all
|
||||
|
||||
respond_to do |format|
|
||||
format.html { render :layout => false}
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@co_author = CoAuthor.find(params[:id])
|
||||
@co_author_relations = CoAuthorRelation.all
|
||||
respond_to do |format|
|
||||
format.html { render :layout => false}
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@co_author = CoAuthor.new(params[:co_author])
|
||||
@co_author.name_id= current_user.id
|
||||
|
||||
if @co_author.save
|
||||
render json: {success:true, msg: t('create.sucess.co_author')}.to_json
|
||||
else
|
||||
error_msg = @co_author.errors.full_messages.join("<br />")
|
||||
render json: {success: false, msg: error_msg}.to_json
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@co_author = CoAuthor.find(params[:id])
|
||||
|
||||
if @co_author.update_attributes(params[:co_author])
|
||||
render json: {success:true, msg: t('update.sucess.co_author')}.to_json
|
||||
else
|
||||
error_msg = @co_author.errors.full_messages.join("<br />")
|
||||
render json: {success: false, msg: error_msg}.to_json
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@co_author = CoAuthor.find(params[:id])
|
||||
@co_author.destroy
|
||||
|
||||
render :json => {success: true, msg: "Co-author deleted successfully!"}
|
||||
end
|
||||
end
|
||||
@@ -1,18 +0,0 @@
|
||||
class Desktop::JournalListsController < ApplicationController
|
||||
def index
|
||||
level_types = JournalLevelType.all
|
||||
all_journal_lists = WritingJournal.where(create_user_id: current_user.id)
|
||||
all_journal_lists = all_journal_lists.map do |j|
|
||||
[ j.journal_title,
|
||||
j.journal_level_type_ids.map do |type|
|
||||
level_types.find(type).title
|
||||
end]
|
||||
end
|
||||
|
||||
@journal_lists = all_journal_lists.uniq
|
||||
|
||||
respond_to do |format|
|
||||
format.html { render :layout => false}
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,107 +0,0 @@
|
||||
class Desktop::JournalPagesController < ApplicationController
|
||||
def index
|
||||
@writing_journal = WritingJournal.where(create_user_id: current_user.id)
|
||||
@level_types = JournalLevelType.all
|
||||
|
||||
respond_to do |format|
|
||||
format.html { render :layout => false}
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@writing_journal = WritingJournal.new
|
||||
@level_types = JournalLevelType.all
|
||||
@author_types = JournalAuthorType.all
|
||||
@paper_types= JournalPaperType.all
|
||||
@co_author_candidate =
|
||||
CoAuthor.where(name_id: current_user.id).map{|c|c.co_author}
|
||||
@journal_candidate =
|
||||
WritingJournal.where(create_user_id: current_user.id).map{|j|j.journal_title}.uniq
|
||||
|
||||
respond_to do |format|
|
||||
format.html { render :layout => false}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
@writing_journal = WritingJournal.find(params[:id])
|
||||
@level_types = JournalLevelType.all
|
||||
@author_types = JournalAuthorType.all
|
||||
@paper_types= JournalPaperType.all
|
||||
respond_to do |format|
|
||||
format.html { render :layout => false}
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
params[:writing_journal][:create_user_id] = current_user.id
|
||||
@writing_journal = WritingJournal.new(params[:writing_journal])
|
||||
|
||||
if @writing_journal.save
|
||||
render json: {success: true, msg: t('create.success.paper')}.to_json
|
||||
else
|
||||
error_msg = @writing_journal.errors.full_messages.join("<br />")
|
||||
render json: {success: false, msg: error_msg}.to_json
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
params[:writing_journal][:update_user_id] = current_user.id
|
||||
@writing_journal= WritingJournal.find(params[:id])
|
||||
|
||||
if @writing_journal.update_attributes(params[:writing_journal])
|
||||
render json: {success: true, msg: t('update.success.paper')}.to_json
|
||||
else
|
||||
error_msg = @writing_journal.errors.full_messages.join("<br />")
|
||||
render json: {success: false, msg: error_msg}.to_json
|
||||
end
|
||||
end
|
||||
|
||||
def check_file_type file
|
||||
if not file.nil?
|
||||
file_type = MIME::Types.type_for(file).first.to_s.split("/")[1]
|
||||
file_type = "/assets/ft-icons/#{file_type}/#{file_type}-48_32.png"
|
||||
else
|
||||
file_type = ""
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@writing_journal = WritingJournal.find(params[:id])
|
||||
@writing_journal.destroy
|
||||
render :json => {success: true, msg: t('delete.success.paper')}
|
||||
end
|
||||
|
||||
def get_journals_json
|
||||
publications = WritingJournal.where(create_user_id: current_user.id)
|
||||
|
||||
sort_publications= Hash.new
|
||||
data = Array.new
|
||||
|
||||
publications.each do |publication|
|
||||
if sort_publications[publication.journal_title].nil?
|
||||
sort_publications[publication.journal_title] = Array.new
|
||||
end
|
||||
sort_publications[publication.journal_title] <<
|
||||
{ title: publication.paper_title,
|
||||
keywords: publication.keywords,
|
||||
abstract: publication.abstract,
|
||||
coauthors: publication.authors,
|
||||
year: publication.year,
|
||||
url_edit: edit_desktop_journal_page_path(publication),
|
||||
url_delete: desktop_journal_page_path(publication),
|
||||
files: publication.writing_journal_files.collect{|file|
|
||||
{title: file.title, url: file.file.url, icon: check_file_type(file.file.url)}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
sort_publications.each do |journal, papers|
|
||||
data << {title: journal, papers: papers}
|
||||
end
|
||||
|
||||
render json: JSON.pretty_generate(data)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in new issue
Block a user