Skip to content

Commit

Permalink
🎁 Mobius gets mobius specific work type
Browse files Browse the repository at this point in the history
This commit will add logic for mobius tenants to get the mobius specific
work type and non-mobius tenants to get all work types minus the mobius
work type.
  • Loading branch information
kirkkwang committed Mar 16, 2024
1 parent 45edc0b commit 1e0c5a4
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 1 deletion.
7 changes: 7 additions & 0 deletions app/helpers/hyku_knapsack/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@

module HykuKnapsack
module ApplicationHelper
def tenant_registered_curation_concern_types
if current_account.mobius?
MOBIUS_CONCERNS
else
Hyrax.config.registered_curation_concern_types - MOBIUS_CONCERNS
end
end
end
end
29 changes: 29 additions & 0 deletions app/models/account_decorator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

module AccountDecorator
MOBIUS_TENANTS = %w[
atsu
ccis
covenant
crowder
eastcentral
jewell
kenrick
mbts
mobap
mobius-search
moval
mssu
nwmsu
sbuniv
stlcc
truman
webster
].freeze

def mobius?
name.in?(MOBIUS_TENANTS)
end
end

Account.prepend(AccountDecorator)
20 changes: 20 additions & 0 deletions app/models/site_decorator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

# OVERRIDE Hyku to set tenants with appropriate works

module SiteDecorator
def instance
return NilSite.instance if Account.global_tenant?

first_or_create do |site|
account = Account.find_by(tenant: Apartment::Tenant.current)
if account.mobius?
site.available_works = MOBIUS_CONCERNS
else
site.available_works = Hyrax.config.registered_curation_concern_types - MOBIUS_CONCERNS
end
end
end
end

Site.singleton_class.send(:prepend, SiteDecorator)
19 changes: 19 additions & 0 deletions app/views/admin/work_types/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<% provide :page_header do %>
<h1><span class="fa fa-address-book"></span> <%= t('hyku.admin.work_types') %></h1>
<% end %>

<div class="card">
<div class="card-body">
<%= simple_form_for @site, url: '/admin/work_types' do |f| %>
<% tenant_registered_curation_concern_types.each do |type| %>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="<%= type %>" id="input-<%= type %>" name="available_works[]" <%= 'checked' if @site.available_works&.include?(type) %>>
<label class="form-check-label" for="input-<%= type %>">
<%= type %>
</label>
</div>
<% end %>
<%= f.submit class: 'btn btn-primary' %>
<% end %>
</div>
</div>
4 changes: 3 additions & 1 deletion config/initializers/hyrax.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
MOBIUS_CONCERNS = ['MobiusWork'].freeze

Hyrax.config do |config|
config.register_curation_concern :mobius_work
config.register_curation_concern MOBIUS_CONCERNS.map { |concern| concern.underscore.to_sym }
end

0 comments on commit 1e0c5a4

Please sign in to comment.