Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add multiple statuses on proposals (#12052)
* Add initial db structure * Add build method * Add proposal state model + admin presenter * Add proposal_state factory * Add admin interface for proposal states * Misc changes * Fix proposal status * Running linters * Fix failing Specs (#285) * Implement custom answers * Fix proposal fields * Fix the admin status badges * Fix migration script * Add notifiable and anwerable to the proposal states * Deprecating proposals old classes * Migrate frontend classes * Refactor seeds * Fix frontend * Fix more tests * Remove obsolete specs * Running linters * More linting * Fix specs * Fixing the proposals specs * Implement templates * Fixing decidim-templates specs * Remove unused i18n * Fixing more specs * Normalize I18n * reverting helper methods * Add proposal states tests * Run linter * Add release notes * Fix the frontend filters * Lint * Fixing test * Adjust labels * Revert proposal related changes * Fix small issues * Running linters * Update decidim-core/app/cells/decidim/amendable/announcement_cell.rb * Add token validation * Lint * Fix tests * Fix uniquess validator * Refactor commands * fix the specs on refactor * Removed description field * Remove boolean fields * Fix description related errors * Fix some tests * Fix more specs * Fix answerable in proposal answer * Fix migration * Rename migrations * Fix failing specs * Fix failing specs * Fix more specs * Fixing specs * Remove token input * Autogenerate the token * removing default state of not_answered * Remove bangs * Fixing the specs * Fix failing specs ... * Fix the state vs Status * Apply latest changes requested * Normalize locales * Apply suggestions from code review Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com> * Apply suggestions from code review * Running linters, apply latest suggestions * Update index.html.erb * Fix failing specs * Running linters * Running linters * Patch factory * Apply Code Review Recommendations --------- Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com>
- Loading branch information
1 parent
c958a77
commit 93ec316
Showing
97 changed files
with
1,610 additions
and
719 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
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
15 changes: 15 additions & 0 deletions
15
decidim-proposals/app/commands/decidim/proposals/admin/create_proposal_state.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,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module Proposals | ||
module Admin | ||
class CreateProposalState < Decidim::Commands::CreateResource | ||
fetch_form_attributes :title, :css_class, :announcement_title, :component | ||
|
||
def resource_class | ||
Decidim::Proposals::ProposalState | ||
end | ||
end | ||
end | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
decidim-proposals/app/commands/decidim/proposals/admin/destroy_proposal_state.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,10 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module Proposals | ||
module Admin | ||
class DestroyProposalState < Decidim::Commands::DestroyResource | ||
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
13 changes: 13 additions & 0 deletions
13
decidim-proposals/app/commands/decidim/proposals/admin/update_proposal_state.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,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module Proposals | ||
module Admin | ||
class UpdateProposalState < Decidim::Commands::UpdateResource | ||
include TranslatableAttributes | ||
|
||
fetch_form_attributes :title, :css_class, :announcement_title, :component | ||
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
86 changes: 86 additions & 0 deletions
86
decidim-proposals/app/controllers/decidim/proposals/admin/proposal_states_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,86 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module Proposals | ||
module Admin | ||
class ProposalStatesController < Admin::ApplicationController | ||
include Decidim::Admin::Paginable | ||
|
||
helper_method :proposal_states, :proposal_state | ||
def index | ||
enforce_permission_to :read, :proposal_state | ||
end | ||
|
||
def new | ||
enforce_permission_to :create, :proposal_state | ||
@form = form(Decidim::Proposals::Admin::ProposalStateForm).instance | ||
end | ||
|
||
def create | ||
enforce_permission_to :create, :proposal_state | ||
|
||
@form = form(ProposalStateForm).from_params(params) | ||
|
||
CreateProposalState.call(@form) do | ||
on(:ok) do | ||
flash[:notice] = I18n.t("proposal_states.create.success", scope: "decidim.proposals.admin") | ||
redirect_to proposal_states_path | ||
end | ||
|
||
on(:invalid) do | ||
flash.keep[:alert] = I18n.t("proposal_states.create.error", scope: "decidim.proposals.admin") | ||
|
||
render action: :new | ||
end | ||
end | ||
end | ||
|
||
def edit | ||
enforce_permission_to(:update, :proposal_state, proposal_state:) | ||
@form = form(Decidim::Proposals::Admin::ProposalStateForm).from_model(proposal_state) | ||
end | ||
|
||
def update | ||
enforce_permission_to(:update, :proposal_state, proposal_state:) | ||
@form = form(ProposalStateForm).from_params(params) | ||
|
||
UpdateProposalState.call(@form, proposal_state) do | ||
on(:ok) do | ||
flash[:notice] = I18n.t("proposal_states.update.success", scope: "decidim.proposals.admin") | ||
|
||
redirect_to proposal_states_path | ||
end | ||
|
||
on(:invalid) do | ||
flash.now[:alert] = I18n.t("proposal_states.update.error", scope: "decidim.proposals.admin") | ||
|
||
render action: :edit | ||
end | ||
end | ||
end | ||
|
||
def destroy | ||
enforce_permission_to(:destroy, :proposal_state, proposal_state:) | ||
|
||
DestroyProposalState.call(proposal_state, current_user) do | ||
on(:ok) do | ||
flash[:notice] = I18n.t("proposal_states.destroy.success", scope: "decidim.proposals.admin") | ||
|
||
redirect_to proposal_states_path | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def proposal_state | ||
@proposal_state ||= proposal_states.find(params[:id]) | ||
end | ||
|
||
def proposal_states | ||
@proposal_states ||= paginate(ProposalState.where(component: current_component)) | ||
end | ||
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
17 changes: 0 additions & 17 deletions
17
decidim-proposals/app/events/decidim/proposals/accepted_proposal_event.rb
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.