diff --git a/app/controllers/admin/education/diplomas_controller.rb b/app/controllers/admin/education/diplomas_controller.rb index 0898fac6fb041c9feb6d6f988a22f869d4f2aa96..fdde0bd5b0974af274e4917e5ab64cd6e3280731 100644 --- a/app/controllers/admin/education/diplomas_controller.rb +++ b/app/controllers/admin/education/diplomas_controller.rb @@ -28,7 +28,7 @@ class Admin::Education::DiplomasController < Admin::Education::ApplicationContro def create @diploma.university = current_university - if @diploma.save_and_sync + if @diploma.save redirect_to [:admin, @diploma], notice: t('admin.successfully_created_html', model: @diploma.to_s) else @@ -38,7 +38,7 @@ class Admin::Education::DiplomasController < Admin::Education::ApplicationContro end def update - if @diploma.update_and_sync(diploma_params) + if @diploma.update(diploma_params) redirect_to [:admin, @diploma], notice: t('admin.successfully_updated_html', model: @diploma.to_s) else @@ -49,7 +49,7 @@ class Admin::Education::DiplomasController < Admin::Education::ApplicationContro end def destroy - @diploma.destroy_and_sync + @diploma.destroy redirect_to admin_education_diplomas_url, notice: t('admin.successfully_destroyed_html', model: @diploma.to_s) end diff --git a/app/controllers/admin/education/programs_controller.rb b/app/controllers/admin/education/programs_controller.rb index 77f2f23b71fba57f818b635ea7e878889aa963af..59a0f35341d48d284ee31506e1d1976da106258d 100644 --- a/app/controllers/admin/education/programs_controller.rb +++ b/app/controllers/admin/education/programs_controller.rb @@ -78,7 +78,7 @@ class Admin::Education::ProgramsController < Admin::Education::ApplicationContro def create @program.university = current_university @program.add_photo_import params[:photo_import] - if @program.save_and_sync + if @program.save redirect_to [:admin, @program], notice: t('admin.successfully_created_html', model: @program.to_s) else breadcrumb @@ -88,7 +88,7 @@ class Admin::Education::ProgramsController < Admin::Education::ApplicationContro def update @program.add_photo_import params[:photo_import] - if @program.update_and_sync(program_params) + if @program.update(program_params) redirect_to [:admin, @program], notice: t('admin.successfully_updated_html', model: @program.to_s) else breadcrumb @@ -98,7 +98,7 @@ class Admin::Education::ProgramsController < Admin::Education::ApplicationContro end def destroy - @program.destroy_and_sync + @program.destroy redirect_to admin_education_programs_url, notice: t('admin.successfully_destroyed_html', model: @program.to_s) end diff --git a/app/controllers/admin/education/schools_controller.rb b/app/controllers/admin/education/schools_controller.rb index 93593ffc8f4bde0b4071a911721c42150fcea930..75c721d6ddeba7006966b18dab07ad35b14b2108 100644 --- a/app/controllers/admin/education/schools_controller.rb +++ b/app/controllers/admin/education/schools_controller.rb @@ -27,7 +27,7 @@ class Admin::Education::SchoolsController < Admin::Education::ApplicationControl def create @school.university = current_university - if @school.save_and_sync + if @school.save redirect_to [:admin, @school], notice: t('admin.successfully_created_html', model: @school.to_s) else breadcrumb @@ -36,7 +36,7 @@ class Admin::Education::SchoolsController < Admin::Education::ApplicationControl end def update - if @school.update_and_sync(school_params) + if @school.update(school_params) redirect_to [:admin, @school], notice: t('admin.successfully_updated_html', model: @school.to_s) else breadcrumb @@ -46,7 +46,7 @@ class Admin::Education::SchoolsController < Admin::Education::ApplicationControl end def destroy - @school.destroy_and_sync + @school.destroy redirect_to admin_education_schools_url, notice: t('admin.successfully_destroyed_html', model: @school.to_s) end diff --git a/app/controllers/admin/research/journals/papers/kinds_controller.rb b/app/controllers/admin/research/journals/papers/kinds_controller.rb index 3740b69ca5566a790dc829bc0c18d6c4375e081c..7d27734cb2e5eab7ebc53b4e55d0d2bba13cfb70 100644 --- a/app/controllers/admin/research/journals/papers/kinds_controller.rb +++ b/app/controllers/admin/research/journals/papers/kinds_controller.rb @@ -4,7 +4,7 @@ class Admin::Research::Journals::Papers::KindsController < Admin::Research::Jour def index breadcrumb end - + def show @papers = @kind.papers.page params[:page] breadcrumb @@ -25,7 +25,7 @@ class Admin::Research::Journals::Papers::KindsController < Admin::Research::Jour breadcrumb add_breadcrumb t('create') end - + def edit breadcrumb add_breadcrumb @kind, admin_research_journal_kind_path(@kind) @@ -37,7 +37,7 @@ class Admin::Research::Journals::Papers::KindsController < Admin::Research::Jour journal: @journal, university: current_university ) - if @kind.save_and_sync + if @kind.save redirect_to admin_research_journal_kind_path(@kind), notice: t('admin.successfully_created_html', model: @paper_kind.to_s) else breadcrumb @@ -47,7 +47,7 @@ class Admin::Research::Journals::Papers::KindsController < Admin::Research::Jour end def update - if @kind.update_and_sync(kind_params) + if @kind.update(kind_params) redirect_to admin_research_journal_kind_path(@kind), notice: t('admin.successfully_updated_html', model: @paper_kind.to_s) else breadcrumb @@ -58,7 +58,7 @@ class Admin::Research::Journals::Papers::KindsController < Admin::Research::Jour end def destroy - @kind.destroy_and_sync + @kind.destroy redirect_to admin_research_journal_path(@journal), notice: t('admin.successfully_destroyed_html', model: @paper_kind.to_s) end diff --git a/app/controllers/admin/research/journals/papers_controller.rb b/app/controllers/admin/research/journals/papers_controller.rb index 614f191a858dbb39778c5727dbb35a83ea1c4a78..a70a74f2cdca8dfaa7de6ce0883bd2b3418bc99e 100644 --- a/app/controllers/admin/research/journals/papers_controller.rb +++ b/app/controllers/admin/research/journals/papers_controller.rb @@ -36,7 +36,7 @@ class Admin::Research::Journals::PapersController < Admin::Research::Journals::A university: current_university, updated_by: current_user ) - if @paper.save_and_sync + if @paper.save redirect_to admin_research_journal_paper_path(@paper), notice: t('admin.successfully_created_html', model: @paper.to_s) else breadcrumb @@ -46,7 +46,7 @@ class Admin::Research::Journals::PapersController < Admin::Research::Journals::A def update @paper.updated_by = current_user - if @paper.update_and_sync(paper_params) + if @paper.update(paper_params) redirect_to admin_research_journal_paper_path(@paper), notice: t('admin.successfully_updated_html', model: @paper.to_s) else breadcrumb @@ -56,7 +56,7 @@ class Admin::Research::Journals::PapersController < Admin::Research::Journals::A end def destroy - @paper.destroy_and_sync + @paper.destroy redirect_to admin_research_journal_path(@journal), notice: t('admin.successfully_destroyed_html', model: @paper.to_s) end diff --git a/app/controllers/admin/research/journals/volumes_controller.rb b/app/controllers/admin/research/journals/volumes_controller.rb index 7a8d0ce2e10c87ff64b5ebb96e736239c1941445..343b40ce0ae0a8a97f505c7324c59f643dc6a1e1 100644 --- a/app/controllers/admin/research/journals/volumes_controller.rb +++ b/app/controllers/admin/research/journals/volumes_controller.rb @@ -33,7 +33,7 @@ class Admin::Research::Journals::VolumesController < Admin::Research::Journals:: def create @volume.add_photo_import params[:photo_import] @volume.assign_attributes(journal: @journal, university: current_university) - if @volume.save_and_sync + if @volume.save redirect_to admin_research_journal_volume_path(@volume), notice: t('admin.successfully_created_html', model: @volume.to_s) else breadcrumb @@ -43,7 +43,7 @@ class Admin::Research::Journals::VolumesController < Admin::Research::Journals:: def update @volume.add_photo_import params[:photo_import] - if @volume.update_and_sync(volume_params) + if @volume.update(volume_params) redirect_to admin_research_journal_volume_path(@volume), notice: t('admin.successfully_updated_html', model: @volume.to_s) else breadcrumb @@ -53,7 +53,7 @@ class Admin::Research::Journals::VolumesController < Admin::Research::Journals:: end def destroy - @volume.destroy_and_sync + @volume.destroy redirect_to admin_research_journal_path(@journal), notice: t('admin.successfully_destroyed_html', model: @volume.to_s) end diff --git a/app/controllers/admin/research/journals_controller.rb b/app/controllers/admin/research/journals_controller.rb index 88d765513cb792405f77f19e0e29a4b390063f6d..fab7f38a1d95c205c07a1f2b2b28001d346da5b8 100644 --- a/app/controllers/admin/research/journals_controller.rb +++ b/app/controllers/admin/research/journals_controller.rb @@ -27,7 +27,7 @@ class Admin::Research::JournalsController < Admin::Research::ApplicationControll end def create - if @journal.save_and_sync + if @journal.save redirect_to [:admin, @journal], notice: t('admin.successfully_created_html', model: @journal.to_s) else breadcrumb @@ -36,7 +36,7 @@ class Admin::Research::JournalsController < Admin::Research::ApplicationControll end def update - if @journal.update_and_sync(journal_params) + if @journal.update(journal_params) redirect_to [:admin, @journal], notice: t('admin.successfully_updated_html', model: @journal.to_s) else breadcrumb @@ -46,7 +46,7 @@ class Admin::Research::JournalsController < Admin::Research::ApplicationControll end def destroy - @journal.destroy_and_sync + @journal.destroy redirect_to admin_research_journals_url, notice: t('admin.successfully_destroyed_html', model: @journal.to_s) end diff --git a/app/controllers/admin/research/laboratories_controller.rb b/app/controllers/admin/research/laboratories_controller.rb index 67621fc6420f7fd87216cd0a495d96df3c19f599..23f95c0fbbcefae8ddac8b3ba9ab249b42c877ca 100644 --- a/app/controllers/admin/research/laboratories_controller.rb +++ b/app/controllers/admin/research/laboratories_controller.rb @@ -26,7 +26,7 @@ class Admin::Research::LaboratoriesController < Admin::Research::ApplicationCont end def create - if @laboratory.save_and_sync + if @laboratory.save redirect_to [:admin, @laboratory], notice: t('admin.successfully_created_html', model: @laboratory.to_s) else breadcrumb @@ -35,7 +35,7 @@ class Admin::Research::LaboratoriesController < Admin::Research::ApplicationCont end def update - if @laboratory.update_and_sync(laboratory_params) + if @laboratory.update(laboratory_params) redirect_to [:admin, @laboratory], notice: t('admin.successfully_updated_html', model: @laboratory.to_s) else breadcrumb @@ -45,7 +45,7 @@ class Admin::Research::LaboratoriesController < Admin::Research::ApplicationCont end def destroy - @laboratory.destroy_and_sync + @laboratory.destroy redirect_to admin_research_laboratories_url, notice: t('admin.successfully_destroyed_html', model: @laboratory.to_s) end diff --git a/app/models/communication/website/post.rb b/app/models/communication/website/post.rb index fe8fabdbd7ad26165e094516530ab24e4a692f22..1e19a45a1804d8fc4595028f4a7635b44f1d2fa5 100644 --- a/app/models/communication/website/post.rb +++ b/app/models/communication/website/post.rb @@ -174,9 +174,9 @@ class Communication::Website::Post < ApplicationRecord def update_authors_statuses! old_author = University::Person.find_by(id: author_id_before_last_save) if old_author && old_author.communication_website_posts.none? - old_author.update_and_sync(is_author: false) + old_author.update(is_author: false) end - author.update_and_sync(is_author: true) if author_id + author.update(is_author: true) if author_id end def translate_additional_data!(translation) diff --git a/app/models/concerns/with_git.rb b/app/models/concerns/with_git.rb index 01e36762e9552a6d91be36b69d3abebb797ffe84..7fb6ba7632bea78ba2930b7c249622c52d72fc06 100644 --- a/app/models/concerns/with_git.rb +++ b/app/models/concerns/with_git.rb @@ -32,31 +32,27 @@ module WithGit end def sync_with_git - websites_for_self.each do |website| - next unless website.git_repository.valid? - Communication::Website::GitFile.sync website, self - recursive_dependencies.each do |object| - Communication::Website::GitFile.sync website, object - end - references.each do |object| - Communication::Website::GitFile.sync website, object - end - website.git_repository.sync! + return unless website_for_self.git_repository.valid? + Communication::Website::GitFile.sync website_for_self, self + recursive_dependencies.each do |object| + Communication::Website::GitFile.sync website_for_self, object end + references.each do |object| + Communication::Website::GitFile.sync website_for_self, object + end + website_for_self.git_repository.sync! end handle_asynchronously :sync_with_git, queue: 'default' def destroy_from_git - websites.each do |website| - next unless website.git_repository.valid? - Communication::Website::GitFile.sync website, self, destroy: true - # # FIXME - # dependencies = git_destroy_dependencies(website).to_a.flatten.uniq.compact - # dependencies.each do |object| - # Communication::Website::GitFile.sync website, object, destroy: true - # end - website.git_repository.sync! - end + return unless website_for_self.git_repository.valid? + Communication::Website::GitFile.sync website_for_self, self, destroy: true + # # FIXME + # dependencies = git_destroy_dependencies(website).to_a.flatten.uniq.compact + # dependencies.each do |object| + # Communication::Website::GitFile.sync website, object, destroy: true + # end + website_for_self.git_repository.sync! end def for_website?(website) @@ -69,15 +65,7 @@ module WithGit protected - def websites_for_self - if is_a? Communication::Website - [self] - elsif respond_to?(:website) - [website] - elsif respond_to?(:websites) - websites - else - [] - end + def website_for_self + is_a?(Communication::Website) ? self : website end end