diff --git a/app/models/attachment.rb b/app/models/attachment.rb index b9272d9f0..276c082b7 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -56,7 +56,7 @@ class Attachment < ApplicationRecord # NOTE: for External services use this methods since redirect doesn't work effectively in a lot of cases def download_url - ActiveStorage::Current.host = Rails.application.routes.default_url_options[:host] if ActiveStorage::Current.host.blank? + ActiveStorage::Current.url_options = Rails.application.routes.default_url_options if ActiveStorage::Current.url_options.blank? file.attached? ? file.blob.url : '' end diff --git a/app/views/fields/belongs_to/_index.html.erb b/app/views/fields/belongs_to/_index.html.erb index 8637400ca..24b43d9c5 100644 --- a/app/views/fields/belongs_to/_index.html.erb +++ b/app/views/fields/belongs_to/_index.html.erb @@ -21,7 +21,7 @@ By default, the relationship is rendered as a link to the associated object. field.display_associated_resource, super_admin_user_path(field.data), ) %> - <% elsif valid_action?(:show, field.associated_class) %> + <% elsif existing_action?(field.associated_class, :show) %> <%= link_to( field.display_associated_resource, [namespace, field.data], diff --git a/app/views/fields/belongs_to/_show.html.erb b/app/views/fields/belongs_to/_show.html.erb index 24b47081a..5cf2c7701 100644 --- a/app/views/fields/belongs_to/_show.html.erb +++ b/app/views/fields/belongs_to/_show.html.erb @@ -16,7 +16,7 @@ By default, the relationship is rendered as a link to the associated object. %> <% if field.data %> - <% if valid_action?(:show, field.associated_class) %> + <% if existing_action?(field.associated_class, :show) %> <%= link_to( field.display_associated_resource, [namespace, field.data], diff --git a/app/views/fields/polymorphic/_show.html.erb b/app/views/fields/polymorphic/_show.html.erb index 27a5645ae..fa9e88307 100644 --- a/app/views/fields/polymorphic/_show.html.erb +++ b/app/views/fields/polymorphic/_show.html.erb @@ -17,7 +17,7 @@ By default, the relationship is rendered as a link to the associated object. %> <% if field.data %> - <% if valid_action?(:show, field.data.class) %> + <% if existing_action?(field.data.class, :show) %> <%= link_to( field.display_associated_resource, [namespace, field.data], diff --git a/app/views/super_admin/accounts/show.html.erb b/app/views/super_admin/accounts/show.html.erb index 1b37e4402..995af9ff0 100644 --- a/app/views/super_admin/accounts/show.html.erb +++ b/app/views/super_admin/accounts/show.html.erb @@ -28,7 +28,7 @@ as well as a link to its edit page. t("administrate.actions.edit_resource", name: page.page_title), [:edit, namespace, page.resource], class: "button", - ) if valid_action?(:edit) && show_action?(:edit, page.resource) %> + ) if accessible_action?(page.resource, :edit) %> diff --git a/app/views/super_admin/application/_collection.html.erb b/app/views/super_admin/application/_collection.html.erb index 3f7aa489c..89fa167d1 100644 --- a/app/views/super_admin/application/_collection.html.erb +++ b/app/views/super_admin/application/_collection.html.erb @@ -45,8 +45,8 @@ to display a collection of resources in an HTML table. <% end %> <% end %> - <% [valid_action?(:edit, collection_presenter.resource_name), - valid_action?(:destroy, collection_presenter.resource_name)].count(true).times do %> + <% [existing_action?(collection_presenter.resource_name, :edit), + existing_action?(collection_presenter.resource_name, :destroy)].count(true).times do %> <% end %> @@ -56,13 +56,13 @@ to display a collection of resources in an HTML table. <% resources.each do |resource| %> + <% if existing_action? collection_presenter.resource_name, :show %> <%= %(role=link data-url=#{polymorphic_path([namespace, resource])}) %> <% end %> > <% collection_presenter.attributes_for(resource).each do |attribute| %> - <% if show_action? :show, resource -%> + <% if authorized_action? resource, :show -%> @@ -72,22 +72,22 @@ to display a collection of resources in an HTML table. <% end %> - <% if valid_action? :edit, collection_presenter.resource_name %> + <% if existing_action? collection_presenter.resource_name, :edit %> <%= link_to( t("administrate.actions.edit"), [:edit, namespace, resource], class: "action-edit", - ) if show_action? :edit, resource%> + ) if authorized_action? resource, :edit%> <% end %> - <% if valid_action? :destroy, collection_presenter.resource_name %> + <% if existing_action? collection_presenter.resource_name, :destroy %> <%= link_to( t("administrate.actions.destroy"), [namespace, resource], class: "text-color-red", method: :delete, data: { confirm: t("administrate.actions.confirm") } - ) if show_action? :destroy, resource %> + ) if authorized_action? resource, :destroy %> <% end %> <% end %> diff --git a/app/views/super_admin/application/_navigation.html.erb b/app/views/super_admin/application/_navigation.html.erb index e09ebb277..4e2a675bc 100644 --- a/app/views/super_admin/application/_navigation.html.erb +++ b/app/views/super_admin/application/_navigation.html.erb @@ -46,7 +46,7 @@ as defined by the routes in the `admin/` namespace <%= link_to( display_resource_name(resource), resource_index_route(resource) - ) if valid_action? :index, resource %> + ) if existing_action? resource, :index %> <% end %> diff --git a/app/views/super_admin/application/index.html.erb b/app/views/super_admin/application/index.html.erb index 43a3705de..f73b3033c 100644 --- a/app/views/super_admin/application/index.html.erb +++ b/app/views/super_admin/application/index.html.erb @@ -48,7 +48,7 @@ It renders the `_table` partial to display details about the resources. ), [:new, namespace, page.resource_path.to_sym], class: "button", - ) if valid_action?(:new) && show_action?(:new, new_resource) %> + ) if accessible_action?(new_resource, :new) %> diff --git a/app/views/super_admin/users/_collection.html.erb b/app/views/super_admin/users/_collection.html.erb index f1f25987c..512624daa 100644 --- a/app/views/super_admin/users/_collection.html.erb +++ b/app/views/super_admin/users/_collection.html.erb @@ -45,8 +45,8 @@ to display a collection of resources in an HTML table. <% end %> <% end %> - <% [valid_action?(:edit, collection_presenter.resource_name), - valid_action?(:destroy, collection_presenter.resource_name)].count(true).times do %> + <% [existing_action?(collection_presenter.resource_name, :edit), + existing_action?(collection_presenter.resource_name, :destroy)].count(true).times do %> <% end %> @@ -56,13 +56,13 @@ to display a collection of resources in an HTML table. <% resources.each do |resource| %> + <% if existing_action? collection_presenter.resource_name, :show %> <%= %(role=link data-url=#{polymorphic_path([namespace, resource.becomes(User)])}) %> <% end %> > <% collection_presenter.attributes_for(resource).each do |attribute| %> - <% if show_action? :show, resource -%> + <% if authorized_action? resource, :show -%> @@ -72,22 +72,22 @@ to display a collection of resources in an HTML table. <% end %> - <% if valid_action? :edit, collection_presenter.resource_name %> + <% if existing_action? collection_presenter.resource_name, :edit %> <%= link_to( t("administrate.actions.edit"), [:edit, namespace, resource.becomes(User)], class: "action-edit", - ) if show_action? :edit, resource%> + ) if authorized_action? resource, :edit%> <% end %> - <% if valid_action? :destroy, collection_presenter.resource_name %> + <% if existing_action? collection_presenter.resource_name, :destroy %> <%= link_to( t("administrate.actions.destroy"), [namespace, resource.becomes(User)], class: "text-color-red", method: :delete, data: { confirm: t("administrate.actions.confirm") } - ) if show_action? :destroy, resource %> + ) if authorized_action? resource, :destroy %> <% end %> <% end %> diff --git a/app/views/super_admin/users/show.html.erb b/app/views/super_admin/users/show.html.erb index 15bdb0ca9..37a79b121 100644 --- a/app/views/super_admin/users/show.html.erb +++ b/app/views/super_admin/users/show.html.erb @@ -28,7 +28,7 @@ as well as a link to its edit page. t("administrate.actions.edit_resource", name: page.page_title), [:edit, namespace, page.resource], class: "button", - ) if valid_action?(:edit) && show_action?(:edit, page.resource) %> + ) if accessible_action?(:edit, page.resource) %>