mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-04 23:11:47 +01:00
start fixing deprecation warnings
This commit is contained in:
parent
0bc9b0397a
commit
ebff4cfc0c
9 changed files with 74 additions and 79 deletions
|
|
@ -1,13 +1,13 @@
|
|||
class Context < ActiveRecord::Base
|
||||
|
||||
has_many :todos, :dependent => :delete_all, :include => :project,
|
||||
:order => 'todos.due IS NULL, todos.due ASC, todos.created_at ASC'
|
||||
has_many :todos, -> { order("todos.due IS NULL, todos.due ASC, todos.created_at ASC").includes(:project) }, :dependent => :delete_all
|
||||
|
||||
has_many :recurring_todos, :dependent => :delete_all
|
||||
belongs_to :user
|
||||
|
||||
scope :active, :conditions => { :state => :active }
|
||||
scope :hidden, :conditions => { :state => :hidden }
|
||||
scope :closed, :conditions => { :state => :closed }
|
||||
scope :active, -> { where state: :active }
|
||||
scope :hidden, -> { where state: :hidden }
|
||||
scope :closed, -> { where state: :closed }
|
||||
scope :with_name, lambda { |name| where("name LIKE ?", name) }
|
||||
|
||||
acts_as_list :scope => :user, :top_of_list => 0
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
class Project < ActiveRecord::Base
|
||||
has_many :todos, :dependent => :delete_all, :order => 'todos.due IS NULL, todos.due ASC, todos.created_at ASC'
|
||||
has_many :notes, :dependent => :delete_all, :order => "created_at DESC"
|
||||
has_many :todos, -> {order("todos.due IS NULL, todos.due ASC, todos.created_at ASC")}, dependent: :delete_all
|
||||
has_many :notes, -> {order "created_at DESC"}, dependent: :delete_all
|
||||
has_many :recurring_todos
|
||||
|
||||
belongs_to :default_context, :class_name => "Context", :foreign_key => "default_context_id"
|
||||
belongs_to :user
|
||||
|
||||
scope :active, :conditions => { :state => 'active' }
|
||||
scope :hidden, :conditions => { :state => 'hidden' }
|
||||
scope :completed, :conditions => { :state => 'completed'}
|
||||
scope :uncompleted, :conditions => ["NOT(state = ?)", 'completed']
|
||||
scope :active, -> { where state: 'active' }
|
||||
scope :hidden, -> { where state: 'hidden' }
|
||||
scope :completed, -> { where state: 'completed' }
|
||||
scope :uncompleted, -> { where("NOT(state = ?)", 'completed') }
|
||||
|
||||
scope :with_name_or_description, lambda { |body| where("name LIKE ? OR description LIKE ?", body, body) }
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ class RecurringTodo < ActiveRecord::Base
|
|||
|
||||
has_many :todos
|
||||
|
||||
scope :active, :conditions => { :state => 'active'}
|
||||
scope :completed, :conditions => { :state => 'completed'}
|
||||
scope :active, -> { where state: 'active'}
|
||||
scope :completed, -> { where state: 'completed'}
|
||||
|
||||
include IsTaggable
|
||||
|
||||
|
|
|
|||
|
|
@ -17,41 +17,37 @@ class Todo < ActiveRecord::Base
|
|||
has_many :successor_dependencies, :foreign_key => 'successor_id', :class_name => 'Dependency', :dependent => :destroy
|
||||
has_many :predecessors, :through => :successor_dependencies
|
||||
has_many :successors, :through => :predecessor_dependencies
|
||||
has_many :uncompleted_predecessors, :through => :successor_dependencies,
|
||||
:source => :predecessor, :conditions => ['NOT (todos.state = ?)', 'completed']
|
||||
has_many :pending_successors, :through => :predecessor_dependencies,
|
||||
:source => :successor, :conditions => ['todos.state = ?', 'pending']
|
||||
has_many :uncompleted_predecessors, -> {where('NOT (todos.state = ?)', 'completed')}, :through => :successor_dependencies,
|
||||
:source => :predecessor
|
||||
has_many :pending_successors, -> {where('todos.state = ?', 'pending')}, :through => :predecessor_dependencies,
|
||||
:source => :successor
|
||||
|
||||
# scopes for states of this todo
|
||||
scope :active, :conditions => { :state => 'active' }
|
||||
scope :active_or_hidden, :conditions => ["todos.state = ? OR todos.state = ?", 'active', 'project_hidden']
|
||||
scope :not_completed, :conditions => ['NOT (todos.state = ?)', 'completed']
|
||||
scope :completed, :conditions => ["todos.state = ?", 'completed']
|
||||
scope :deferred, :conditions => ["todos.state = ?", 'deferred']
|
||||
scope :blocked, :conditions => ['todos.state = ?', 'pending']
|
||||
scope :pending, :conditions => ['todos.state = ?', 'pending']
|
||||
scope :deferred_or_blocked, :conditions => ["(todos.state = ?) OR (todos.state = ?)", "deferred", "pending"]
|
||||
scope :not_deferred_or_blocked, :conditions => ["(NOT todos.state=?) AND (NOT todos.state = ?)", "deferred", "pending"]
|
||||
scope :hidden,
|
||||
:joins => "INNER JOIN contexts c_hidden ON c_hidden.id = todos.context_id",
|
||||
:conditions => ["todos.state = ? OR (c_hidden.state = ? AND (todos.state = ? OR todos.state = ? OR todos.state = ?))",
|
||||
'project_hidden', 'hidden', 'active', 'deferred', 'pending']
|
||||
scope :not_hidden,
|
||||
:joins => "INNER JOIN contexts c_hidden ON c_hidden.id = todos.context_id",
|
||||
:conditions => ['NOT(todos.state = ? OR (c_hidden.state = ? AND (todos.state = ? OR todos.state = ? OR todos.state = ?)))',
|
||||
'project_hidden', 'hidden', 'active', 'deferred', 'pending']
|
||||
scope :active, -> { where state: 'active' }
|
||||
scope :active_or_hidden, -> { where "todos.state = ? OR todos.state = ?", 'active', 'project_hidden' }
|
||||
scope :not_completed, -> { where 'NOT (todos.state = ?)', 'completed' }
|
||||
scope :completed, -> { where "todos.state = ?", 'completed' }
|
||||
scope :deferred, -> { where "todos.state = ?", 'deferred' }
|
||||
scope :blocked, -> {where 'todos.state = ?', 'pending' }
|
||||
scope :pending, -> {where 'todos.state = ?', 'pending' }
|
||||
scope :deferred_or_blocked, -> { where "(todos.state = ?) OR (todos.state = ?)", "deferred", "pending" }
|
||||
scope :not_deferred_or_blocked, -> { where "(NOT todos.state=?) AND (NOT todos.state = ?)", "deferred", "pending" }
|
||||
scope :hidden, -> {
|
||||
joins("INNER JOIN contexts c_hidden ON c_hidden.id = todos.context_id").
|
||||
where("todos.state = ? OR (c_hidden.state = ? AND (todos.state = ? OR todos.state = ? OR todos.state = ?))", 'project_hidden', 'hidden', 'active', 'deferred', 'pending') }
|
||||
scope :not_hidden, -> {
|
||||
joins("INNER JOIN contexts c_hidden ON c_hidden.id = todos.context_id").
|
||||
where('NOT(todos.state = ? OR (c_hidden.state = ? AND (todos.state = ? OR todos.state = ? OR todos.state = ?)))','project_hidden', 'hidden', 'active', 'deferred', 'pending') }
|
||||
|
||||
# other scopes
|
||||
scope :are_due, :conditions => ['NOT (todos.due IS NULL)']
|
||||
scope :with_tag, lambda { |tag_id| joins("INNER JOIN taggings ON todos.id = taggings.taggable_id").where("taggings.tag_id = ? ", tag_id) }
|
||||
scope :with_tags, lambda { |tag_ids| where("EXISTS(SELECT * from taggings t WHERE t.tag_id IN (?) AND t.taggable_id=todos.id AND t.taggable_type='Todo')", tag_ids) }
|
||||
# scope :of_user, lambda { |user_id| {:conditions => ["todos.user_id = ? ", user_id] } }
|
||||
scope :completed_after, lambda { |date| where("todos.completed_at > ?", date) }
|
||||
scope :completed_before, lambda { |date| where("todos.completed_at < ?", date) }
|
||||
scope :created_after, lambda { |date| where("todos.created_at > ?", date) }
|
||||
scope :created_before, lambda { |date| where("todos.created_at < ?", date) }
|
||||
|
||||
scope :due_today, lambda { where("todos.due <= ?", Time.zone.now) }
|
||||
scope :are_due, -> { where 'NOT (todos.due IS NULL)' }
|
||||
scope :due_today, -> { where("todos.due <= ?", Time.zone.now) }
|
||||
scope :with_tag, lambda { |tag_id| joins("INNER JOIN taggings ON todos.id = taggings.taggable_id").where("taggings.tag_id = ? ", tag_id) }
|
||||
scope :with_tags, lambda { |tag_ids| where("EXISTS(SELECT * from taggings t WHERE t.tag_id IN (?) AND t.taggable_id=todos.id AND t.taggable_type='Todo')", tag_ids) }
|
||||
scope :completed_after, lambda { |date| where("todos.completed_at > ?", date) }
|
||||
scope :completed_before, lambda { |date| where("todos.completed_at < ?", date) }
|
||||
scope :created_after, lambda { |date| where("todos.created_at > ?", date) }
|
||||
scope :created_before, lambda { |date| where("todos.created_at < ?", date) }
|
||||
|
||||
def self.due_after(date)
|
||||
where('todos.due > ?', date)
|
||||
|
|
@ -151,7 +147,7 @@ class Todo < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def uncompleted_predecessors?
|
||||
return !uncompleted_predecessors.all.empty?
|
||||
return !uncompleted_predecessors.empty?
|
||||
end
|
||||
|
||||
def should_be_blocked?
|
||||
|
|
|
|||
|
|
@ -11,9 +11,7 @@ class User < ActiveRecord::Base
|
|||
cattr_accessor :per_page
|
||||
@@per_page = 5
|
||||
|
||||
has_many :contexts,
|
||||
:order => 'position ASC',
|
||||
:dependent => :delete_all do
|
||||
has_many(:contexts, -> { order 'position ASC' }, dependent: :delete_all) do
|
||||
def find_by_params(params)
|
||||
find(params['id'] || params['context_id']) || nil
|
||||
end
|
||||
|
|
@ -25,9 +23,8 @@ class User < ActiveRecord::Base
|
|||
}
|
||||
end
|
||||
end
|
||||
has_many :projects,
|
||||
:order => 'projects.position ASC',
|
||||
:dependent => :delete_all do
|
||||
|
||||
has_many(:projects, -> {order 'projects.position ASC'}, dependent: :delete_all) do
|
||||
def find_by_params(params)
|
||||
find(params['id'] || params['project_id'])
|
||||
end
|
||||
|
|
@ -79,34 +76,36 @@ class User < ActiveRecord::Base
|
|||
return where(scope_conditions)
|
||||
end
|
||||
end
|
||||
has_many :todos,
|
||||
:order => 'todos.completed_at DESC, todos.created_at DESC',
|
||||
:dependent => :delete_all do
|
||||
|
||||
has_many(:todos, -> { order 'todos.completed_at DESC, todos.created_at DESC' }, dependent: :delete_all) do
|
||||
def count_by_group(g)
|
||||
except(:order).group(g).count
|
||||
end
|
||||
end
|
||||
|
||||
has_many :recurring_todos,
|
||||
:order => 'recurring_todos.completed_at DESC, recurring_todos.created_at DESC',
|
||||
:dependent => :delete_all
|
||||
has_many :deferred_todos,
|
||||
:class_name => 'Todo',
|
||||
:conditions => [ 'state = ?', 'deferred' ],
|
||||
:order => 'show_from ASC, todos.created_at DESC' do
|
||||
-> {order 'recurring_todos.completed_at DESC, recurring_todos.created_at DESC'},
|
||||
dependent: :delete_all
|
||||
|
||||
has_many(:deferred_todos,
|
||||
-> { where('state = ?', 'deferred').
|
||||
order('show_from ASC, todos.created_at DESC')},
|
||||
:class_name => 'Todo') do
|
||||
def find_and_activate_ready
|
||||
where('show_from <= ?', Time.zone.now).collect { |t| t.activate! }
|
||||
end
|
||||
end
|
||||
has_many :notes, :order => "created_at DESC", :dependent => :delete_all
|
||||
has_one :preference, :dependent => :destroy
|
||||
|
||||
has_many :notes, -> { order "created_at DESC" }, dependent: :delete_all
|
||||
has_one :preference, dependent: :destroy
|
||||
|
||||
validates_presence_of :login
|
||||
validates_presence_of :password, :if => :password_required?
|
||||
validates_length_of :password, :within => 5..40, :if => :password_required?
|
||||
validates_presence_of :password_confirmation, :if => :password_required?
|
||||
validates_presence_of :password, if: :password_required?
|
||||
validates_length_of :password, within: 5..40, if: :password_required?
|
||||
validates_presence_of :password_confirmation, if: :password_required?
|
||||
validates_confirmation_of :password
|
||||
validates_length_of :login, :within => 3..80
|
||||
validates_uniqueness_of :login, :on => :create
|
||||
validates_length_of :login, within: 3..80
|
||||
validates_uniqueness_of :login, on: :create
|
||||
validate :validate_auth_type
|
||||
|
||||
before_create :crypt_password, :generate_token
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue