big refactor for test and admin namespace
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -7,4 +7,6 @@ class ProductOrder
|
||||
belongs_to :product
|
||||
belongs_to :order
|
||||
|
||||
view :by_product_id, key: :product_id
|
||||
|
||||
end
|
||||
|
||||
@@ -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
@@ -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')
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user