Skip to content

Commit 8148581

Browse files
authored
Merge pull request #1342 from ElixirTeSS/multi-provider-ingestion
Store origin URI when exchanging
2 parents 994f058 + 40f5cf4 commit 8148581

25 files changed

Lines changed: 510 additions & 57 deletions

app/assets/stylesheets/application.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,11 @@ sup {
690690
margin-left: 5px;
691691
}
692692

693+
.exchange-icon {
694+
color: $brand-primary;
695+
margin-left: 5px;
696+
}
697+
693698
.days_ago_text {
694699
color: grey;
695700
font-style: italic;

app/controllers/events_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ def event_params
243243
:timezone, :content_provider_id, { collection_ids: [] }, { node_ids: [] },
244244
{ node_names: [] }, { target_audience: [] }, { eligibility: [] }, :visible,
245245
{ host_institutions: [] }, :capacity, :contact, :recognition, :learning_objectives,
246-
:prerequisites, :tech_requirements, :cost_basis, :cost_value, :cost_currency, :language, :presence,
246+
:prerequisites, :tech_requirements, :cost_basis, :cost_value, :cost_currency, :language,
247+
:presence, :origin_uri,
247248
external_resources_attributes: %i[id url title _destroy],
248249
external_resources: %i[url title], material_ids: [],
249250
llm_interaction_attributes: %i[id scrape_or_process model prompt input output needs_processing _destroy],

app/controllers/materials_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def material_params
170170
:last_scraped, :scraper_record, :remote_created_date, :remote_updated_date,
171171
:content_provider_id, :difficulty_level, :version, :status,
172172
:date_created, :date_modified, :date_published, :other_types,
173-
:prerequisites, :syllabus, :visible, :learning_objectives, { subsets: [] },
173+
:prerequisites, :syllabus, :visible, :learning_objectives, :origin_uri, { subsets: [] },
174174
{ target_audience: [] },
175175
{ collection_ids: [] }, { keywords: [] }, { resource_type: [] },
176176
{ scientific_topic_names: [] }, { scientific_topic_uris: [] },

app/helpers/application_helper.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ module ApplicationHelper
2929
private: { icon: 'fa-eye-slash', message: 'This resource is private' },
3030
missing: { icon: 'fa-chain-broken', message: 'This resource has been offline for over three days' },
3131
check: { icon: 'fa-check', message: 'This resource is enabled' },
32-
cross: { icon: 'fa-times', message: 'This resource has been disabled' }
32+
cross: { icon: 'fa-times', message: 'This resource has been disabled' },
33+
exchanged: { icon: 'fa-exchange', message: 'This resource originated from another TeSS registry' },
3334
}.freeze
3435

3536
# Countries that have priority in the country selection menu. Using ISO 3166-1 Alpha2 code.
@@ -93,6 +94,11 @@ def event_status_icon(event, size = nil)
9394
end
9495
end
9596

97+
def exchange_icon(resource, size = nil)
98+
return unless resource.origin_uri.present?
99+
"<span class='exchange-icon pull-right'>#{icon_for(:exchanged, size)}</span>".html_safe
100+
end
101+
96102
def icon_for(type, size = nil, options = {})
97103
options[:class] ||= "info-icon#{'-' + size.to_s if size}"
98104
"<i class=\"fa #{ICONS[type][:icon]} has-tooltip #{options[:class]}\"

app/models/application_record.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ class ApplicationRecord < ActiveRecord::Base
66
include AutocompleteManager
77
include ArrayFieldCleaner
88

9+
def oai_identifier
10+
"#{self.class.model_name.route_key}/#{id}"
11+
end
912
end

app/models/event.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ class Event < ApplicationRecord
157157
validates :presence, inclusion: { in: presences.keys, allow_blank: true }
158158
validates :keywords, length: { maximum: 20 }
159159
validate :allowed_url
160+
validates :origin_uri, url: { allow_blank: true }
161+
160162
clean_array_fields(:keywords, :fields, :event_types, :target_audience,
161163
:eligibility, :host_institutions, :sponsors)
162164
update_suggestions(:keywords, :target_audience, :host_institutions)

app/models/material.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ class Material < ApplicationRecord
123123
validates :url, url: true
124124
validates :other_types, presence: true, if: proc { |m| m.resource_type.include?('other') }
125125
validates :keywords, length: { maximum: 20 }
126+
validates :origin_uri, url: { allow_blank: true }
126127

127128
clean_array_fields(:keywords, :fields,
128129
:target_audience, :resource_type, :subsets)

app/views/common/_origin_info.erb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<% unless resource.origin_uri.blank? %>
2+
<h4 class="nav-heading"><%= t('exchange.title') %></h4>
3+
<div class="nav-block" id="origin-info">
4+
<p>
5+
<%= t('exchange.info', resource_type: resource.model_name.human) %>
6+
</p>
7+
8+
<p>
9+
<%= external_link_button t('exchange.link'), resource.origin_uri %>
10+
</p>
11+
</div>
12+
<% end %>

app/views/events/_event.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<% end %>
2020

2121
<%= event_status_icon(event) %>
22+
<%= exchange_icon(event) %>
2223
</div>
2324
<% if event.event_types.any? %>
2425
<% event.event_types.each do |t| %>

app/views/events/show.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<div class="wrapper collapsing-wrapper">
22
<%# SIDEBAR %>
33
<div class="collapsing-sidebar" id="sidebar">
4+
<%= render partial: 'common/origin_info', locals: { resource: @event } %>
45
<%= render partial: 'content_providers/partials/content_provider_info', locals: { content_provider: @event.content_provider } %>
56
<%= render partial: "nodes/partials/associated_node_info", locals: { associated_nodes: @event.associated_nodes } %>
67
<%= render(partial: 'users/partials/user_info', locals: { user: @event.user }) if current_user.try(:is_admin?) %>

0 commit comments

Comments
 (0)