Class: Decidim::AmendmentsController
Constant Summary
Decidim::AmendmentsHelper::TOTAL_STEPS
Instance Method Summary
collapse
#add_body_classes, #cell, #edit_link, #extra_admin_link, #html_truncate, #present, #prevent_timeout_seconds, #resolve_presenter_class, #text_initials
#cache
#accept_and_reject_buttons_for, #action_button_card_for, #allowed_to_accept_and_reject?, #allowed_to_promote?, #amendments_enabled?, #amendments_form_field_for, #amendments_form_fields_label, #amendments_form_fields_value, #can_participate_in_private_space?, #can_react_to_emendation?, #current_step, #emendation_actions_for, #emendation_announcement_for, #promote_button_for, #render_emendation_body, #total_steps, #wizard_aside_back_url, #wizard_header_title
included, #text_editor_for
#floating_help
#has_visible_scopes?, #scope_name_for_picker, #scopes_picker_field, #scopes_picker_filter, #scopes_select_field, #scopes_select_tag
#default_locale?
#areas_for_select, #base_error_messages, #decidim_form_for, #decidim_form_slug_url, #editor_field_tag, #form_field_has_error?, #form_required_explanation, #name_with_locale, #ordered_scopes_descendants, #ordered_scopes_descendants_for_select, #scopes_picker_field_tag, #tab_element_class_for, #translated_field_tag
#normalize_provider_name, #oauth_icon, #provider_name
#store_share_token
#check_user_block_status, #check_user_not_blocked
#snippets
#disable_http_caching
#skip_store_location?, #store_current_location
register_permissions
enhance_controller, extended, included
Instance Method Details
#accept ⇒ Object
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
# File 'decidim-core/app/controllers/decidim/amendments_controller.rb', line 151
def accept
enforce_permission_to :accept, :amendment, current_component: amendable.component
@form = form(Decidim::Amendable::ReviewForm).from_params(params)
Decidim::Amendable::Accept.call(@form) do
on(:ok) do |emendation|
flash[:notice] = t("accepted.success", scope: "decidim.amendments")
redirect_to Decidim::ResourceLocatorPresenter.new(emendation).path
end
on(:invalid) do
flash.now[:alert] = t("accepted.error", scope: "decidim.amendments")
render :review
end
end
end
|
#create ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'decidim-core/app/controllers/decidim/amendments_controller.rb', line 29
def create
enforce_permission_to :create, :amendment, current_component: amendable.component
@form = form(Decidim::Amendable::CreateForm).from_params(params)
Decidim::Amendable::CreateDraft.call(@form) do
on(:ok) do |amendment|
flash[:notice] = t("created.success", scope: "decidim.amendments")
redirect_to preview_draft_amend_path(amendment)
end
on(:invalid) do
flash.now[:alert] = t("created.error", scope: "decidim.amendments")
render :new
end
end
end
|
#destroy_draft ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'decidim-core/app/controllers/decidim/amendments_controller.rb', line 71
def destroy_draft
enforce_permission_to :create, :amendment, current_component: amendable.component
Decidim::Amendable::DestroyDraft.call(amendment, current_user) do
on(:ok) do |amendable|
flash[:notice] = t("success", scope: "decidim.amendments.destroy_draft")
redirect_to new_amend_path(amendable_gid: amendable.to_sgid.to_s)
end
on(:invalid) do
flash[:alert] = t("error", scope: "decidim.amendments.destroy_draft")
redirect_to edit_draft_amend_path(amendment)
end
end
end
|
#edit_draft ⇒ Object
47
48
49
50
51
|
# File 'decidim-core/app/controllers/decidim/amendments_controller.rb', line 47
def edit_draft
enforce_permission_to :create, :amendment, current_component: amendable.component
@form = form(Decidim::Amendable::EditForm).from_model(amendment)
end
|
#new ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'decidim-core/app/controllers/decidim/amendments_controller.rb', line 15
def new
raise ActionController::RoutingError, "Not Found" unless amendable
enforce_permission_to :create, :amendment, current_component: amendable.component
amendment_draft = amendable.amendments.find_by(amender: current_user.id, state: "draft")
if amendment_draft
redirect_to edit_draft_amend_path(amendment_draft)
else
@form = form(Decidim::Amendable::CreateForm).from_params(params)
end
end
|
#preview_draft ⇒ Object
87
88
89
|
# File 'decidim-core/app/controllers/decidim/amendments_controller.rb', line 87
def preview_draft
enforce_permission_to :create, :amendment, current_component: amendable.component
end
|
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'decidim-core/app/controllers/decidim/amendments_controller.rb', line 127
def promote
enforce_permission_to :promote, :amendment, current_component: amendable.component
@form = form(Decidim::Amendable::PromoteForm).from_model(amendment)
Decidim::Amendable::Promote.call(@form) do
on(:ok) do |promoted_resource|
flash[:notice] = I18n.t("promoted.success", scope: "decidim.amendments")
redirect_to Decidim::ResourceLocatorPresenter.new(promoted_resource).path
end
on(:invalid) do
flash.now[:alert] = t("promoted.error", scope: "decidim.amendments")
redirect_to Decidim::ResourceLocatorPresenter.new(emendation).path
end
end
end
|
#publish_draft ⇒ Object
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'decidim-core/app/controllers/decidim/amendments_controller.rb', line 91
def publish_draft
enforce_permission_to :create, :amendment, current_component: amendable.component
@form = form(Decidim::Amendable::PublishForm).from_model(amendment)
Decidim::Amendable::PublishDraft.call(@form) do
on(:ok) do |emendation|
flash[:notice] = t("success", scope: "decidim.amendments.publish_draft")
redirect_to Decidim::ResourceLocatorPresenter.new(emendation).path
end
on(:invalid) do
flash.now[:alert] = t("error", scope: "decidim.amendments.publish_draft")
render :edit_draft
end
end
end
|
#reject ⇒ Object
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'decidim-core/app/controllers/decidim/amendments_controller.rb', line 109
def reject
enforce_permission_to :reject, :amendment, current_component: amendable.component
@form = form(Decidim::Amendable::RejectForm).from_model(amendment)
Decidim::Amendable::Reject.call(@form) do
on(:ok) do
flash[:notice] = t("rejected.success", scope: "decidim.amendments")
end
on(:invalid) do
flash[:alert] = t("rejected.error", scope: "decidim.amendments")
end
redirect_to Decidim::ResourceLocatorPresenter.new(emendation).path
end
end
|
#review ⇒ Object
145
146
147
148
149
|
# File 'decidim-core/app/controllers/decidim/amendments_controller.rb', line 145
def review
enforce_permission_to :accept, :amendment, current_component: amendable.component
@form = form(Decidim::Amendable::ReviewForm).from_params(params)
end
|
#update_draft ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'decidim-core/app/controllers/decidim/amendments_controller.rb', line 53
def update_draft
enforce_permission_to :create, :amendment, current_component: amendable.component
@form = form(Decidim::Amendable::EditForm).from_params(params)
Decidim::Amendable::UpdateDraft.call(@form) do
on(:ok) do |amendment|
flash[:notice] = t("success", scope: "decidim.amendments.update_draft")
redirect_to preview_draft_amend_path(amendment)
end
on(:invalid) do
flash.now[:alert] = t("error", scope: "decidim.amendments.update_draft")
render :edit_draft
end
end
end
|
#withdraw ⇒ Object
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
# File 'decidim-core/app/controllers/decidim/amendments_controller.rb', line 169
def withdraw
enforce_permission_to :withdraw, :amendment, amendment:, current_component: amendable.component
Decidim::Amendable::Withdraw.call(amendment, current_user) do
on(:ok) do |withdrawn_emendation|
flash[:notice] = t("success", scope: "decidim.amendments.withdraw")
redirect_to Decidim::ResourceLocatorPresenter.new(withdrawn_emendation).path
end
on(:invalid) do
flash[:alert] = t("error", scope: "decidim.amendments.withdraw")
redirect_to Decidim::ResourceLocatorPresenter.new(emendation).path
end
end
end
|