Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publications hors HAL #1596

Merged
merged 10 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions app/controllers/admin/research/hal/publications_controller.rb

This file was deleted.

66 changes: 66 additions & 0 deletions app/controllers/admin/research/publications_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
class Admin::Research::PublicationsController < Admin::Research::ApplicationController
load_and_authorize_resource class: Research::Publication

has_scope :for_search_term

def index
@publications = apply_scopes(@publications).ordered.page(params[:page])
breadcrumb
end

def show
breadcrumb
end

def static
@about = @publication
@website = @publication.websites&.first || current_university.websites.first
render_as_plain_text
end

def new
breadcrumb
end

def edit
breadcrumb
add_breadcrumb t('edit')
end

def create
if @publication.save
redirect_to [:admin, @publication], notice: t('admin.successfully_created_html', model: @publication.to_s)
else
breadcrumb
render :new, status: :unprocessable_entity
end
end

def update
if @publication.update(publication_params)
redirect_to [:admin, @publication], notice: t('admin.successfully_updated_html', model: @publication.to_s)
else
breadcrumb
add_breadcrumb t('edit')
render :edit, status: :unprocessable_entity
end
end

def destroy
@publication.destroy
redirect_to admin_research_publications_url, notice: t('admin.successfully_destroyed_html', model: @publication.to_s)
end

protected

def breadcrumb
super
add_breadcrumb Research::Publication.model_name.human(count: 2), admin_research_publications_path
breadcrumb_for @publication
end

def publication_params
params.require(:research_publication)
.permit(:title, :publication_date, :abstract, :authors_list, :doi, :ref, :journal_title, :url, :open_access, :citation_full, researcher_ids: [])
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Communication::Website::Page::ResearchHalPublication < Communication::Website::Page
class Communication::Website::Page::ResearchPublication < Communication::Website::Page

def is_necessary_for_website?
website.connected_hal_publications.any?
website.connected_publications.any?
end

def editable_width?
Expand All @@ -15,7 +15,7 @@ def full_width_by_default?
def dependencies
super +
[website.config_default_languages] +
website.connected_hal_publications
website.connected_publications
end

protected
Expand Down
2 changes: 1 addition & 1 deletion app/models/communication/website/page/with_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module Communication::Website::Page::WithType
# Research
Communication::Website::Page::ResearchVolume,
Communication::Website::Page::ResearchPaper,
Communication::Website::Page::ResearchHalPublication,
Communication::Website::Page::ResearchPublication,
# Administration
Communication::Website::Page::AdministrationLocation,
# People facets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def self.static_config_key
end

def self.pattern_in_website(website, language)
"/#{website.special_page(Communication::Website::Page::ResearchHalPublication, language: language).slug_with_ancestors}/:year-:slug/"
"/#{website.special_page(Communication::Website::Page::ResearchPublication, language: language).slug_with_ancestors}/:year-:slug/"
end

protected
Expand Down
6 changes: 3 additions & 3 deletions app/models/communication/website/with_connected_objects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ def connected_organizations
University::Organization.where(id: ids)
end

def connected_hal_publications
ids = connections.where(indirect_object_type: 'Research::Hal::Publication').pluck(:indirect_object_id)
Research::Hal::Publication.where(id: ids)
def connected_publications
ids = connections.where(indirect_object_type: 'Research::Publication').pluck(:indirect_object_id)
Research::Publication.where(id: ids)
end

# ensure the object "website" respond to both is_direct_object? and is_indirect_object? as website doesn't include neither as_direct_object nor as_indirect_object
Expand Down
2 changes: 1 addition & 1 deletion app/models/research.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def self.parts
[Research::Laboratory, :admin_research_laboratories_path],
[Research::Thesis, :admin_research_theses_path],
[Research::Journal, :admin_research_journals_path],
[Research::Hal, :admin_research_hal_root_path],
[Research::Publication, :admin_research_publications_path],
]
end
end
7 changes: 3 additions & 4 deletions app/models/research/hal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ def self.update_from_api!
end

def self.pause_git_sync
Research::Hal::Publication.skip_callback :save, :after, :connect_and_sync_direct_sources
Research::Publication.skip_callback :save, :after, :connect_and_sync_direct_sources
end

def self.unpause_git_sync
Research::Hal::Publication.set_callback :save, :after, :connect_and_sync_direct_sources
Research::Publication.set_callback :save, :after, :connect_and_sync_direct_sources
end

def self.clear_queue!
ids = []
Delayed::Job.find_each do |job|
next unless job.public_respond_to?(:payload_object)
if job.payload_object.method_name == :sync_indirect_object_with_git_without_delay &&
job.payload_object.args.first.is_a?(Research::Hal::Publication)
job.payload_object.args.first.is_a?(Research::Publication)
ids << job.id
end
end
Expand All @@ -39,7 +39,6 @@ def self.clear_queue!

def self.parts
[
[Research::Hal::Publication, :admin_research_hal_publications_path],
[Research::Hal::Author, :admin_research_hal_authors_path],
]
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/research/hal/author.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Research::Hal::Author < ApplicationRecord
include Sanitizable

has_and_belongs_to_many :publications,
foreign_key: 'research_hal_publication_id',
foreign_key: 'research_publication_id',
association_foreign_key: :research_hal_author_id
has_and_belongs_to_many :university_person_researchers,
class_name: 'University::Person',
Expand Down Expand Up @@ -68,7 +68,7 @@ def import_research_hal_publications!
publications.clear
# Do not overuse the API if no researcher is concerned
return if researchers.none?
Research::Hal::Publication.import_from_hal_for_author(self).each do |publication|
Importers::Hal.import_publications_for_author(self).each do |publication|
publications << publication
end
publications
Expand Down
147 changes: 0 additions & 147 deletions app/models/research/hal/publication.rb

This file was deleted.

Loading
Loading