Implements story #136

Adds draft state for proposals
This commit is contained in:
Juan Salvador Pérez García
2018-06-07 12:19:26 +02:00
parent 83b8127b72
commit 77dd60427d
17 changed files with 176 additions and 38 deletions

View File

@@ -35,13 +35,16 @@ class ProposalsController < ApplicationController
@proposal = Proposal.new(proposal_params.merge(author: current_user))
if @proposal.save
redirect_to share_proposal_path(@proposal), notice: I18n.t('flash.actions.create.proposal')
redirect_to created_proposal_path(@proposal), notice: I18n.t('flash.actions.create.proposal')
else
render :new
end
end
def created; end
def index_customization
discard_draft
discard_archived
load_retired
load_successful_proposals
@@ -88,6 +91,11 @@ class ProposalsController < ApplicationController
end
end
def publish
@proposal.publish
redirect_to share_proposal_path(@proposal), notice: t('proposals.notice.published')
end
private
def proposal_params
@@ -116,6 +124,10 @@ class ProposalsController < ApplicationController
@featured_proposals_votes = current_user ? current_user.proposal_votes(proposals) : {}
end
def discard_draft
@resources = @resources.published
end
def discard_archived
@resources = @resources.not_archived unless @current_order == "archival_date"
end
@@ -158,5 +170,4 @@ class ProposalsController < ApplicationController
@recommended_proposals = Proposal.recommendations(current_user).sort_by_random.limit(3)
end
end
end