app/controllers/decidim/proposals/collaborative_drafts_controller.rb in decidim-proposals-0.16.1 vs app/controllers/decidim/proposals/collaborative_drafts_controller.rb in decidim-proposals-0.17.0
- old
+ new
@@ -22,18 +22,20 @@
before_action :retrieve_collaborative_draft, only: [:show, :edit, :update, :withdraw, :publish]
def index
@collaborative_drafts = search
.results
+ .not_hidden
.includes(:category)
.includes(:scope)
@collaborative_drafts = paginate(@collaborative_drafts)
@collaborative_drafts = reorder(@collaborative_drafts)
end
def show
+ raise ActionController::RoutingError, "Not Found" unless retrieve_collaborative_draft
@report_form = form(Decidim::ReportForm).from_params(reason: "spam")
@request_access_form = form(RequestAccessToCollaborativeDraftForm).from_params({})
@accept_request_form = form(AcceptAccessToCollaborativeDraftForm).from_params({})
@reject_request_form = form(RejectAccessToCollaborativeDraftForm).from_params({})
end
@@ -94,10 +96,11 @@
def edit
enforce_permission_to :edit, :collaborative_draft, collaborative_draft: @collaborative_draft
@form = form(CollaborativeDraftForm).from_model(@collaborative_draft)
+ @form.attachment = form(AttachmentForm).from_model(@collaborative_draft.attachments.first)
end
def update
enforce_permission_to :edit, :collaborative_draft, collaborative_draft: @collaborative_draft
@@ -151,10 +154,10 @@
def collaborative_drafts_enabled?
raise ActionController::RoutingError, "Not Found" unless component_settings.collaborative_drafts_enabled?
end
def retrieve_collaborative_draft
- @collaborative_draft = CollaborativeDraft.where(component: current_component).find(params[:id])
+ @collaborative_draft = CollaborativeDraft.not_hidden.where(component: current_component).find_by(id: params[:id])
end
def geocoded_collaborative_draft
@geocoded_collaborative_draft ||= search.results.not_hidden.select(&:geocoded?)
end