Updated router. Temporarly replaced routing filter with rails internal.
This commit is contained in:
parent
b71fcdf371
commit
eab16e337e
21 changed files with 190 additions and 128 deletions
|
|
@ -33,8 +33,8 @@ class Article < ActiveRecord::Base
|
|||
belongs_to :article_category
|
||||
has_many :article_prices, :order => "created_at DESC"
|
||||
|
||||
named_scope :available, :conditions => {:availability => true}
|
||||
named_scope :not_in_stock, :conditions => {:type => nil}
|
||||
scope :available, :conditions => {:availability => true}
|
||||
scope :not_in_stock, :conditions => {:type => nil}
|
||||
|
||||
# Validations
|
||||
validates_presence_of :name, :unit, :price, :tax, :deposit, :unit_quantity, :supplier_id, :article_category_id
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class Delivery < ActiveRecord::Base
|
|||
has_one :invoice
|
||||
has_many :stock_changes, :dependent => :destroy
|
||||
|
||||
named_scope :recent, :order => 'created_at DESC', :limit => 10
|
||||
scope :recent, :order => 'created_at DESC', :limit => 10
|
||||
|
||||
validates_presence_of :supplier_id
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ class GroupOrder < ActiveRecord::Base
|
|||
validates_numericality_of :price
|
||||
validates_uniqueness_of :ordergroup_id, :scope => :order_id # order groups can only order once per order
|
||||
|
||||
named_scope :open, lambda { {:conditions => ["order_id IN (?)", Order.open.collect(&:id)]} }
|
||||
named_scope :finished, lambda { {:conditions => ["order_id IN (?)", Order.finished_not_closed.collect(&:id)]} }
|
||||
scope :open, lambda { {:conditions => ["order_id IN (?)", Order.open.collect(&:id)]} }
|
||||
scope :finished, lambda { {:conditions => ["order_id IN (?)", Order.finished_not_closed.collect(&:id)]} }
|
||||
|
||||
# Updates the "price" attribute.
|
||||
# Until the order is finished this will be the maximum price or
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class GroupOrderArticle < ActiveRecord::Base
|
|||
|
||||
attr_accessor :ordergroup_id # To create an new GroupOrder if neccessary
|
||||
|
||||
named_scope :ordered, :conditions => 'result > 0'
|
||||
scope :ordered, :conditions => 'result > 0'
|
||||
|
||||
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
|
||||
def result=(result)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class Invoice < ActiveRecord::Base
|
|||
|
||||
validates_presence_of :supplier_id
|
||||
|
||||
named_scope :unpaid, :conditions => { :paid_on => nil }
|
||||
scope :unpaid, :conditions => { :paid_on => nil }
|
||||
|
||||
# Custom attribute setter that accepts decimal numbers using localized decimal separator.
|
||||
def amount=(amount)
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ class Message < ActiveRecord::Base
|
|||
serialize :recipients_ids, Array
|
||||
attr_accessor :sent_to_all, :group_id, :recipients_nicks
|
||||
|
||||
named_scope :pending, :conditions => { :email_state => 0 }
|
||||
named_scope :sent, :conditions => { :email_state => 1 }
|
||||
named_scope :public, :conditions => {:private => false}
|
||||
scope :pending, :conditions => { :email_state => 0 }
|
||||
scope :sent, :conditions => { :email_state => 1 }
|
||||
scope :public, :conditions => {:private => false}
|
||||
|
||||
# Values for the email_state attribute: :none, :pending, :sent, :failed
|
||||
EMAIL_STATE = {
|
||||
|
|
|
|||
|
|
@ -21,11 +21,11 @@ class Order < ActiveRecord::Base
|
|||
after_update :update_price_of_group_orders
|
||||
|
||||
# Finders
|
||||
named_scope :open, :conditions => {:state => 'open'}, :order => 'ends DESC'
|
||||
named_scope :finished, :conditions => "state = 'finished' OR state = 'closed'", :order => 'ends DESC'
|
||||
named_scope :finished_not_closed, :conditions => {:state => 'finished'}, :order => 'ends DESC'
|
||||
named_scope :closed, :conditions => {:state => 'closed'}, :order => 'ends DESC'
|
||||
named_scope :stockit, :conditions => {:supplier_id => 0}, :order => 'ends DESC'
|
||||
scope :open, :conditions => {:state => 'open'}, :order => 'ends DESC'
|
||||
scope :finished, :conditions => "state = 'finished' OR state = 'closed'", :order => 'ends DESC'
|
||||
scope :finished_not_closed, :conditions => {:state => 'finished'}, :order => 'ends DESC'
|
||||
scope :closed, :conditions => {:state => 'closed'}, :order => 'ends DESC'
|
||||
scope :stockit, :conditions => {:supplier_id => 0}, :order => 'ends DESC'
|
||||
|
||||
def stockit?
|
||||
supplier_id == 0
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class OrderArticle < ActiveRecord::Base
|
|||
validates_presence_of :order_id, :article_id
|
||||
validate :article_and_price_exist
|
||||
|
||||
named_scope :ordered, :conditions => "units_to_order >= 1"
|
||||
scope :ordered, :conditions => "units_to_order >= 1"
|
||||
|
||||
|
||||
# This method returns either the ArticlePrice or the Article
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ class Page < ActiveRecord::Base
|
|||
before_validation :update_permalink, :on => :update
|
||||
after_update :create_redirect
|
||||
|
||||
named_scope :non_redirected, :conditions => {:redirect => nil}
|
||||
named_scope :no_parent, :conditions => {:parent_id => nil}
|
||||
scope :non_redirected, :conditions => {:redirect => nil}
|
||||
scope :no_parent, :conditions => {:parent_id => nil}
|
||||
|
||||
def self.permalink(title)
|
||||
title.gsub(/[\/\.,;@\s]/, "_").gsub(/[\"\']/, "")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
class StockArticle < Article
|
||||
has_many :stock_changes
|
||||
|
||||
named_scope :available, :conditions => "quantity > 0"
|
||||
scope :available, :conditions => "quantity > 0"
|
||||
|
||||
before_destroy :check_quantity
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ class Task < ActiveRecord::Base
|
|||
has_many :users, :through => :assignments
|
||||
belongs_to :workgroup
|
||||
|
||||
named_scope :non_group, :conditions => { :workgroup_id => nil, :done => false }
|
||||
named_scope :done, :conditions => {:done => true}, :order => "due_date DESC"
|
||||
named_scope :upcoming, lambda { |*args| {:conditions => ["done = 0 AND due_date = ?", (args.first || 7.days.from_now)]} }
|
||||
scope :non_group, :conditions => { :workgroup_id => nil, :done => false }
|
||||
scope :done, :conditions => {:done => true}, :order => "due_date DESC"
|
||||
scope :upcoming, lambda { |*args| {:conditions => ["done = 0 AND due_date = ?", (args.first || 7.days.from_now)]} }
|
||||
|
||||
# form will send user in string. responsibilities will added later
|
||||
attr_protected :users
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue