big refactor for test and admin namespace

This commit is contained in:
2012-12-04 18:45:18 +01:00
parent 7d64ab2022
commit d8eef4a047
85 changed files with 1403 additions and 1272 deletions
+1
View File
@@ -24,6 +24,7 @@ class Order
}
}], reduce_function: '_sum'
view :by_supplier_id_and_id, key: [:supplier_id, :_id]
view :by_list_id, key: :list_id
# Return all currently active orders for a given supplier
def self.active_for_supplier(supplier_id)
+2
View File
@@ -11,6 +11,8 @@ class Product
has_many :product_orders
validates :supplier_id, presence: true
validates :price, presence: true, numericality: true
after_save :persist_product_category_ids
def product_category_ids=(ids)
+2
View File
@@ -7,4 +7,6 @@ class ProductOrder
belongs_to :product
belongs_to :order
view :by_product_id, key: :product_id
end
+3 -1
View File
@@ -26,6 +26,8 @@ class Supplier
after_create :add_section_on_create
view :by_email, key: :email
def location=(val)
lat, lng = val.strip.split(/[ ,]+/).map(&:to_f)
self.lat = lat
@@ -45,7 +47,7 @@ class Supplier
end
def active_lists(options = {})
return @active_lists if @active_lists.present?
return @active_lists if @active_lists.present?
@active_lists = List.active_for_supplier(id)
@active_lists.include_relations(table: :section, orders: {product_orders: :product})
@active_lists
+3 -1
View File
@@ -14,7 +14,9 @@ class Table
validates :supplier_id, presence: true
#validates :list_id, presence: true
validates :number, numericality: {greater_than: 0}
validates_uniqueness_of :number
#validates_uniqueness_of :number
#view :by_number, key: :number # For uniqueness validation
def occupied?
return @is_occupied if instance_variable_defined?(:'@is_occupied')
+1
View File
@@ -12,6 +12,7 @@ class User
before_save :ensure_authentication_token
view :by_authentication_token, key: :authentication_token
view :by_email, key: :email
def list_is_closed!
self.active_list_id = nil