diff --git a/app/controllers/users/lists_controller.rb b/app/controllers/users/lists_controller.rb index e7fc35b2..f87946cb 100644 --- a/app/controllers/users/lists_controller.rb +++ b/app/controllers/users/lists_controller.rb @@ -67,7 +67,7 @@ module Users # POST /user/lists/:id/order_products def order_products res = {} - unless active_list.present? + unless active_list.try(:active?) res[:list_closed] = true render json: res, status: 404 return diff --git a/app/models/list.rb b/app/models/list.rb index d7103b75..89df415b 100644 --- a/app/models/list.rb +++ b/app/models/list.rb @@ -292,6 +292,7 @@ class List return unless order.id orders_placed_count = supplier.increment_orders_placed_count! loaded_products = self.class.database.load_document product_orders.map{|po| po['product_id'] || po['product']} + #loaded_products = loaded_products.compact.include_relation(:product_category).select{|product| product.active? and product.product_category.try(:active?)} product_orders.each do |product_order| next unless product = loaded_products.find{|p| p.id == product_order['product_id'] or p.id == product_order['product']} # to get the price and current product name quantity = product_order['quantity'].to_i diff --git a/app/models/product_category.rb b/app/models/product_category.rb index ed9bbe12..c49ec8d0 100644 --- a/app/models/product_category.rb +++ b/app/models/product_category.rb @@ -69,6 +69,12 @@ class ProductCategory product_categories end + def active?(time = Time.now) + return true unless time_zone = supplier.time_zone.presence # cannot do activity magic without the appropriate time zone + + true + end + def to_client_format return {} unless products.present? {name: name, products: products.to_a.map{|p| p.as_json}} diff --git a/spec/requests/users/lists_spec.rb b/spec/requests/users/lists_spec.rb new file mode 100644 index 00000000..a061221c --- /dev/null +++ b/spec/requests/users/lists_spec.rb @@ -0,0 +1,18 @@ +require 'spec_helper' + +describe "User lists", type: :request do + let(:supplier){ create :supplier } + let(:user){ create :user} + before do + supplier.add_employee(employee) + login_as employee, scope: :employee + end + it "works" do + supplier = create :supplier + get "/supplier/suppliers/#{supplier.id}.json" + api_response.data.relationships.product_categorie + included_section = api_response.included.find{|ih| ih['type'] == 'sections'} + included_section['relationships']['tables']['data'].should eq [] + included_section['relationships']['section-areas']['data'].should eq [] + end +end diff --git a/wip.md b/wip.md index 6425e449..f333925d 100644 --- a/wip.md +++ b/wip.md @@ -10,6 +10,13 @@ Release todos: - facebook api integration on homepage share picture and js - Signup explanation better and link to current supplier when already signed in +- Add got it button to bottom of supplier User info modal +- User move table alert flash_message +- When an employee schedule is added the color is not immediate taken + from the selected employee +- User app authorizations + - identity +- Add exception notifier Supplier -------- @@ -33,6 +40,8 @@ Supplier - Change list table - Set product_category day from false to true - Go to list from dashboard (targetObject.targetObject stupidity) + - Click on the get Qr codes link from the section actions menus and + sections index page - Product order check for product being active - Add product_variant price_difference @@ -47,6 +56,13 @@ User the specs - Kom in aanmerking voor vaste klanten acties! - Add supplier info page +- Testing + - When there are new product orders, and the list is closed by the + supplier, and the user orders anyway, what happens?, also a security test + - Ordering a product + - Test for product being inactive + - Test for product's product category not active that moment +- Destroy authentication info button in settings page Bugs ----