Skip to content

Commit

Permalink
add share_tokens menu
Browse files Browse the repository at this point in the history
  • Loading branch information
antopalidi committed Sep 4, 2024
1 parent b896f86 commit 86ea930
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion decidim-admin/app/forms/decidim/admin/share_token_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def user
private

def token_uniqueness
return unless Decidim::ShareToken.where(organization:, token_for:, token:).where.not(id:).any?
return unless Decidim::ShareToken.where(organization: organization, token_for: token_for, token: token).where.not(id: id).any?

errors.add(:token, :taken)
end
Expand Down
6 changes: 6 additions & 0 deletions decidim-assemblies/lib/decidim/assemblies/admin_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ class AdminEngine < ::Rails::Engine
decidim_admin_assemblies.moderations_path(current_participatory_space),
if: allowed_to?(:read, :moderation, assembly: current_participatory_space),
active: is_active_link?(decidim_admin_assemblies.moderations_path(current_participatory_space))

menu.add_item :assembly_share_tokens,
I18n.t("menu.share_tokens", scope: "decidim.admin"),
decidim_admin_assemblies.assembly_share_tokens_path(current_assembly),
active: is_active_link?(decidim_admin_assemblies.assembly_share_tokens_path(current_participatory_space)),
if: allowed_to?(:read, :share_tokens, current_participatory_space: current_participatory_space)
end
end
initializer "decidim_assemblies.admin_assemblies_menu" do
Expand Down
6 changes: 6 additions & 0 deletions decidim-conferences/lib/decidim/conferences/admin_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ class AdminEngine < ::Rails::Engine
decidim_admin_conferences.moderations_path(current_participatory_space),
if: allowed_to?(:read, :moderation, conference: current_participatory_space),
active: is_active_link?(decidim_admin_conferences.moderations_path(current_participatory_space))

menu.add_item :conference_share_tokens,
I18n.t("menu.share_tokens", scope: "decidim.admin"),
decidim_admin_conferences.conference_share_tokens_path(current_participatory_space),
active: is_active_link?(decidim_admin_conferences.conference_share_tokens_path(current_participatory_space)),
if: allowed_to?(:read, :share_tokens, current_participatory_space: current_participatory_space)
end
end

Expand Down
6 changes: 6 additions & 0 deletions decidim-initiatives/lib/decidim/initiatives/admin_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ class AdminEngine < ::Rails::Engine
decidim_admin_initiatives.moderations_path(current_participatory_space),
active: is_active_link?(decidim_admin_initiatives.moderations_path(current_participatory_space)),
if: allowed_to?(:read, :moderation)

menu.add_item :initiatives_share_tokens,
I18n.t("menu.share_tokens", scope: "decidim.admin"),
decidim_admin_initiatives.initiative_share_tokens_path(current_participatory_space),
active: is_active_link?(decidim_admin_initiatives.initiative_share_tokens_path(current_participatory_space)),
if: allowed_to?(:read, :share_tokens, initiative: current_participatory_space)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def org_admin_action?
end

def user_can_preview_space?
return allow! if context[:share_token].present? && Decidim::ShareToken.use!(token_for: process, token: context[:share_token], user:)
return allow! if context[:share_token].present? && Decidim::ShareToken.use!(token_for: process, token: context[:share_token], user: user)
rescue ActiveRecord::RecordNotFound, StandardError
nil
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,12 @@ class AdminEngine < ::Rails::Engine
decidim_admin_participatory_processes.moderations_path(current_participatory_space),
active: is_active_link?(decidim_admin_participatory_processes.moderations_path(current_participatory_space)),
if: allowed_to?(:read, :moderation)

menu.add_item :participatory_process_share_tokens,
I18n.t("menu.share_tokens", scope: "decidim.admin"),
decidim_admin_participatory_processes.participatory_process_share_tokens_path(current_participatory_space),
active: is_active_link?(decidim_admin_participatory_processes.participatory_process_share_tokens_path(current_participatory_space)),
if: allowed_to?(:read, :share_tokens, current_participatory_space: current_participatory_space)
end
end

Expand Down

0 comments on commit 86ea930

Please sign in to comment.