Skip to content

Commit

Permalink
Fixes #25712 - Remove org_loc_string helper
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrisker committed Dec 17, 2018
1 parent 83ad48b commit 5bc5afd
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
4 changes: 0 additions & 4 deletions app/helpers/taxonomy_helper.rb
Expand Up @@ -163,8 +163,4 @@ def translated_label(resource, verb)
}
labels[resource][verb]
end

def org_loc_string(conjunction)
Taxonomy.enabled_taxonomies.map { |tax| _(tax) }.join(" #{conjunction} ")
end
end
3 changes: 1 addition & 2 deletions app/models/concerns/authorizable.rb
Expand Up @@ -10,8 +10,7 @@ def check_permissions_after_save

Foreman::Logging.logger('permissions').debug { "verifying the transaction by permission #{name} for class #{self.class}" }
unless authorizer.can?(name, self, false)
org_loc_string = Taxonomy.enabled_taxonomies.map { |tax| _(tax) }.join(' ' + _('or') + ' ')
errors.add :base, _("You don't have permission %{name} with attributes that you have specified or you don't have access to specified %{tax_string}") % { :name => name, :tax_string => org_loc_string }
errors.add :base, _("You don't have permission %{name} with attributes that you have specified or you don't have access to specified organizations or locations") % { :name => name }

# This is required in case the rollback happend, the instance must look like new record so that all url helpers work correctly. Rails don't rollback these attributes.
if creation
Expand Down
4 changes: 2 additions & 2 deletions app/views/filters/_form.html.erb
Expand Up @@ -45,13 +45,13 @@

<div id="override_taxonomy_form" class="<%= f.object.allows_taxonomies_filtering? && Taxonomy.enabled_taxonomies.any? ? '' : 'hidden' %>">
<%= checkbox_f f, :override?,
:label_help => (_("Filters inherit %{orgs_and_locs} associated with the role by default. If override field is enabled, <br> the filter can override the set of its %{orgs_and_locs}. Later role changes will not affect such filter.<br> After disabling the override field, the role %{orgs_and_locs} apply again.") % { :orgs_and_locs => org_loc_string('and') }).html_safe,
:label_help => _("Filters inherit organizations and locations associated with the role by default. If override field is enabled, <br> the filter can override the set of its organizations and locations. Later role changes will not affect such filter.<br> After disabling the override field, the role organizations and locations apply again.").html_safe,
:id => 'override_taxonomy_checkbox' %>
</div>

<div id="granular_form" style="<%= f.object.granular? ? '' : 'display:none' %>">
<%= checkbox_f f, :unlimited?,
:label_help => (_("If the unlimited field is enabled, the filter applies to all resources of the selected type. If the unlimited </br> field is disabled, you can specify further filtering using Foreman search syntax in the search field.</br> If the role is associated with %s, the filters are not considered unlimited</br> as they are scoped accordingly.") % org_loc_string('or')).html_safe %>
:label_help => _("If the unlimited field is enabled, the filter applies to all resources of the selected type. If the unlimited </br> field is disabled, you can specify further filtering using Foreman search syntax in the search field.</br> If the role is associated with organizations or locations, the filters are not considered unlimited</br> as they are scoped accordingly.").html_safe %>
<%= autocomplete_f f, :search,
Expand Down
4 changes: 2 additions & 2 deletions app/views/roles/_form.html.erb
Expand Up @@ -11,15 +11,15 @@
<div class="tab-content">
<div class="tab-pane active" id="primary">
<% if @role.persisted? && (show_location_tab? || show_organization_tab?) %>
<h5><%= _("Changes to %s will propagate to all inheriting filters") % org_loc_string(_('and')) %></h5>
<h5><%= _("Changes to organizations and locations will propagate to all inheriting filters") %></h5>
<% divider = '<hr>'.html_safe %>
<% end %>
<% if @role.cloned_from_id.present? && User.current.can?(:view_roles, @role.cloned_from) %>
<h5><%= _("This role has been cloned from role %s").html_safe % link_to(@role.cloned_from.name, edit_role_path(@role.cloned_from)) %></h5>
<% divider = '<hr>'.html_safe %>
<% end %>
<%= divider %>
<%= text_f f, :name, :class => @role.builtin? ? "disabled" : "" %>
Expand Down

0 comments on commit 5bc5afd

Please sign in to comment.