diff --git a/app/controllers/admin/communication/websites/connections_controller.rb b/app/controllers/admin/communication/websites/connections_controller.rb index 02820624b0cdcadc7ec9e59d3c5ca6b3a9165436..6a15e0607c918cb8054d9ec0c65ba9ccfbcc2c03 100644 --- a/app/controllers/admin/communication/websites/connections_controller.rb +++ b/app/controllers/admin/communication/websites/connections_controller.rb @@ -6,7 +6,6 @@ class Admin::Communication::Websites::ConnectionsController < Admin::Communicati def show @connection = @website.connections.find params[:id] - @others = @connection.for_same_object breadcrumb add_breadcrumb @connection end diff --git a/app/controllers/admin/communication/websites_controller.rb b/app/controllers/admin/communication/websites_controller.rb index d83628439f6b2d87ab09005347ef20cd8f185d65..5cb335ea0cc3ab1eba7974c7b9048584868525c6 100644 --- a/app/controllers/admin/communication/websites_controller.rb +++ b/app/controllers/admin/communication/websites_controller.rb @@ -5,7 +5,6 @@ class Admin::Communication::WebsitesController < Admin::Communication::Websites: def index @websites = apply_scopes(@websites).ordered.page(params[:page]) breadcrumb - add_breadcrumb Communication::Website.model_name.human(count: 2), admin_communication_websites_path end def show diff --git a/app/models/communication/block.rb b/app/models/communication/block.rb index 5bcac1570de7e82a3402dafbb225da3058288911..e723210bf3f9513f9b7c02b17b383530574398ed 100644 --- a/app/models/communication/block.rb +++ b/app/models/communication/block.rb @@ -39,9 +39,6 @@ class Communication::Block < ApplicationRecord # template_blobs would be a better name, because there are files has_many_attached :template_images - delegate :website, to: :about - delegate :websites, to: :about - enum template_kind: { chapter: 50, image: 51, @@ -86,6 +83,18 @@ class Communication::Block < ApplicationRecord template.data end + def website + about.website + rescue + nil + end + + def websites + about.websites + rescue + [] + end + def display_dependencies template.display_dependencies end diff --git a/app/models/communication/block/component/base.rb b/app/models/communication/block/component/base.rb index f49dfdb03fd72ff5dba8e873903f0ec815bf8377..0c5b241af7d465a8d4a397a2ffe1aa27ff7e42d5 100644 --- a/app/models/communication/block/component/base.rb +++ b/app/models/communication/block/component/base.rb @@ -37,4 +37,8 @@ class Communication::Block::Component::Base def translate! # By default, does nothing. Specific cases are handled in their own definitions. (example: post) end + + def to_s + self.class.to_s.demodulize + end end diff --git a/app/models/communication/block/template/base.rb b/app/models/communication/block/template/base.rb index 98799b982b8d1755ab32d0da05be4dd93bc97fe0..abe513efd45c93740ce25401659ea1f934c9d34c 100644 --- a/app/models/communication/block/template/base.rb +++ b/app/models/communication/block/template/base.rb @@ -150,6 +150,10 @@ class Communication::Block::Template::Base hash end + def to_s + self.class.to_s.demodulize + end + protected def build_component(property) diff --git a/app/models/communication/website/connection.rb b/app/models/communication/website/connection.rb index 56744bfba065a96a61fd5c70a7e52c2478267cf9..1ab29f0ca4a2e06cf4dff373d29b0c699912e8e9 100644 --- a/app/models/communication/website/connection.rb +++ b/app/models/communication/website/connection.rb @@ -35,13 +35,6 @@ class Communication::Website::Connection < ApplicationRecord for_object(object).distinct(:website).collect(&:website).uniq end - def for_same_object - self.class.where( university: university, - website: website, - object: object) - .where.not(id: id) - end - def to_s "#{id.split('-').first}" end diff --git a/app/models/communication/website/with_connections.rb b/app/models/communication/website/with_connections.rb index 7760da784d6601da94cec5aa1d07fb5155e064a1..c7b01d907a323c8f9e17f51d9c437080c51b47f5 100644 --- a/app/models/communication/website/with_connections.rb +++ b/app/models/communication/website/with_connections.rb @@ -10,7 +10,7 @@ module Communication::Website::WithConnections def clean_connections! start = Time.now connect self - # connections.where('updated_at < ?', start).destroy_all + connections.where('updated_at < ?', start).destroy_all end def connect(object) diff --git a/app/models/concerns/with_dependencies.rb b/app/models/concerns/with_dependencies.rb index 75ea2c51eb2a609dd4bc0c38bbbe3c438d1e2b08..3a4f865c8901950eebea9bbda89c0843a53a83f6 100644 --- a/app/models/concerns/with_dependencies.rb +++ b/app/models/concerns/with_dependencies.rb @@ -20,7 +20,7 @@ module WithDependencies reference_dependencies.each do |dependency| add_dependency_to_array array, dependency end - array + array.compact end protected diff --git a/app/models/concerns/with_websites.rb b/app/models/concerns/with_websites.rb index dcdcc4fb1fbfd401ceadc186ae0fda1485c44011..ee0e237e32f130dc5f1f34d77acde373af7f6e17 100644 --- a/app/models/concerns/with_websites.rb +++ b/app/models/concerns/with_websites.rb @@ -12,7 +12,7 @@ module WithWebsites protected def connect_to_websites - if respond_to?(:website) + if respond_to?(:website) && !website.nil? website.connect self else websites.each { |website| website.connect self } diff --git a/app/models/university/organization.rb b/app/models/university/organization.rb index baedf60ef881b26937a2694970619be382760c7c..101c87ca398d9d305586c4c0758cbce0b8a826ab 100644 --- a/app/models/university/organization.rb +++ b/app/models/university/organization.rb @@ -39,6 +39,7 @@ class University::Organization < ApplicationRecord include Sanitizable include WithBlobs include WithBlocks + include WithDependencies include WithGit include WithPermalink include WithSlug diff --git a/app/views/admin/application/_dependencies.html.erb b/app/views/admin/application/_dependencies.html.erb index 2602c59097f413059ae5747706ec41b73444e03a..5ab6bbc49e2d4fc28dce08906b2d44cc9b3af457 100644 --- a/app/views/admin/application/_dependencies.html.erb +++ b/app/views/admin/application/_dependencies.html.erb @@ -10,6 +10,27 @@ expanded ||= false aria-controls="dependencies"></i> <div id="dependencies" class="collapse"> <%= osuny_panel 'Dependencies', subtitle: 'Only for server admins' do %> + <h2 class="h5">dependencies</h2> + <div class="table-responsive"> + <table class="<%= table_classes %>"> + <thead> + <tr> + <th>Name</th> + <th>Class</th> + </tr> + </thead> + <tbody> + <% dependencies.each do |dependency| %> + <tr> + <td><%= dependency.to_s %></td> + <td><%= dependency.class %></td> + </tr> + <% end %> + </tbody> + </table> + </div> + + <h2 class="h5">git_dependencies</h2> <div class="table-responsive"> <table class="<%= table_classes %>"> diff --git a/app/views/admin/communication/blocks/show.html.erb b/app/views/admin/communication/blocks/show.html.erb index 42dcbe027f2c599ba34cf4f1ef9cbd9d2dc5e796..649998b0aef688ec818f826f7c39cf07ef29ab83 100644 --- a/app/views/admin/communication/blocks/show.html.erb +++ b/app/views/admin/communication/blocks/show.html.erb @@ -1,6 +1,7 @@ <% content_for :title, @block %> <%= render 'admin/application/dependencies', + dependencies: @block.dependencies, git_dependencies: @block.template.git_dependencies, active_storage_blobs: @block.template.active_storage_blobs, expanded: true %> diff --git a/app/views/admin/communication/websites/connections/show.html.erb b/app/views/admin/communication/websites/connections/show.html.erb index 10be4f529a00ffb5ee1ec1d4e1d4df597268f980..3689e8487fe60077aa5f7a1a703f87a9b0a988b5 100644 --- a/app/views/admin/communication/websites/connections/show.html.erb +++ b/app/views/admin/communication/websites/connections/show.html.erb @@ -1,24 +1,8 @@ <% content_for :title, @connection %> -<div class="row"> - <div class="col-lg-6 mb-5"> - <%= osuny_label Communication::Website::Connection.human_attribute_name('object') %> - <p><%= @connection.object %></p> - <%= osuny_label Communication::Website::Connection.human_attribute_name('object_type') %> - <p><%= @connection.object_type %></p> - <%= osuny_label Communication::Website::Connection.human_attribute_name('object_id') %> - <p><%= @connection.object_id %></p> - </div> - <div class="col-lg-6 mb-5"> - <%= osuny_label Communication::Website::Connection.human_attribute_name('source') %> - <p><%= @connection.source %></p> - <%= osuny_label Communication::Website::Connection.human_attribute_name('source_type') %> - <p><%= @connection.source_type %></p> - <%= osuny_label Communication::Website::Connection.human_attribute_name('source_id') %> - <p><%= @connection.source_id %></p> - </div> -</div> - -<%= osuny_panel Communication::Website::Connection.human_attribute_name('others') do %> - <%= render 'admin/communication/websites/connections/list', connections: @others %> -<% end %> \ No newline at end of file +<%= osuny_label Communication::Website::Connection.human_attribute_name('object') %> +<p><%= @connection.object %></p> +<%= osuny_label Communication::Website::Connection.human_attribute_name('object_type') %> +<p><%= @connection.object_type %></p> +<%= osuny_label Communication::Website::Connection.human_attribute_name('object_id') %> +<p><%= @connection.object_id %></p> diff --git a/app/views/admin/communication/websites/pages/show.html.erb b/app/views/admin/communication/websites/pages/show.html.erb index d5c54efe44a9daf54298a9250415ccda10f223d5..3ec87ada48013dcf54de31ad4f588cf5a2dcd615 100644 --- a/app/views/admin/communication/websites/pages/show.html.erb +++ b/app/views/admin/communication/websites/pages/show.html.erb @@ -8,6 +8,7 @@ <%= render 'admin/communication/blocks/list', about: @page %> <%= render 'admin/communication/websites/pages/show/special_page', about: @page %> <%= render 'admin/application/dependencies', + dependencies: @page.dependencies, git_dependencies: @page.git_dependencies(@page.website), active_storage_blobs: @page.active_storage_blobs %> </div>