forked from decidim/decidim
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add create authorization to initiative types (decidim#9309)
* first version * fix i18n * linter * linter * fix permissions fix test * fix tests add button when initiative type doesn't need an authorisation but initiative does * lint * lint * change requests * refactor * linter * Improve spec Fix not authorized modal when choosing initiative type * linter * linter * add refresh when needed * Update decidim-initiatives/spec/system/create_initiative_spec.rb Co-authored-by: Antti Hukkanen <[email protected]> * Update decidim-initiatives/spec/system/create_initiative_spec.rb Co-authored-by: Antti Hukkanen <[email protected]> * Update decidim-initiatives/spec/system/create_initiative_spec.rb Co-authored-by: Antti Hukkanen <[email protected]> * Update decidim-initiatives/spec/system/create_initiative_spec.rb Co-authored-by: Antti Hukkanen <[email protected]> * Update decidim-initiatives/spec/system/create_initiative_spec.rb Co-authored-by: Antti Hukkanen <[email protected]> * Update decidim-initiatives/spec/system/create_initiative_spec.rb Co-authored-by: Antti Hukkanen <[email protected]> * refactor modal in partial * linter Co-authored-by: Antti Hukkanen <[email protected]>
- Loading branch information
Showing
14 changed files
with
437 additions
and
113 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
25 changes: 25 additions & 0 deletions
25
...initiatives/app/controllers/decidim/initiatives/authorization_create_modals_controller.rb
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,25 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module Initiatives | ||
class AuthorizationCreateModalsController < Decidim::Initiatives::ApplicationController | ||
helper_method :authorizations, :authorize_action_path | ||
layout false | ||
|
||
def show | ||
@initiative_type = Decidim::InitiativesType.find_by(id: params[:slug]) | ||
render template: "decidim/authorization_modals/show" | ||
end | ||
|
||
private | ||
|
||
def authorize_action_path(handler_name) | ||
authorizations.status_for(handler_name).current_path(redirect_url: URI(request.referer).path) | ||
end | ||
|
||
def authorizations | ||
@authorizations ||= action_authorized_to("create", permissions_holder: @initiative_type) | ||
end | ||
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
19 changes: 19 additions & 0 deletions
19
decidim-initiatives/app/views/decidim/initiatives/_modal.html.erb
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,19 @@ | ||
<div class="reveal not-authorized-reveal" id="not-authorized-modal" aria-hidden="true" role="dialog" aria-modal="true" aria-labelledby="not-authorized-modal-title" data-reveal data-multiple-opened="true"> | ||
<div class="reveal__header"> | ||
<h2 class="reveal__title" id="not-authorized-modal-title"><%= t(".not_authorized.title") %></h2> | ||
<button class="close-button" data-close aria-label="<%= t(".not_authorized.close") %>" | ||
type="button"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<div class="not-authhorized-content"> | ||
<div class="not-authorized-modal-content"> | ||
<p> | ||
<%= t(".not_authorized.explanation") %> | ||
</p> | ||
</div> | ||
</div> | ||
<div class="not-authorized-modal-footer reveal__footer"> | ||
<%= link_to t(".not_authorized.authorizations_page"), decidim_verifications.authorizations_path(redirect_url: create_initiative_url(:select_initiative_type)), class: "button expanded" %> | ||
</div> | ||
</div> |
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
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
Oops, something went wrong.