Commit de1b1171f516224a9448b36ba12bb9bc3d7e6178
1 parent
0bc6c491
Exists in
master
and in
29 other branches
ActionItem117: s/environment_admin/admin/, part 1
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@905 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
17 changed files
with
337 additions
and
337 deletions
Show diff stats
... | ... | @@ -0,0 +1,18 @@ |
1 | +class AdminPanelController < EnvironmentAdminController | |
2 | + | |
3 | + before_filter :login_required | |
4 | + | |
5 | + protect 'view_environment_admin_panel', :environment | |
6 | + | |
7 | + #FIXME This is not necessary because the application controller define the envrioment | |
8 | + # as the default holder | |
9 | + before_filter :load_default_enviroment | |
10 | + | |
11 | + design :holder => 'environment' | |
12 | + | |
13 | + protected | |
14 | + | |
15 | + def load_default_enviroment | |
16 | + @environment = Environment.default | |
17 | + end | |
18 | +end | ... | ... |
... | ... | @@ -0,0 +1,52 @@ |
1 | +class CategoriesController < EnvironmentAdminController | |
2 | + | |
3 | + protect 'manage_environment_categories', :environment | |
4 | + | |
5 | + helper :categories | |
6 | + | |
7 | + def index | |
8 | + @categories = environment.top_level_categories | |
9 | + end | |
10 | + | |
11 | + ALLOWED_TYPES = CategoriesHelper::TYPES.map {|item| item[1] } | |
12 | + | |
13 | + # posts back | |
14 | + def new | |
15 | + type = (params[:type] || 'Category') | |
16 | + raise 'Type not allowed' unless ALLOWED_TYPES.include?(type) | |
17 | + | |
18 | + @category = type.constantize.new(params[:category]) | |
19 | + @category.environment = environment | |
20 | + if params[:parent_id] | |
21 | + @category.parent = environment.categories.find(params[:parent_id]) | |
22 | + end | |
23 | + if request.post? | |
24 | + begin | |
25 | + @category.save! | |
26 | + redirect_to :action => 'index' | |
27 | + rescue Exception => e | |
28 | + render :action => 'new' | |
29 | + end | |
30 | + end | |
31 | + end | |
32 | + | |
33 | + # posts back | |
34 | + def edit | |
35 | + begin | |
36 | + @category = environment.categories.find(params[:id]) | |
37 | + if request.post? | |
38 | + @category.update_attributes!(params[:category]) | |
39 | + redirect_to :action => 'index' | |
40 | + end | |
41 | + rescue Exception => e | |
42 | + render :action => 'edit' | |
43 | + end | |
44 | + end | |
45 | + | |
46 | + post_only :remove | |
47 | + def remove | |
48 | + environment.categories.find(params[:id]).destroy | |
49 | + redirect_to :action => 'index' | |
50 | + end | |
51 | + | |
52 | +end | ... | ... |
... | ... | @@ -0,0 +1,17 @@ |
1 | +class EditTemplateController < EnvironmentAdminController | |
2 | + | |
3 | + design_editor :holder => 'environment', :autosave => true, :block_types => :block_types | |
4 | + | |
5 | + #FIXME This is wrong | |
6 | + #See the FavoriteLinksController considerations and choose the better way | |
7 | + def block_types | |
8 | + %w[ | |
9 | + FavoriteLinks | |
10 | + ] | |
11 | + end | |
12 | + | |
13 | + def index | |
14 | + redirect_to :action => 'design_editor' | |
15 | + end | |
16 | + | |
17 | +end | ... | ... |
app/controllers/admin/environment_role_manager_controller.rb
0 → 100644
... | ... | @@ -0,0 +1,66 @@ |
1 | +class EnvironmentRoleManagerController < ApplicationController | |
2 | + protect 'manage_environment_roles', :environment | |
3 | + | |
4 | + def index | |
5 | + @admins = Person.find(:all, :conditions => ['role_assignments.resource_type = ?', 'Environment'], :include => :role_assignments ) | |
6 | + end | |
7 | + | |
8 | + def change_roles | |
9 | + @admin = Person.find(params[:id]) | |
10 | + @roles = Role.find(:all).select{ |r| r.has_kind?(:environment) } | |
11 | + end | |
12 | + | |
13 | + def update_roles | |
14 | + @roles = params[:roles] ? Role.find(params[:roles]) : [] | |
15 | + @person = Person.find(params[:person]) | |
16 | + if @person.define_roles(@roles, environment) | |
17 | + flash[:notice] = _('Roles successfuly updated') | |
18 | + else | |
19 | + flash[:notice] = _('Couldn\'t change the roles') | |
20 | + end | |
21 | + redirect_to :action => :index | |
22 | + end | |
23 | + | |
24 | + def change_role | |
25 | + @roles = Role.find(:all).select{ |r| r.has_kind?(:environment) } | |
26 | + @admin = Person.find(params[:id]) | |
27 | + @associations = @admin.find_roles(environment) | |
28 | + end | |
29 | + | |
30 | + def add_role | |
31 | + @person = Person.find(params[:person]) | |
32 | + @role = Role.find(params[:role]) | |
33 | + if environment.affiliate(@person, @role) | |
34 | + redirect_to :action => 'index' | |
35 | + else | |
36 | + @admin = Person.find(params[:person]) | |
37 | + @roles = Role.find(:all).select{ |r| r.has_kind?(:environment) } | |
38 | + render :action => 'affiliate' | |
39 | + end | |
40 | + end | |
41 | + | |
42 | + def remove_role | |
43 | + @association = RoleAssignment.find(params[:id]) | |
44 | + if @association.destroy | |
45 | + flash[:notice] = _('Member succefully unassociated') | |
46 | + else | |
47 | + flash[:notice] = _('Failed to unassociate member') | |
48 | + end | |
49 | + redirect_to :aciton => 'index' | |
50 | + end | |
51 | + | |
52 | + def unassociate | |
53 | + @association = RoleAssignment.find(params[:id]) | |
54 | + if @association.destroy | |
55 | + flash[:notice] = _('Member succefully unassociated') | |
56 | + else | |
57 | + flash[:notice] = _('Failed to unassociate member') | |
58 | + end | |
59 | + redirect_to :aciton => 'index' | |
60 | + end | |
61 | + | |
62 | + def make_admin | |
63 | + @people = Person.find(:all) | |
64 | + @roles = Role.find(:all).select{|r|r.has_kind?(:environment)} | |
65 | + end | |
66 | +end | ... | ... |
... | ... | @@ -0,0 +1,20 @@ |
1 | +class FeaturesController < EnvironmentAdminController | |
2 | + protect 'edit_environment_features', :environment | |
3 | + | |
4 | + acts_as_environment_admin_controller | |
5 | + | |
6 | + def index | |
7 | + @features = Environment.available_features | |
8 | + end | |
9 | + | |
10 | + post_only :update | |
11 | + def update | |
12 | + if @environment.update_attributes(params[:environment]) | |
13 | + flash[:notice] = _('Features updated successfully.') | |
14 | + redirect_to :action => 'index' | |
15 | + else | |
16 | + render :action => 'index' | |
17 | + end | |
18 | + end | |
19 | + | |
20 | +end | ... | ... |
... | ... | @@ -0,0 +1,74 @@ |
1 | +# Manage tags stored by the acts-as_taggable_on_steroids plugin by providing an interface to create, destroy, update and list them | |
2 | +class ManageTagsController < EnvironmentAdminController | |
3 | + | |
4 | + # Index redirects to list action without modifing the url | |
5 | + def index | |
6 | + redirect_to :action => 'list' | |
7 | + end | |
8 | + | |
9 | + # Lists the tags starting with the top tags or with the chidren of @parent if its provided | |
10 | + def list | |
11 | + @parent = Tag.find(params[:parent]) if params[:parent] | |
12 | + @tags = @parent ? @parent.children : Tag.roots | |
13 | + @pending_tags = Tag.find_all_by_pending(true) | |
14 | + end | |
15 | + | |
16 | + # Prompt for data to a new tag | |
17 | + def new | |
18 | + @parent_tags = Tag.find_all_by_pending(false) | |
19 | + @tag = Tag.new | |
20 | + end | |
21 | + | |
22 | + # Collects the data and creates a new tag with it | |
23 | + def create | |
24 | + @tag = Tag.new(params[:tag]) | |
25 | + if @tag.save | |
26 | + flash[:notice] = _('Tag was successfully created.') | |
27 | + redirect_to :action => 'list' | |
28 | + else | |
29 | + @parent_tags = Tag.find_all_by_pending(false) | |
30 | + render :action => 'new' | |
31 | + end | |
32 | + end | |
33 | + | |
34 | + # Prompt for modifications on the attributes of a tag | |
35 | + def edit | |
36 | + @tag = Tag.find(params[:id]) | |
37 | + @parent_tags = @tag.parent_candidates | |
38 | + end | |
39 | + | |
40 | + # Do the modifications collected by edit | |
41 | + def update | |
42 | + @tag = Tag.find(params[:id]) | |
43 | + if @tag.update_attributes(params[:tag]) | |
44 | + flash[:notice] = _('Tag was successfully updated.') | |
45 | + redirect_to :action => 'list' | |
46 | + else | |
47 | + @parent_tags = @tag.parent_candidates | |
48 | + render :action => 'edit' | |
49 | + end | |
50 | + end | |
51 | + | |
52 | + # Destroy a tag and all its children | |
53 | + def destroy | |
54 | + @tag = Tag.find(params[:id]) | |
55 | + if @tag.destroy | |
56 | + flash[:notice] = _('Tag was successfuly destroyed') | |
57 | + end | |
58 | + redirect_to :action => 'list' | |
59 | + end | |
60 | + | |
61 | + # Approve a pending tag so now ita can be used to tag things | |
62 | + def approve | |
63 | + @tag = Tag.find(params[:id]) | |
64 | + if @tag.update_attribute(:pending, false) | |
65 | + flash[:notice] = _('Tag was successfuly approved') | |
66 | + redirect_to :action => 'list' | |
67 | + end | |
68 | + end | |
69 | + | |
70 | + # Full-text search for tags that have the query terms | |
71 | + def search | |
72 | + @tags_found = Tag.find_all_by_name_and_pending(params[:query], false) | |
73 | + end | |
74 | +end | ... | ... |
... | ... | @@ -0,0 +1,40 @@ |
1 | +class RegionValidatorsController < ApplicationController | |
2 | + | |
3 | + before_filter :load_region_and_search, :except => 'index' | |
4 | + | |
5 | +# protect 'manage_environment_validators', :environment | |
6 | + | |
7 | + def index | |
8 | + @regions = Region.top_level_for(environment) | |
9 | + end | |
10 | + | |
11 | + def region | |
12 | + # nothing to do, load_region_and_search already does everything needed here | |
13 | + end | |
14 | + | |
15 | + def search | |
16 | + render :partial => 'search' | |
17 | + end | |
18 | + | |
19 | + def add | |
20 | + validator = environment.organizations.find(params[:validator_id]) | |
21 | + @region.validators << validator | |
22 | + redirect_to :action => 'region', :id => @region.id | |
23 | + end | |
24 | + | |
25 | + def remove | |
26 | + validator = environment.organizations.find(params[:validator_id]) | |
27 | + @region.validators.delete(validator) | |
28 | + redirect_to :action => 'region', :id => @region.id | |
29 | + end | |
30 | + | |
31 | + protected | |
32 | + | |
33 | + def load_region_and_search | |
34 | + @region = environment.regions.find(params[:id]) | |
35 | + if params[:search] | |
36 | + @search = @region.search_possible_validators(params[:search]) | |
37 | + end | |
38 | + end | |
39 | + | |
40 | +end | ... | ... |
... | ... | @@ -0,0 +1,49 @@ |
1 | +class RoleController < EnvironmentAdminController | |
2 | + protect 'manage_environment_roles', :environment | |
3 | + | |
4 | + def index | |
5 | + @roles = Role.find(:all) | |
6 | + end | |
7 | + | |
8 | + def show | |
9 | + @role = Role.find(params[:id]) | |
10 | + end | |
11 | + | |
12 | + def new | |
13 | + @role = Role.new | |
14 | + end | |
15 | + | |
16 | + def create | |
17 | + @role = Role.new(params[:role]) | |
18 | + if @role.save | |
19 | + redirect_to :action => 'show', :id => @role | |
20 | + else | |
21 | + flash[:notice] = _('Failed to create role') | |
22 | + render :action => 'new' | |
23 | + end | |
24 | + end | |
25 | + | |
26 | + def edit | |
27 | + @role = Role.find(params[:id]) | |
28 | + end | |
29 | + | |
30 | + def update | |
31 | + @role = Role.find(params[:id]) | |
32 | + if @role.update_attributes(params[:role]) | |
33 | + redirect_to :action => 'show', :id => @role | |
34 | + else | |
35 | + flash[:notice] = _('Failed to edit role') | |
36 | + render :action => 'edit' | |
37 | + end | |
38 | + end | |
39 | + | |
40 | + def destroy | |
41 | + @role = Role.find(params[:id]) | |
42 | + if @role.destroy | |
43 | + redirect_to :action => 'index' | |
44 | + else | |
45 | + flash[:notice] = _('Failed to edit role') | |
46 | + redirect_to :action => 'index' | |
47 | + end | |
48 | + end | |
49 | +end | ... | ... |
app/controllers/environment_admin/admin_panel_controller.rb
... | ... | @@ -1,18 +0,0 @@ |
1 | -class AdminPanelController < EnvironmentAdminController | |
2 | - | |
3 | - before_filter :login_required | |
4 | - | |
5 | - protect 'view_environment_admin_panel', :environment | |
6 | - | |
7 | - #FIXME This is not necessary because the application controller define the envrioment | |
8 | - # as the default holder | |
9 | - before_filter :load_default_enviroment | |
10 | - | |
11 | - design :holder => 'environment' | |
12 | - | |
13 | - protected | |
14 | - | |
15 | - def load_default_enviroment | |
16 | - @environment = Environment.default | |
17 | - end | |
18 | -end |
app/controllers/environment_admin/categories_controller.rb
... | ... | @@ -1,52 +0,0 @@ |
1 | -class CategoriesController < EnvironmentAdminController | |
2 | - | |
3 | - protect 'manage_environment_categories', :environment | |
4 | - | |
5 | - helper :categories | |
6 | - | |
7 | - def index | |
8 | - @categories = environment.top_level_categories | |
9 | - end | |
10 | - | |
11 | - ALLOWED_TYPES = CategoriesHelper::TYPES.map {|item| item[1] } | |
12 | - | |
13 | - # posts back | |
14 | - def new | |
15 | - type = (params[:type] || 'Category') | |
16 | - raise 'Type not allowed' unless ALLOWED_TYPES.include?(type) | |
17 | - | |
18 | - @category = type.constantize.new(params[:category]) | |
19 | - @category.environment = environment | |
20 | - if params[:parent_id] | |
21 | - @category.parent = environment.categories.find(params[:parent_id]) | |
22 | - end | |
23 | - if request.post? | |
24 | - begin | |
25 | - @category.save! | |
26 | - redirect_to :action => 'index' | |
27 | - rescue Exception => e | |
28 | - render :action => 'new' | |
29 | - end | |
30 | - end | |
31 | - end | |
32 | - | |
33 | - # posts back | |
34 | - def edit | |
35 | - begin | |
36 | - @category = environment.categories.find(params[:id]) | |
37 | - if request.post? | |
38 | - @category.update_attributes!(params[:category]) | |
39 | - redirect_to :action => 'index' | |
40 | - end | |
41 | - rescue Exception => e | |
42 | - render :action => 'edit' | |
43 | - end | |
44 | - end | |
45 | - | |
46 | - post_only :remove | |
47 | - def remove | |
48 | - environment.categories.find(params[:id]).destroy | |
49 | - redirect_to :action => 'index' | |
50 | - end | |
51 | - | |
52 | -end |
app/controllers/environment_admin/edit_template_controller.rb
... | ... | @@ -1,17 +0,0 @@ |
1 | -class EditTemplateController < EnvironmentAdminController | |
2 | - | |
3 | - design_editor :holder => 'environment', :autosave => true, :block_types => :block_types | |
4 | - | |
5 | - #FIXME This is wrong | |
6 | - #See the FavoriteLinksController considerations and choose the better way | |
7 | - def block_types | |
8 | - %w[ | |
9 | - FavoriteLinks | |
10 | - ] | |
11 | - end | |
12 | - | |
13 | - def index | |
14 | - redirect_to :action => 'design_editor' | |
15 | - end | |
16 | - | |
17 | -end |
app/controllers/environment_admin/environment_role_manager_controller.rb
... | ... | @@ -1,66 +0,0 @@ |
1 | -class EnvironmentRoleManagerController < ApplicationController | |
2 | - protect 'manage_environment_roles', :environment | |
3 | - | |
4 | - def index | |
5 | - @admins = Person.find(:all, :conditions => ['role_assignments.resource_type = ?', 'Environment'], :include => :role_assignments ) | |
6 | - end | |
7 | - | |
8 | - def change_roles | |
9 | - @admin = Person.find(params[:id]) | |
10 | - @roles = Role.find(:all).select{ |r| r.has_kind?(:environment) } | |
11 | - end | |
12 | - | |
13 | - def update_roles | |
14 | - @roles = params[:roles] ? Role.find(params[:roles]) : [] | |
15 | - @person = Person.find(params[:person]) | |
16 | - if @person.define_roles(@roles, environment) | |
17 | - flash[:notice] = _('Roles successfuly updated') | |
18 | - else | |
19 | - flash[:notice] = _('Couldn\'t change the roles') | |
20 | - end | |
21 | - redirect_to :action => :index | |
22 | - end | |
23 | - | |
24 | - def change_role | |
25 | - @roles = Role.find(:all).select{ |r| r.has_kind?(:environment) } | |
26 | - @admin = Person.find(params[:id]) | |
27 | - @associations = @admin.find_roles(environment) | |
28 | - end | |
29 | - | |
30 | - def add_role | |
31 | - @person = Person.find(params[:person]) | |
32 | - @role = Role.find(params[:role]) | |
33 | - if environment.affiliate(@person, @role) | |
34 | - redirect_to :action => 'index' | |
35 | - else | |
36 | - @admin = Person.find(params[:person]) | |
37 | - @roles = Role.find(:all).select{ |r| r.has_kind?(:environment) } | |
38 | - render :action => 'affiliate' | |
39 | - end | |
40 | - end | |
41 | - | |
42 | - def remove_role | |
43 | - @association = RoleAssignment.find(params[:id]) | |
44 | - if @association.destroy | |
45 | - flash[:notice] = _('Member succefully unassociated') | |
46 | - else | |
47 | - flash[:notice] = _('Failed to unassociate member') | |
48 | - end | |
49 | - redirect_to :aciton => 'index' | |
50 | - end | |
51 | - | |
52 | - def unassociate | |
53 | - @association = RoleAssignment.find(params[:id]) | |
54 | - if @association.destroy | |
55 | - flash[:notice] = _('Member succefully unassociated') | |
56 | - else | |
57 | - flash[:notice] = _('Failed to unassociate member') | |
58 | - end | |
59 | - redirect_to :aciton => 'index' | |
60 | - end | |
61 | - | |
62 | - def make_admin | |
63 | - @people = Person.find(:all) | |
64 | - @roles = Role.find(:all).select{|r|r.has_kind?(:environment)} | |
65 | - end | |
66 | -end |
app/controllers/environment_admin/features_controller.rb
... | ... | @@ -1,20 +0,0 @@ |
1 | -class FeaturesController < EnvironmentAdminController | |
2 | - protect 'edit_environment_features', :environment | |
3 | - | |
4 | - acts_as_environment_admin_controller | |
5 | - | |
6 | - def index | |
7 | - @features = Environment.available_features | |
8 | - end | |
9 | - | |
10 | - post_only :update | |
11 | - def update | |
12 | - if @environment.update_attributes(params[:environment]) | |
13 | - flash[:notice] = _('Features updated successfully.') | |
14 | - redirect_to :action => 'index' | |
15 | - else | |
16 | - render :action => 'index' | |
17 | - end | |
18 | - end | |
19 | - | |
20 | -end |
app/controllers/environment_admin/manage_tags_controller.rb
... | ... | @@ -1,74 +0,0 @@ |
1 | -# Manage tags stored by the acts-as_taggable_on_steroids plugin by providing an interface to create, destroy, update and list them | |
2 | -class ManageTagsController < EnvironmentAdminController | |
3 | - | |
4 | - # Index redirects to list action without modifing the url | |
5 | - def index | |
6 | - redirect_to :action => 'list' | |
7 | - end | |
8 | - | |
9 | - # Lists the tags starting with the top tags or with the chidren of @parent if its provided | |
10 | - def list | |
11 | - @parent = Tag.find(params[:parent]) if params[:parent] | |
12 | - @tags = @parent ? @parent.children : Tag.roots | |
13 | - @pending_tags = Tag.find_all_by_pending(true) | |
14 | - end | |
15 | - | |
16 | - # Prompt for data to a new tag | |
17 | - def new | |
18 | - @parent_tags = Tag.find_all_by_pending(false) | |
19 | - @tag = Tag.new | |
20 | - end | |
21 | - | |
22 | - # Collects the data and creates a new tag with it | |
23 | - def create | |
24 | - @tag = Tag.new(params[:tag]) | |
25 | - if @tag.save | |
26 | - flash[:notice] = _('Tag was successfully created.') | |
27 | - redirect_to :action => 'list' | |
28 | - else | |
29 | - @parent_tags = Tag.find_all_by_pending(false) | |
30 | - render :action => 'new' | |
31 | - end | |
32 | - end | |
33 | - | |
34 | - # Prompt for modifications on the attributes of a tag | |
35 | - def edit | |
36 | - @tag = Tag.find(params[:id]) | |
37 | - @parent_tags = @tag.parent_candidates | |
38 | - end | |
39 | - | |
40 | - # Do the modifications collected by edit | |
41 | - def update | |
42 | - @tag = Tag.find(params[:id]) | |
43 | - if @tag.update_attributes(params[:tag]) | |
44 | - flash[:notice] = _('Tag was successfully updated.') | |
45 | - redirect_to :action => 'list' | |
46 | - else | |
47 | - @parent_tags = @tag.parent_candidates | |
48 | - render :action => 'edit' | |
49 | - end | |
50 | - end | |
51 | - | |
52 | - # Destroy a tag and all its children | |
53 | - def destroy | |
54 | - @tag = Tag.find(params[:id]) | |
55 | - if @tag.destroy | |
56 | - flash[:notice] = _('Tag was successfuly destroyed') | |
57 | - end | |
58 | - redirect_to :action => 'list' | |
59 | - end | |
60 | - | |
61 | - # Approve a pending tag so now ita can be used to tag things | |
62 | - def approve | |
63 | - @tag = Tag.find(params[:id]) | |
64 | - if @tag.update_attribute(:pending, false) | |
65 | - flash[:notice] = _('Tag was successfuly approved') | |
66 | - redirect_to :action => 'list' | |
67 | - end | |
68 | - end | |
69 | - | |
70 | - # Full-text search for tags that have the query terms | |
71 | - def search | |
72 | - @tags_found = Tag.find_all_by_name_and_pending(params[:query], false) | |
73 | - end | |
74 | -end |
app/controllers/environment_admin/region_validators_controller.rb
... | ... | @@ -1,40 +0,0 @@ |
1 | -class RegionValidatorsController < ApplicationController | |
2 | - | |
3 | - before_filter :load_region_and_search, :except => 'index' | |
4 | - | |
5 | -# protect 'manage_environment_validators', :environment | |
6 | - | |
7 | - def index | |
8 | - @regions = Region.top_level_for(environment) | |
9 | - end | |
10 | - | |
11 | - def region | |
12 | - # nothing to do, load_region_and_search already does everything needed here | |
13 | - end | |
14 | - | |
15 | - def search | |
16 | - render :partial => 'search' | |
17 | - end | |
18 | - | |
19 | - def add | |
20 | - validator = environment.organizations.find(params[:validator_id]) | |
21 | - @region.validators << validator | |
22 | - redirect_to :action => 'region', :id => @region.id | |
23 | - end | |
24 | - | |
25 | - def remove | |
26 | - validator = environment.organizations.find(params[:validator_id]) | |
27 | - @region.validators.delete(validator) | |
28 | - redirect_to :action => 'region', :id => @region.id | |
29 | - end | |
30 | - | |
31 | - protected | |
32 | - | |
33 | - def load_region_and_search | |
34 | - @region = environment.regions.find(params[:id]) | |
35 | - if params[:search] | |
36 | - @search = @region.search_possible_validators(params[:search]) | |
37 | - end | |
38 | - end | |
39 | - | |
40 | -end |
app/controllers/environment_admin/role_controller.rb
... | ... | @@ -1,49 +0,0 @@ |
1 | -class RoleController < EnvironmentAdminController | |
2 | - protect 'manage_environment_roles', :environment | |
3 | - | |
4 | - def index | |
5 | - @roles = Role.find(:all) | |
6 | - end | |
7 | - | |
8 | - def show | |
9 | - @role = Role.find(params[:id]) | |
10 | - end | |
11 | - | |
12 | - def new | |
13 | - @role = Role.new | |
14 | - end | |
15 | - | |
16 | - def create | |
17 | - @role = Role.new(params[:role]) | |
18 | - if @role.save | |
19 | - redirect_to :action => 'show', :id => @role | |
20 | - else | |
21 | - flash[:notice] = _('Failed to create role') | |
22 | - render :action => 'new' | |
23 | - end | |
24 | - end | |
25 | - | |
26 | - def edit | |
27 | - @role = Role.find(params[:id]) | |
28 | - end | |
29 | - | |
30 | - def update | |
31 | - @role = Role.find(params[:id]) | |
32 | - if @role.update_attributes(params[:role]) | |
33 | - redirect_to :action => 'show', :id => @role | |
34 | - else | |
35 | - flash[:notice] = _('Failed to edit role') | |
36 | - render :action => 'edit' | |
37 | - end | |
38 | - end | |
39 | - | |
40 | - def destroy | |
41 | - @role = Role.find(params[:id]) | |
42 | - if @role.destroy | |
43 | - redirect_to :action => 'index' | |
44 | - else | |
45 | - flash[:notice] = _('Failed to edit role') | |
46 | - redirect_to :action => 'index' | |
47 | - end | |
48 | - end | |
49 | -end |
app/controllers/environment_admin_controller.rb