Commit 9b38a790fce2a99c7506ba544840e423015e5726
1 parent
4561d9b9
Exists in
master
and in
22 other branches
ActionItem75: some more changes to fit with the access_control plugin and to define the permissions
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@709 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
7 changed files
with
53 additions
and
5 deletions
Show diff stats
app/controllers/application.rb
@@ -10,7 +10,6 @@ class ApplicationController < ActionController::Base | @@ -10,7 +10,6 @@ class ApplicationController < ActionController::Base | ||
10 | # Be sure to include AuthenticationSystem in Application Controller instead | 10 | # Be sure to include AuthenticationSystem in Application Controller instead |
11 | include AuthenticatedSystem | 11 | include AuthenticatedSystem |
12 | extend PermissionCheck | 12 | extend PermissionCheck |
13 | - | ||
14 | init_gettext 'noosfero' | 13 | init_gettext 'noosfero' |
15 | 14 | ||
16 | before_filter :detect_stuff_by_domain, :load_profile_from_params | 15 | before_filter :detect_stuff_by_domain, :load_profile_from_params |
app/helpers/application_helper.rb
1 | # Methods added to this helper will be available to all templates in the | 1 | # Methods added to this helper will be available to all templates in the |
2 | # application. | 2 | # application. |
3 | module ApplicationHelper | 3 | module ApplicationHelper |
4 | - | 4 | + include PermissionName |
5 | + | ||
5 | # Displays context help. You can pass the content of the help message as the | 6 | # Displays context help. You can pass the content of the help message as the |
6 | # first parameter or using template code inside a block passed to this | 7 | # first parameter or using template code inside a block passed to this |
7 | # method. *Note*: the block is ignored if <tt>content</tt> is not | 8 | # method. *Note*: the block is ignored if <tt>content</tt> is not |
app/models/profile.rb
@@ -3,6 +3,13 @@ | @@ -3,6 +3,13 @@ | ||
3 | # which by default is the one returned by Environment:default. | 3 | # which by default is the one returned by Environment:default. |
4 | class Profile < ActiveRecord::Base | 4 | class Profile < ActiveRecord::Base |
5 | 5 | ||
6 | + PERMISSIONS[:profile] = { | ||
7 | + 'edit_profile' => N_('Edit profile'), | ||
8 | + 'destroy_profile' => N_('Destroy profile'), | ||
9 | + 'manage_memberships' => N_('Manage memberships'), | ||
10 | + 'post_content' => N_('Post content'), | ||
11 | + } | ||
12 | + | ||
6 | after_create do |profile| | 13 | after_create do |profile| |
7 | homepage = Article.new | 14 | homepage = Article.new |
8 | homepage.title = profile.name | 15 | homepage.title = profile.name |
app/views/role/_form.rhtml
@@ -5,8 +5,8 @@ | @@ -5,8 +5,8 @@ | ||
5 | <%= f.text_field :name %> | 5 | <%= f.text_field :name %> |
6 | 6 | ||
7 | <%= _('Permissions: ') %> <br> | 7 | <%= _('Permissions: ') %> <br> |
8 | - <% Role::PERMISSIONS[:profile].keys.each do |p| %> | ||
9 | - <%= labelled_form_field(Role.permission_name(p), (check_box_tag "role[permissions][]", p, @role.has_permission?(p))) %> | 8 | + <% Profile::PERMISSIONS[:profile].keys.each do |p| %> |
9 | + <%= labelled_form_field(permission_name(p), (check_box_tag "role[permissions][]", p, @role.has_permission?(p))) %> | ||
10 | <% end %> | 10 | <% end %> |
11 | 11 | ||
12 | <%= submit_tag (mode == :edit) ? _('Save changes') : _('Create role')%> | 12 | <%= submit_tag (mode == :edit) ? _('Save changes') : _('Create role')%> |
app/views/role/show.rhtml
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | <h3> <%= _('Permissions') %> </h3> | 3 | <h3> <%= _('Permissions') %> </h3> |
4 | <ul> | 4 | <ul> |
5 | <% @role.permissions.each do |p| %> | 5 | <% @role.permissions.each do |p| %> |
6 | - <li> <%= Role.permission_name(p) %> </li> | 6 | + <li> <%= permission_name(p) %> </li> |
7 | <% end %> | 7 | <% end %> |
8 | </ul> | 8 | </ul> |
9 | 9 |
@@ -0,0 +1,22 @@ | @@ -0,0 +1,22 @@ | ||
1 | +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html | ||
2 | +one: | ||
3 | + id: 1 | ||
4 | + accessor_id: 4 | ||
5 | + accessor_type: 'Person' | ||
6 | + role_id: 2 | ||
7 | + resource_id: 5 | ||
8 | + resource_type: 'Profile' | ||
9 | +two: | ||
10 | + id: 2 | ||
11 | + accessor_id: 1 | ||
12 | + accessor_type: 'Person' | ||
13 | + role_id: 1 | ||
14 | + resource_id: 5 | ||
15 | + resource_type: 'Profile' | ||
16 | +three: | ||
17 | + id: 3 | ||
18 | + accessor_id: 1 | ||
19 | + accessor_type: 'Person' | ||
20 | + role_id: 1 | ||
21 | + resource_id: 6 | ||
22 | + resource_type: 'Profile' |
@@ -0,0 +1,19 @@ | @@ -0,0 +1,19 @@ | ||
1 | +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html | ||
2 | +one: | ||
3 | + id: 1 | ||
4 | + name: 'member' | ||
5 | + permissions: | ||
6 | + - post_content | ||
7 | +two: | ||
8 | + id: 2 | ||
9 | + name: 'owner' | ||
10 | + permissions: | ||
11 | + - menage_memberships | ||
12 | + - post_content | ||
13 | + - destroy_profile | ||
14 | + - edit_profile | ||
15 | +three: | ||
16 | + id: 3 | ||
17 | + name: 'moderator' | ||
18 | + permissions: | ||
19 | + - manage_memberships |