Merge pull request #379 from warpc/377-fix_groups_as_owner
[fixed #377] Fixed for group list in create project page
This commit is contained in:
commit
851fd9d722
|
@ -21,7 +21,7 @@ class Group < ActiveRecord::Base
|
|||
scope :search, lambda {|q| where("uname ILIKE ?", "%#{q.strip}%")}
|
||||
scope :opened, where('1=1')
|
||||
scope :by_owner, lambda {|owner| where(:owner_id => owner.id)}
|
||||
scope :by_admin, lambda {|admin| joins(:relations).where(:'relations.role' => 'admin', :'relations.target_id' => admin.id, :'relations.target_type' => 'User')}
|
||||
scope :by_admin, lambda {|admin| joins(:objects).where(:'relations.role' => 'admin', :'relations.object_id' => admin.id, :'relations.object_type' => 'User')}
|
||||
|
||||
attr_accessible :description
|
||||
attr_readonly :own_projects_count
|
||||
|
@ -34,7 +34,7 @@ class Group < ActiveRecord::Base
|
|||
# include Modules::Models::Owner
|
||||
|
||||
def self.can_own_project(user)
|
||||
(by_owner(user) | by_admin(user)).collect { |el| [el.name, el.id] }
|
||||
(by_owner(user) | by_admin(user))
|
||||
end
|
||||
|
||||
def name
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
= label_tag t("activerecord.attributes.project.who_owns.group")
|
||||
= radio_button_tag :who_owns, 'group', @who_owns == :group #{}.merge( (@who_owns == :group) ? {:checked => 'checked'} : {} )
|
||||
-# TODO: Make our own select_box helper with new design, blackjack and bitches!
|
||||
= select_tag :owner_id, options_for_select( Group.can_own_project(current_user) )
|
||||
= select_tag :owner_id, options_from_collection_for_select( Group.can_own_project(current_user), :id, :name )
|
||||
- else
|
||||
= hidden_field_tag :who_owns, :me
|
||||
.both
|
||||
|
|
Loading…
Reference in New Issue