Class: Decidim::Admin::AreaTypesController
Overview
Controller that allows managing areatypes to group areas
Instance Method Summary
collapse
#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path
Instance Method Details
#create ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'app/controllers/decidim/admin/area_types_controller.rb', line 20
def create
enforce_permission_to :create, :area_type
@form = form(AreaTypeForm).from_params(params)
CreateAreaType.call(@form, current_user) do
on(:ok) do
flash[:notice] = I18n.t("area_types.create.success", scope: "decidim.admin")
redirect_to area_types_path
end
on(:invalid) do
flash.now[:alert] = I18n.t("area_types.create.error", scope: "decidim.admin")
render :new
end
end
end
|
#destroy ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
|
# File 'app/controllers/decidim/admin/area_types_controller.rb', line 59
def destroy
enforce_permission_to :destroy, :area_type, area_type: area_type
Decidim.traceability.perform_action!("delete", area_type, current_user) do
area_type.destroy!
end
flash[:notice] = I18n.t("area_types.destroy.success", scope: "decidim.admin")
redirect_to area_types_path
end
|
#edit ⇒ Object
37
38
39
40
|
# File 'app/controllers/decidim/admin/area_types_controller.rb', line 37
def edit
enforce_permission_to :update, :area_type, area_type: area_type
@form = form(AreaTypeForm).from_model(area_type)
end
|
#index ⇒ Object
11
12
13
|
# File 'app/controllers/decidim/admin/area_types_controller.rb', line 11
def index
enforce_permission_to :read, :area_type
end
|
#new ⇒ Object
15
16
17
18
|
# File 'app/controllers/decidim/admin/area_types_controller.rb', line 15
def new
enforce_permission_to :create, :area_type
@form = form(AreaTypeForm).instance
end
|
#update ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'app/controllers/decidim/admin/area_types_controller.rb', line 42
def update
enforce_permission_to :update, :area_type, area_type: area_type
@form = form(AreaTypeForm).from_params(params)
UpdateAreaType.call(area_type, @form, current_user) do
on(:ok) do
flash[:notice] = I18n.t("area_types.update.success", scope: "decidim.admin")
redirect_to area_types_path
end
on(:invalid) do
flash.now[:alert] = I18n.t("area_types.update.error", scope: "decidim.admin")
render :edit
end
end
end
|