Project

General

Profile

RE: Override project.is_public ยป override_is_public_by_group_ownership_1.2.0.patch

Corentin Merot, 2011-06-15 11:35

View differences:

app/models/project.rb
83 83

  
84 84
  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] } }
85 85
  named_scope :active, { :conditions => "#{Project.table_name}.status = #{STATUS_ACTIVE}"}
86
  named_scope :all_public, { :conditions => { :is_public => true } }
86
  named_scope :all_public, lambda { { :conditions => Project.is_public } }
87 87
  named_scope :visible, lambda {|*args| {:conditions => Project.visible_condition(args.shift || User.current, *args) }}
88 88
  
89 89
  def initialize(attributes = nil)
......
103 103
      self.trackers = Tracker.all
104 104
    end
105 105
  end
106
  
106
 
107
  def is_public?
108
    user = User.current
109
    isea_group = Group.find_by_lastname('Production iseabloom')
110
    if user && isea_group && user.group_ids.include?(isea_group.id)
111
      return true
112
    else
113
      return false
114
    end
115
  end 
107 116
  def identifier=(identifier)
108 117
    super unless identifier_frozen?
109 118
  end
......
159 168
      statement_by_role = {}
160 169
      unless options[:member]
161 170
        role = user.logged? ? Role.non_member : Role.anonymous
162
        if role.allowed_to?(permission) && user.mail.match(/@iseabloom.com$/)
171
        isea_group = Group.find_by_lastname('Production iseabloom')
172
        if role.allowed_to?(permission) && isea_group && user.group_ids.include?(isea_group.id)
163 173
          statement_by_role[role] = "#{Project.table_name}.is_public = #{connection.quoted_true}"
164 174
        end
165 175
      end
    (1-1/1)