Skip to content

Commit a85df3d

Browse files
committed
refactor(feature_enabled()): changed at best all TeSS::Config.feature
1 parent 5a5f93c commit a85df3d

26 files changed

Lines changed: 51 additions & 51 deletions

app/controllers/application_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def feature_enabled?(feature)
103103
helper_method :feature_enabled?
104104

105105
def ensure_feature_enabled(feature = controller_name)
106-
if TeSS::Config.feature.key?(feature) && !TeSS::Config.feature[feature]
106+
if TeSS::Config.feature.key?(feature) && !feature_enabled?(feature)
107107
raise ActionController::RoutingError.new('Feature not enabled')
108108
end
109109
end
@@ -114,7 +114,7 @@ def user_not_authorized(exception)
114114
end
115115

116116
def set_current_space
117-
Space.current_space = TeSS::Config.feature['spaces'] ? Space.find_by_host(request.host) : Space.default
117+
Space.current_space = feature_enabled?('spaces') ? Space.find_by_host(request.host) : Space.default
118118
end
119119

120120
def current_space

app/controllers/collections_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ def collection_params
137137
def item_class
138138
case params[:type]
139139
when 'Event'
140-
return Event if TeSS::Config.feature['events']
140+
return Event if feature_enabled?('events')
141141
when 'Material'
142-
return Material if TeSS::Config.feature['materials']
142+
return Material if feature_enabled?('materials')
143143
end
144144

145145
raise ActionController::RoutingError.new('Unrecognized type')

app/helpers/sources_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def source_approval_badge(status)
3636
end
3737

3838
def user_creatable_ingestion_methods
39-
return [] unless TeSS::Config.feature['sources'] &&
40-
TeSS::Config.feature['user_source_creation'] &&
39+
return [] unless feature_enabled?('sources') &&
40+
feature_enabled?('user_source_creation') &&
4141
TeSS::Config.user_ingestion_methods&.any?
4242

4343
TeSS::Config.user_ingestion_methods.map do |key|

app/views/about/tess.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
<% end %>
124124

125125
<!-- SUBSCRIBE-->
126-
<% if TeSS::Config.feature['subscription'] %>
126+
<% if feature_enabled?('subscription') %>
127127
<div id="subscribe" class="<%= next_about_block(@feature_count += 1) %>">
128128
<h3><%= t('about.headings.subscribe') %></h3>
129129
<p><%== t 'about.subscribe' %></p>

app/views/collections/show.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<% if policy(@collection).manage? %>
1111
<%= render partial: 'collaborations/collaborators_button', locals: { resource: @collection } %>
1212
<% end %>
13-
<% if TeSS::Config.feature['collection_curation'] && current_user && policy(@collection).curate? %>
13+
<% if feature_enabled?('collection_curation') && current_user && policy(@collection).curate? %>
1414
<% if feature_enabled?('events') %>
1515
<%= link_to t('.curate_events', default: [:'helpers.links.events', 'events']),
1616
curate_events_collection_path(@collection), class: 'btn btn-default' %>

app/views/content_providers/partials/_content_provider_sidebar.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<% unless TeSS::Config.feature['content_providers_disabled'].include?('type') %>
1+
<% unless feature_enabled?('content_providers_disabled').include?('type') %>
22
<h4 class="nav-heading">Type</h4>
33
<div class="nav-block">
44
<%= content_provider.content_provider_type %>
55
</div>
66
<% end %>
7-
<% unless content_provider.keywords.blank? || TeSS::Config.feature['content_providers_disabled'].include?('keywords') %>
7+
<% unless content_provider.keywords.blank? || feature_enabled?('content_providers_disabled').include?('keywords') %>
88
<h4 class="nav-heading">Keywords</h4>
99
<div class="nav-block">
1010
<%= content_provider.keywords.join(', ') %>

app/views/content_providers/show.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
count: not_finished_events_count.zero? && events_count.positive? ? '0*' : not_finished_events_count) %>
4444
<% end %>
4545

46-
<% if TeSS::Config.feature['sources'] && policy(@content_provider).update? %>
46+
<% if feature_enabled?('sources') && policy(@content_provider).update? %>
4747
<%= tab('Sources', icon_class_for_model('sources'), 'sources', count: sources.count, activator: activator) %>
4848
<% end %>
4949
</ul>
@@ -69,7 +69,7 @@
6969
view_all_link: events_path(content_provider: @content_provider.title),
7070
inc_expired_link: events_path(content_provider: @content_provider.title, include_expired: true) } %>
7171
<% end %>
72-
<% if policy(@content_provider).update? && TeSS::Config.feature['sources'] %>
72+
<% if policy(@content_provider).update? && feature_enabled?('sources') %>
7373
<div id="sources" class="tab-pane fade<%= ' in active' if activator.check_pane('sources') %>">
7474
<% if policy(@content_provider).create_source? %>
7575
<div class="my-3">

app/views/devise/registrations/new.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="page-header">
33
<%= page_title 'Registration' %>
44
</div>
5-
<% if !TeSS::Config.feature['registration'] %>
5+
<% if !feature_enabled?('registration') %>
66
<div class="panel panel-danger">
77
<div class="panel-heading">
88
<h3 class="panel-title">Registration is currently disabled</h3>

app/views/devise/sessions/_omniauth_options.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<% Devise.omniauth_configs.each do |provider, config| -%>
33
<%= link_to(omniauth_authorize_path(resource_name, provider), method: :post,
44
class: config.options[:logo] ? '' :
5-
TeSS::Config.feature["login_through_oidc_only"] ? 'btn btn-default btn-lg btn-oidc-only' : 'btn btn-default') do %>
5+
feature_enabled?("login_through_oidc_only") ? 'btn btn-default btn-lg btn-oidc-only' : 'btn btn-default') do %>
66
<% if config.options[:logo].present? %>
77
<%= image_tag(config.options[:logo], class: "omniauth-logo omniauth-#{provider}") -%>
88
<% else %>

app/views/devise/sessions/new.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="account-form">
22
<div class="page-header">
3-
<% if !TeSS::Config.feature["login_through_oidc_only"] %>
3+
<% if !feature_enabled?("login_through_oidc_only") %>
44
<%= page_title 'Log in' %>
55
<% end %>
66
</div>
@@ -12,7 +12,7 @@
1212
<hr/>
1313
<% end %>
1414

15-
<% if TeSS::Config.feature["login_through_oidc_only"] %>
15+
<% if feature_enabled?("login_through_oidc_only") %>
1616
<dl class="faq">
1717
<div class="question">
1818
<dt>
@@ -33,7 +33,7 @@
3333
<%= f.submit t('authentication.password.log_in'), :class => 'btn btn-primary' %>
3434
</div>
3535
<% end %>
36-
<% if !TeSS::Config.feature["login_through_oidc_only"] %>
36+
<% if !feature_enabled?("login_through_oidc_only") %>
3737
<%= render "devise/shared/links" %>
3838
<% else %>
3939
</dd>

0 commit comments

Comments
 (0)