From c9cc26c600394a2e84a9a6bcd4c7c32ed584ed69 Mon Sep 17 00:00:00 2001 From: Finn Bacall Date: Tue, 15 Jul 2025 12:57:47 +0100 Subject: [PATCH 01/18] Spaces index styling --- app/assets/stylesheets/learning-paths.scss | 2 +- .../learning_paths/_learning_path.html.erb | 2 +- app/views/spaces/_space.html.erb | 24 ++++++++++--------- app/views/spaces/show.html.erb | 2 +- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/app/assets/stylesheets/learning-paths.scss b/app/assets/stylesheets/learning-paths.scss index 692c64557..f90730a63 100644 --- a/app/assets/stylesheets/learning-paths.scss +++ b/app/assets/stylesheets/learning-paths.scss @@ -38,7 +38,7 @@ } } -.learning-path-item { +.block-item { text-align: center; border-image-slice: 80; border-image-width: 80px; diff --git a/app/views/learning_paths/_learning_path.html.erb b/app/views/learning_paths/_learning_path.html.erb index 3abdb502c..64c87a277 100644 --- a/app/views/learning_paths/_learning_path.html.erb +++ b/app/views/learning_paths/_learning_path.html.erb @@ -1,4 +1,4 @@ -
  • +
  • <%= link_to learning_path, class: 'link-overlay' do %> <%= item_order_badge(collection_item) if defined? collection_item %> diff --git a/app/views/spaces/_space.html.erb b/app/views/spaces/_space.html.erb index 907cbb1ae..a36330c57 100644 --- a/app/views/spaces/_space.html.erb +++ b/app/views/spaces/_space.html.erb @@ -1,21 +1,23 @@ <% cache(space, expires_in: 6.hours) do %> -
  • +
  • <%= link_to space, class: 'link-overlay' do %> - <%= image_tag get_image_url_for(space), class: "media-image listing_image pull-right" %> + <%# image_tag get_image_url_for(space), class: "media-image listing_image pull-right" %>

    <%= space.title %>

    - <%# if space.materials.length > 0 %> - - <%# end %> + <%= space.url %> - <%# if space.events.length > 0 %> - - - - - <%# end %> + <% if space.materials.length > 0 %> +
    <%= pluralize(space.materials.length, 'training material') %>
    + <% end %> + + <% if space.events.length > 0 %> +
    + <%= pluralize(space.events.not_finished.length, 'event') %> + (<%= pluralize(space.events.finished.length, 'past event') %>) +
    + <% end %> <% end %>
  • <% end %> diff --git a/app/views/spaces/show.html.erb b/app/views/spaces/show.html.erb index ada8f3925..9b3599c26 100644 --- a/app/views/spaces/show.html.erb +++ b/app/views/spaces/show.html.erb @@ -27,7 +27,7 @@
    - <%= display_attribute(@space, :host) %> + <%= display_attribute(@space, :url) %>
    <%= render_markdown @space.description %> From 0605bf00870b5cb0afef73d8751112cd0fa57dfc Mon Sep 17 00:00:00 2001 From: Finn Bacall Date: Thu, 7 Aug 2025 09:54:30 +0100 Subject: [PATCH 02/18] Add `space_id` to sources --- db/migrate/20250807085314_add_space_id_to_sources.rb | 5 +++++ db/schema.rb | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 db/migrate/20250807085314_add_space_id_to_sources.rb diff --git a/db/migrate/20250807085314_add_space_id_to_sources.rb b/db/migrate/20250807085314_add_space_id_to_sources.rb new file mode 100644 index 000000000..4dbbef59a --- /dev/null +++ b/db/migrate/20250807085314_add_space_id_to_sources.rb @@ -0,0 +1,5 @@ +class AddSpaceIdToSources < ActiveRecord::Migration[7.2] + def change + add_reference :sources, :space, foreign_key: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 7354d68e5..769407996 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -482,7 +482,9 @@ t.integer "approval_status" t.datetime "updated_at" t.string "default_language" + t.bigint "space_id" t.index ["content_provider_id"], name: "index_sources_on_content_provider_id" + t.index ["space_id"], name: "index_sources_on_space_id" t.index ["user_id"], name: "index_sources_on_user_id" end @@ -667,6 +669,7 @@ add_foreign_key "node_links", "nodes" add_foreign_key "nodes", "users" add_foreign_key "sources", "content_providers" + add_foreign_key "sources", "spaces" add_foreign_key "sources", "users" add_foreign_key "space_roles", "spaces" add_foreign_key "space_roles", "users" From e9b7366019820cdc6ea9989b06785b167658fd8d Mon Sep 17 00:00:00 2001 From: Finn Bacall Date: Thu, 7 Aug 2025 10:19:46 +0100 Subject: [PATCH 03/18] Tie source and ingested resources to a space --- app/controllers/sources_controller.rb | 1 + app/models/source.rb | 1 + lib/ingestors/ingestor.rb | 1 + test/unit/ingestors/ingestor_test.rb | 26 +++++++++++++++++++++++++- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/controllers/sources_controller.rb b/app/controllers/sources_controller.rb index 33142098e..0df2974f7 100644 --- a/app/controllers/sources_controller.rb +++ b/app/controllers/sources_controller.rb @@ -39,6 +39,7 @@ def create authorize Source @source = @content_provider.sources.build(source_params) @source.user = current_user + @source.space = current_space respond_to do |format| if @source.save diff --git a/app/models/source.rb b/app/models/source.rb index 381e5da0a..889bf44a0 100644 --- a/app/models/source.rb +++ b/app/models/source.rb @@ -2,6 +2,7 @@ class Source < ApplicationRecord include LogParameterChanges include HasTestJob include HasAssociatedNodes + include InSpace APPROVAL_STATUS = { 0 => :not_approved, diff --git a/lib/ingestors/ingestor.rb b/lib/ingestors/ingestor.rb index 1fa4fa7be..7f9106e9a 100644 --- a/lib/ingestors/ingestor.rb +++ b/lib/ingestors/ingestor.rb @@ -164,6 +164,7 @@ def write_resources(type, resources, user, provider, source: nil) # check for matched events resource.user_id ||= user.id resource.content_provider_id ||= provider.id + resource.space_id ||= source&.space_id existing_resource = find_existing(type, resource) update = existing_resource diff --git a/test/unit/ingestors/ingestor_test.rb b/test/unit/ingestors/ingestor_test.rb index 28ad68760..7b1bd13c3 100644 --- a/test/unit/ingestors/ingestor_test.rb +++ b/test/unit/ingestors/ingestor_test.rb @@ -89,7 +89,7 @@ class IngestorTest < ActiveSupport::TestCase assert_equal(event.language, 'de') end - test 'does not set event language when languare and source default language missing' do + test 'does not set event language when language and source default language missing' do user = users(:scraper_user) provider = content_providers(:portal_provider) @@ -187,4 +187,28 @@ class IngestorTest < ActiveSupport::TestCase end end end + + test 'sets event space from source space' do + user = users(:scraper_user) + provider = content_providers(:portal_provider) + space = spaces(:plants) + + @source = Source.create!(url: 'https://somewhere.com/stuff', method: 'bioschemas', + enabled: true, approval_status: 'approved', + space: space, content_provider: provider, user: users(:admin)) + + ingestor = Ingestors::Ingestor.new + + ingestor.instance_variable_set(:@events, + [OpenStruct.new(url: 'https://some-course.ca', + title: 'Some course', + start: '2021-01-31 13:00:00', + end:'2021-01-31 14:00:00')]) + assert_difference('provider.events.count', 1) do + ingestor.write(user, provider, source: @source) + end + event = Event.find_by(title: 'Some course') + assert_equal space, event.space + end + end From 0dca8f867ba500fe22e982b10759c1b31fcbc423 Mon Sep 17 00:00:00 2001 From: Finn Bacall Date: Thu, 7 Aug 2025 10:41:57 +0100 Subject: [PATCH 04/18] Ensure cross-space filter is visible even if other curation filters not Tweak filter wording to be more accurate to function --- app/views/search/common/_facet_sidebar_curation.html.erb | 2 +- config/locales/en.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/search/common/_facet_sidebar_curation.html.erb b/app/views/search/common/_facet_sidebar_curation.html.erb index a30431886..91043dbeb 100644 --- a/app/views/search/common/_facet_sidebar_curation.html.erb +++ b/app/views/search/common/_facet_sidebar_curation.html.erb @@ -3,7 +3,7 @@ <% show_cross_space_filter = current_user&.is_admin? %> <% resource_name = resource_type.model_name.human.downcase.pluralize %> -<% if show_last_scraped_filter || show_hidden_filter %> +<% if show_last_scraped_filter || show_hidden_filter || show_cross_space_filter %>