Class: Decidim::Initiatives::CreateInitiativeController
Overview
Controller in charge of managing the create initiative wizard.
Instance Method Summary
collapse
#can_edit_custom_signature_end_date?, #hero_background_path, #humanize_admin_state, #metadata_badge_css_class, #render_committee_tooltip
#permission_class_chain, #permission_scope, #permissions_context
Instance Method Details
#fill_data ⇒ Object
64
65
66
67
68
69
70
71
|
# File 'app/controllers/decidim/initiatives/create_initiative_controller.rb', line 64
def fill_data
@form = if session[:initiative_id].present?
form(Decidim::Initiatives::InitiativeForm).from_model(current_initiative, { initiative_type: })
else
= { type_id: initiative_type_id, signature_type: initiative_type.signature_type }
form(Decidim::Initiatives::InitiativeForm).from_params(params.merge(), { initiative_type: })
end
end
|
#finish ⇒ Object
85
86
87
88
89
90
91
92
|
# File 'app/controllers/decidim/initiatives/create_initiative_controller.rb', line 85
def finish
current_initiative.presence
if current_initiative.validating?
session[:type_id] = nil
session[:initiative_id] = nil
end
end
|
#load_initiative_draft ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
|
# File 'app/controllers/decidim/initiatives/create_initiative_controller.rb', line 34
def load_initiative_draft
session[:initiative_id] = params[:initiative_id]
if current_initiative.validating?
redirect_to finish_create_initiative_index_path
elsif current_initiative.created?
redirect_to promotal_committee_create_initiative_index_path
else
redirect_to initiatives_path
end
end
|
81
82
83
|
# File 'app/controllers/decidim/initiatives/create_initiative_controller.rb', line 81
def promotal_committee
redirect_to finish_create_initiative_index_path unless promotal_committee_required?
end
|
#select_initiative_type ⇒ Object
46
47
48
49
50
51
|
# File 'app/controllers/decidim/initiatives/create_initiative_controller.rb', line 46
def select_initiative_type
session[:initiative_id] = nil
@form = form(Decidim::Initiatives::SelectInitiativeTypeForm).from_params(params)
redirect_to fill_data_create_initiative_index_path if single_initiative_type?
end
|
#store_data ⇒ Object
73
74
75
76
77
78
79
|
# File 'app/controllers/decidim/initiatives/create_initiative_controller.rb', line 73
def store_data
if current_initiative
store_data_update_initiative
else
store_data_create_initiative
end
end
|
#store_initiative_type ⇒ Object
53
54
55
56
57
58
59
60
61
62
|
# File 'app/controllers/decidim/initiatives/create_initiative_controller.rb', line 53
def store_initiative_type
@form = form(Decidim::Initiatives::SelectInitiativeTypeForm).from_params(params)
if @form.valid?
session[:type_id] = @form.type_id
redirect_to fill_data_create_initiative_index_path
else
render :select_initiative_type
end
end
|