diff --git a/app/models/project.rb b/app/models/project.rb index 128a9e7..acb54a1 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -83,7 +83,7 @@ class Project < ActiveRecord::Base named_scope :has_module, lambda { |mod| { :conditions => ["#{Project.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name=?)", mod.to_s] } } named_scope :active, { :conditions => "#{Project.table_name}.status = #{STATUS_ACTIVE}"} - named_scope :all_public, { :conditions => { :is_public => true } } + named_scope :all_public, lambda { { :conditions => Project.is_public } } named_scope :visible, lambda {|*args| {:conditions => Project.visible_condition(args.shift || User.current, *args) }} def initialize(attributes = nil) @@ -103,7 +103,16 @@ class Project < ActiveRecord::Base self.trackers = Tracker.all end end - + + def is_public? + user = User.current + isea_group = Group.find_by_lastname('Production iseabloom') + if user && isea_group && user.group_ids.include?(isea_group.id) + return true + else + return false + end + end def identifier=(identifier) super unless identifier_frozen? end @@ -159,7 +168,8 @@ class Project < ActiveRecord::Base statement_by_role = {} unless options[:member] role = user.logged? ? Role.non_member : Role.anonymous - if role.allowed_to?(permission) && user.mail.match(/@iseabloom.com$/) + isea_group = Group.find_by_lastname('Production iseabloom') + if role.allowed_to?(permission) && isea_group && user.group_ids.include?(isea_group.id) statement_by_role[role] = "#{Project.table_name}.is_public = #{connection.quoted_true}" end end