Commit 9b38a790fce2a99c7506ba544840e423015e5726
1 parent
4561d9b9
Exists in
master
and in
29 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 | 10 | # Be sure to include AuthenticationSystem in Application Controller instead |
11 | 11 | include AuthenticatedSystem |
12 | 12 | extend PermissionCheck |
13 | - | |
14 | 13 | init_gettext 'noosfero' |
15 | 14 | |
16 | 15 | before_filter :detect_stuff_by_domain, :load_profile_from_params | ... | ... |
app/helpers/application_helper.rb
1 | 1 | # Methods added to this helper will be available to all templates in the |
2 | 2 | # application. |
3 | 3 | module ApplicationHelper |
4 | - | |
4 | + include PermissionName | |
5 | + | |
5 | 6 | # Displays context help. You can pass the content of the help message as the |
6 | 7 | # first parameter or using template code inside a block passed to this |
7 | 8 | # method. *Note*: the block is ignored if <tt>content</tt> is not | ... | ... |
app/models/profile.rb
... | ... | @@ -3,6 +3,13 @@ |
3 | 3 | # which by default is the one returned by Environment:default. |
4 | 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 | 13 | after_create do |profile| |
7 | 14 | homepage = Article.new |
8 | 15 | homepage.title = profile.name | ... | ... |
app/views/role/_form.rhtml
... | ... | @@ -5,8 +5,8 @@ |
5 | 5 | <%= f.text_field :name %> |
6 | 6 | |
7 | 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 | 10 | <% end %> |
11 | 11 | |
12 | 12 | <%= submit_tag (mode == :edit) ? _('Save changes') : _('Create role')%> | ... | ... |
app/views/role/show.rhtml
... | ... | @@ -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 @@ |
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 | ... | ... |