Commit c8b1aabb3ab0b973f2de3f0898e3d63380d8ebc2
1 parent
0e575f49
Exists in
master
and in
28 other branches
ActionItem6: pending enterprises is now shown
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@214 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
5 changed files
with
13 additions
and
10 deletions
Show diff stats
app/controllers/enterprise_controller.rb
... | ... | @@ -5,6 +5,7 @@ class EnterpriseController < ApplicationController |
5 | 5 | |
6 | 6 | def index |
7 | 7 | @enterprises = Enterprise.find(:all) - @my_enterprises |
8 | + @pending_enterprises = current_user.person.my_enterprises(false) | |
8 | 9 | end |
9 | 10 | |
10 | 11 | def register_form |
... | ... | @@ -21,7 +22,7 @@ class EnterpriseController < ApplicationController |
21 | 22 | redirect_to :action => 'index' |
22 | 23 | else |
23 | 24 | flash[:notice] = _('Enterprise was not created') |
24 | - render :action => 'register' | |
25 | + render :action => 'register_form' | |
25 | 26 | end |
26 | 27 | end |
27 | 28 | ... | ... |
app/models/person.rb
... | ... | @@ -9,7 +9,7 @@ class Person < Profile |
9 | 9 | has_many :other_friendships |
10 | 10 | has_many :other_friend, :class_name => 'Person', :through => :other_friendships, :foreign_key => 'friend_id' |
11 | 11 | |
12 | - def my_enterprises | |
13 | - related_profiles.select{ |p| p.kind_of?(Enterprise) } | |
12 | + def my_enterprises(status = true) | |
13 | + related_profiles.find(:all, :conditions => ['type = ? and active = ?', 'Enterprise', status]) | |
14 | 14 | end |
15 | 15 | end | ... | ... |
app/models/profile.rb
... | ... | @@ -45,9 +45,7 @@ class Profile < ActiveRecord::Base |
45 | 45 | |
46 | 46 | # A profile_owner cannot have more than one profile, but many profiles can exist |
47 | 47 | # without being associated to a particular user. |
48 | - validates_uniqueness_of :user_id, :if => (lambda do |profile| | |
49 | - ! profile.user_id.nil? | |
50 | - end) | |
48 | + validates_uniqueness_of :user_id, :allow_nil =>true | |
51 | 49 | |
52 | 50 | # creates a new Profile. By default, it is attached to the default |
53 | 51 | # VirtualCommunity (see VirtualCommunity#default), unless you tell it | ... | ... |
app/views/enterprise/index.rhtml
... | ... | @@ -4,7 +4,9 @@ |
4 | 4 | <%= render :partial => 'enterprise', :collection => @my_enterprises %> |
5 | 5 | </ul> |
6 | 6 | |
7 | -<h2> <%= _('Listing pending enterprises') %> </h2> | |
8 | -<ul> | |
9 | - <%= render :partial => 'enterprise', :collection => @pending_enterprises %> | |
10 | -</ul> | |
7 | +<% unless @pending_enterprises.blank? %> | |
8 | + <h2> <%= _('Listing pending enterprises') %> </h2> | |
9 | + <ul> | |
10 | + <%= render :partial => 'enterprise', :collection => @pending_enterprises %> | |
11 | + </ul> | |
12 | +<% end %> | ... | ... |