Commit d9861a6912319e96d5542228a9df42f8e79956be
1 parent
5d1a3c2d
Exists in
master
and in
29 other branches
ActionItem5: linked the functionlity of managing members of profiles and editing the enterprise info
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@566 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
9 changed files
with
25 additions
and
12 deletions
Show diff stats
app/controllers/application.rb
... | ... | @@ -57,9 +57,9 @@ class ApplicationController < ActionController::Base |
57 | 57 | # * +permission+ must be a symbol or string naming the needed permission. |
58 | 58 | # * +target+ is the object over witch the user would need the specified permission. |
59 | 59 | def self.protect(actions, permission, target = nil) |
60 | - before_filter :only => actions do |controller| | |
61 | - unless controller.send(:logged_in?) and controller.send(:current_user).person.has_permission?(permission, target) | |
62 | - controller.send(:render, {:file => 'app/views/shared/access_denied.rhtml', :layout => true}) | |
60 | + before_filter :only => actions do |c| | |
61 | + unless c.send(:logged_in?) && c.send(:current_user).person.has_permission?(permission.to_s, c.send(target)) | |
62 | + c.send(:render, {:file => 'app/views/shared/access_denied.rhtml', :layout => true}) | |
63 | 63 | end |
64 | 64 | end |
65 | 65 | end | ... | ... |
app/controllers/profile_admin/enterprise_editor_controller.rb
1 | 1 | class EnterpriseEditorController < ProfileAdminController |
2 | 2 | |
3 | 3 | before_filter :logon, :check_enterprise |
4 | - | |
4 | + protect [:edit, :update], :edit_profile, :profile | |
5 | + protect [:destroy], :destroy_profile, @profile | |
6 | + | |
7 | + | |
5 | 8 | # Show details about an enterprise |
6 | 9 | def index |
7 | 10 | @enterprise = @profile | ... | ... |
app/models/enterprise.rb
... | ... | @@ -8,11 +8,11 @@ class Enterprise < Organization |
8 | 8 | end |
9 | 9 | |
10 | 10 | # Test that an enterprise can't be activated unless was previously approved |
11 | - def validate | |
12 | - if self.active && !self.approved? | |
13 | - errors.add('active', _('Not approved enterprise can\'t be activated')) | |
14 | - end | |
15 | - end | |
11 | +# def validate | |
12 | +# if self.active && !self.approved? | |
13 | +# errors.add('active', _('Not approved enterprise can\'t be activated')) | |
14 | +# end | |
15 | +# end | |
16 | 16 | |
17 | 17 | # Activate the enterprise so it can be seen by other users |
18 | 18 | def activate | ... | ... |
app/models/profile.rb
... | ... | @@ -50,6 +50,7 @@ class Profile < ActiveRecord::Base |
50 | 50 | validates_presence_of :identifier, :name |
51 | 51 | validates_format_of :identifier, :with => IDENTIFIER_FORMAT |
52 | 52 | validates_exclusion_of :identifier, :in => RESERVED_IDENTIFIERS |
53 | + validates_uniqueness_of :identifier | |
53 | 54 | |
54 | 55 | # A profile_owner cannot have more than one profile, but many profiles can exist |
55 | 56 | # without being associated to a particular user. | ... | ... |
app/models/role.rb
app/views/enterprise_editor/index.rhtml
1 | 1 | <h3> <%= @profile.name %> </h3> |
2 | 2 | |
3 | +<%= error_messages_for 'profile' %> | |
4 | + | |
3 | 5 | <p> <%= _('Identifier: ') %> <%= @profile.identifier %> </p> |
4 | 6 | <p> <%= _('Address: ') %> <%= @profile.address %> </p> |
5 | 7 | <p> <%= _('Contact phone: ') %> <%= @profile.contact_phone %> </p> |
... | ... | @@ -17,3 +19,5 @@ |
17 | 19 | <%= help _('Remove the enterprise from the system') %> |
18 | 20 | <%= link_to _('Activate'), :action => 'activate', :id => @profile unless @profile.active? %> |
19 | 21 | <%= help _('Activate an approved enterprise') unless @profile.active? %> |
22 | + | |
23 | +<%= link_to _('Back'), :controller => :profile_editor %> | ... | ... |
app/views/membership_editor/index.rhtml
app/views/profile_members/index.rhtml
test/fixtures/roles.yml
... | ... | @@ -8,6 +8,8 @@ two: |
8 | 8 | id: 2 |
9 | 9 | name: 'owner' |
10 | 10 | permissions: |
11 | + - menage_memberships | |
12 | + - post_content | |
11 | 13 | - destroy_profile |
12 | 14 | - edit_profile |
13 | 15 | three: |
... | ... | @@ -15,4 +17,3 @@ three: |
15 | 17 | name: 'moderator' |
16 | 18 | permissions: |
17 | 19 | - manage_memberships |
18 | - - moderate_content | ... | ... |