-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enforce original locale in amendments
- Loading branch information
1 parent
13d4234
commit dbdbad1
Showing
7 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
module AmendmentsEnforceLocale | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
# rubocop:disable Rails/LexicallyScopedActionFilter | ||
before_action :enforce_locale, only: [:new, :create] | ||
# rubocop:enable Rails/LexicallyScopedActionFilter | ||
|
||
def enforce_locale | ||
return unless amendable.component.settings.try(:amendments_enabled) | ||
return unless amendable.component.current_settings.try(:amendment_creation_enabled) | ||
return unless Rails.application.secrets.enforce_original_amendments_locale | ||
|
||
amendable_locale = amendable.title.keys.first | ||
return if locale.to_s == amendable_locale | ||
|
||
# flash[:alert] = t("pending_limit_reached", scope: "decidim.decidim_awesome.amendments", emendation: translated_attribute(emendation.title)) | ||
flash[:alert] = t("gpc.amendments.enforced_locale", locale: amendable_locale) | ||
redirect_to new_amend_path(amendable_gid: amendable_gid, locale: amendable.title.keys.first) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters