Class: Decidim::Admin::ScopesController
Overview
Controller that allows managing all scopes at the admin panel.
Instance Method Summary
collapse
#current_ability_klass, #user_not_authorized_path
Instance Method Details
#create ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/controllers/decidim/admin/scopes_controller.rb', line 19
def create
authorize! :new, Scope
@form = form(ScopeForm).from_params(params)
CreateScope.call(@form) do
on(:ok) do
flash[:notice] = I18n.t("scopes.create.success", scope: "decidim.admin")
redirect_to scopes_path
end
on(:invalid) do
flash.now[:alert] = I18n.t("scopes.create.error", scope: "decidim.admin")
render :new
end
end
end
|
#destroy ⇒ Object
59
60
61
62
63
64
65
66
|
# File 'app/controllers/decidim/admin/scopes_controller.rb', line 59
def destroy
authorize! :destroy, scope
scope.destroy!
flash[:notice] = I18n.t("scopes.destroy.success", scope: "decidim.admin")
redirect_to scopes_path
end
|
#edit ⇒ Object
36
37
38
39
|
# File 'app/controllers/decidim/admin/scopes_controller.rb', line 36
def edit
authorize! :update, scope
@form = form(ScopeForm).from_model(scope)
end
|
#index ⇒ Object
9
10
11
12
|
# File 'app/controllers/decidim/admin/scopes_controller.rb', line 9
def index
authorize! :index, Scope
@scopes = collection
end
|
#new ⇒ Object
14
15
16
17
|
# File 'app/controllers/decidim/admin/scopes_controller.rb', line 14
def new
authorize! :new, Scope
@form = form(ScopeForm).instance
end
|
#update ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'app/controllers/decidim/admin/scopes_controller.rb', line 41
def update
@scope = collection.find(params[:id])
authorize! :update, scope
@form = form(ScopeForm).from_params(params)
UpdateScope.call(scope, @form) do
on(:ok) do
flash[:notice] = I18n.t("scopes.update.success", scope: "decidim.admin")
redirect_to scopes_path
end
on(:invalid) do
flash.now[:alert] = I18n.t("scopes.update.error", scope: "decidim.admin")
render :edit
end
end
end
|