validate :validate_custom_field
before_validation :set_searchable
- scope :sorted, order("#{table_name}.position ASC")
+ scope :sorted, lambda { order("#{table_name}.position ASC") }
CUSTOM_FIELDS_TABS = [
{:name => 'IssueCustomField', :partial => 'custom_fields/index',
validates_uniqueness_of :name, :scope => [:type, :project_id]
validates_length_of :name, :maximum => 30
- scope :shared, where(:project_id => nil)
- scope :sorted, order("#{table_name}.position ASC")
- scope :active, where(:active => true)
+ scope :shared, lambda { where(:project_id => nil) }
+ scope :sorted, lambda { order("#{table_name}.position ASC") }
+ scope :active, lambda { where(:active => true) }
scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)}
def self.default
before_destroy :remove_references_before_destroy
- scope :sorted, order("#{table_name}.lastname ASC")
+ scope :sorted, lambda { order("#{table_name}.lastname ASC") }
safe_attributes 'name',
'user_ids',
{:conditions => ["#{IssueStatus.table_name}.is_closed = ?", is_closed], :include => :status}
}
- scope :recently_updated, :order => "#{Issue.table_name}.updated_on DESC"
- scope :on_active_project, :include => [:status, :project, :tracker],
- :conditions => ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"]
+ scope :recently_updated, lambda { { :order => "#{Issue.table_name}.updated_on DESC" } }
+ scope :on_active_project, lambda { { :include => [:status, :project, :tracker],
+ :conditions => ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"] } }
before_create :default_assign
before_save :close_duplicates, :update_done_ratio_from_issue_status, :force_updated_on_change
validates_length_of :name, :maximum => 30
validates_inclusion_of :default_done_ratio, :in => 0..100, :allow_nil => true
- scope :sorted, order("#{table_name}.position ASC")
+ scope :sorted, lambda { order("#{table_name}.position ASC") }
scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)}
def update_default
has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify
# Groups and active users
- scope :active, :conditions => "#{Principal.table_name}.status = 1"
+ scope :active, lambda { { :conditions => "#{Principal.table_name}.status = 1" } }
scope :like, lambda {|q|
q = q.to_s
before_destroy :delete_all_members
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] } }
- scope :active, { :conditions => "#{Project.table_name}.status = #{STATUS_ACTIVE}"}
+ scope :active, lambda { { :conditions => "#{Project.table_name}.status = #{STATUS_ACTIVE}" } }
scope :status, lambda {|arg| arg.blank? ? {} : {:conditions => {:status => arg.to_i}} }
- scope :all_public, { :conditions => { :is_public => true } }
+ scope :all_public, lambda { { :conditions => { :is_public => true } } }
scope :visible, lambda {|*args| {:conditions => Project.visible_condition(args.shift || User.current, *args) }}
scope :allowed_to, lambda {|*args|
user = User.current
['own', :label_issues_visibility_own]
]
- scope :sorted, order("#{table_name}.builtin ASC, #{table_name}.position ASC")
- scope :givable, order("#{table_name}.position ASC").where(:builtin => 0)
+ scope :sorted, lambda { order("#{table_name}.builtin ASC, #{table_name}.position ASC") }
+ scope :givable, lambda { order("#{table_name}.position ASC").where(:builtin => 0) }
scope :builtin, lambda { |*args|
compare = (args.first == true ? 'not' : '')
where("#{compare} builtin = 0")
validates_uniqueness_of :name
validates_length_of :name, :maximum => 30
- scope :sorted, order("#{table_name}.position ASC")
+ scope :sorted, lambda { order("#{table_name}.position ASC") }
scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)}
def to_s; name end
has_one :api_token, :class_name => 'Token', :conditions => "action='api'"
belongs_to :auth_source
- scope :logged, :conditions => "#{User.table_name}.status <> #{STATUS_ANONYMOUS}"
+ scope :logged, lambda { { :conditions => "#{User.table_name}.status <> #{STATUS_ANONYMOUS}" } }
scope :status, lambda {|arg| arg.blank? ? {} : {:conditions => {:status => arg.to_i}} }
acts_as_customizable
validate :validate_version
scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)}
- scope :open, where(:status => 'open')
+ scope :open, lambda { where(:status => 'open') }
scope :visible, lambda {|*args|
includes(:project).where(Project.allowed_to_condition(args.first || User.current, :view_issues))
}
before_save :handle_redirects
# eager load information about last updates, without loading text
- scope :with_updated_on, {
+ scope :with_updated_on, lambda { {
:select => "#{WikiPage.table_name}.*, #{WikiContent.table_name}.updated_on, #{WikiContent.table_name}.version",
:joins => "LEFT JOIN #{WikiContent.table_name} ON #{WikiContent.table_name}.page_id = #{WikiPage.table_name}.id"
- }
+ } }
# Wiki pages that are protected by default
DEFAULT_PROTECTED_PAGES = %w(sidebar)