Use new module_parent and module_parents methods

We were getting some deprecation warnings:

DEPRECATION WARNING: `Module#parent` has been renamed to
`module_parent`. `parent` is deprecated and will be removed in Rails
6.1.

DEPRECATION WARNING: `Module#parents` has been renamed to
`module_parents`. `parents` is deprecated and will be removed in Rails
6.1.
This commit is contained in:
Javi Martín
2021-09-18 14:01:53 +02:00
parent 7fe2309762
commit 7c8e3788ec
5 changed files with 13 additions and 13 deletions

View File

@@ -22,7 +22,7 @@
<% end %>
<% if feature?(:legislation) %>
<li class="<%= "is-active" if controller.class.parent == Admin::Legislation %>">
<li class="<%= "is-active" if controller.class.module_parent == Admin::Legislation %>">
<%= link_to t("admin.menu.legislation"), admin_legislation_processes_path, class: "legislation-link" %>
</li>
<% end %>
@@ -69,7 +69,7 @@
banners_link,
information_texts_link,
documents_link,
class: ("is-active" if customization? && controller.class.parent != Admin::Poll::Questions::Answers)
class: ("is-active" if customization? && controller.class.module_parent != Admin::Poll::Questions::Answers)
) %>
</li>

View File

@@ -4,7 +4,7 @@ class Admin::MenuComponent < ApplicationComponent
private
def moderated_content?
moderated_sections.include?(controller_name) && controller.class.parent != Admin::Legislation
moderated_sections.include?(controller_name) && controller.class.module_parent != Admin::Legislation
end
def moderated_sections
@@ -17,7 +17,7 @@ class Admin::MenuComponent < ApplicationComponent
end
def polls?
controller.class.parent == Admin::Poll::Questions::Answers ||
controller.class.module_parent == Admin::Poll::Questions::Answers ||
%w[polls active_polls recounts results questions answers].include?(controller_name) &&
action_name != "booth_assignments"
end
@@ -35,7 +35,7 @@ class Admin::MenuComponent < ApplicationComponent
controllers_names = ["settings", "tags", "geozones", "images", "content_blocks",
"local_census_records", "imports"]
controllers_names.include?(controller_name) &&
controller.class.parent != Admin::Poll::Questions::Answers
controller.class.module_parent != Admin::Poll::Questions::Answers
end
def customization?
@@ -57,7 +57,7 @@ class Admin::MenuComponent < ApplicationComponent
def local_census_records?
controller_name == "local_census_records" ||
(controller_name == "imports" && controller.class.parent == Admin::LocalCensusRecords)
(controller_name == "imports" && controller.class.module_parent == Admin::LocalCensusRecords)
end
def messages_menu_active?
@@ -69,11 +69,11 @@ class Admin::MenuComponent < ApplicationComponent
end
def sdg_managers?
controller_name == "managers" && controller.class.parent == Admin::SDG
controller_name == "managers" && controller.class.module_parent == Admin::SDG
end
def managers?
controller_name == "managers" && controller.class.parent == Admin
controller_name == "managers" && controller.class.module_parent == Admin
end
def officers_link
@@ -320,7 +320,7 @@ class Admin::MenuComponent < ApplicationComponent
[
t("admin.menu.site_customization.images"),
admin_site_customization_images_path,
controller_name == "images" && controller.class.parent != Admin::Poll::Questions::Answers
controller_name == "images" && controller.class.module_parent != Admin::Poll::Questions::Answers
]
end

View File

@@ -8,7 +8,7 @@ module TranslatableFormHelper
end
def backend_translations_enabled?
(controller.class.parents & [Admin, Management, Valuation, SDGManagement]).any?
(controller.class.module_parents & [Admin, Management, Valuation, SDGManagement]).any?
end
def highlight_translation_html_class

View File

@@ -27,7 +27,7 @@
"aria-hidden": true, class: "button hollow expanded" %>
<%= render "layouts/flash" %>
<%= render "layouts/officing_booth" if controller.class.parent == Officing && session[:booth_id].present? %>
<%= render "layouts/officing_booth" if controller.class.module_parent == Officing && session[:booth_id].present? %>
<%= yield %>
</div>
</div>

View File

@@ -22,7 +22,7 @@
<li>
<%= layout_menu_link_to t("layouts.header.poll_questions"),
polls_path,
controller_name == "polls" || (controller_name == "questions" && controller.class.parent == Polls),
controller_name == "polls" || (controller_name == "questions" && controller.class.module_parent == Polls),
accesskey: "3" %>
</li>
<% end %>
@@ -30,7 +30,7 @@
<li>
<%= layout_menu_link_to t("layouts.header.collaborative_legislation"),
legislation_processes_path,
controller.class.parent == Legislation,
controller.class.module_parent == Legislation,
accesskey: "4" %>
</li>
<% end %>