diff --git a/.gitignore b/.gitignore index ca6029aa..be107971 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,5 @@ erl_crash.dump /db/data /db/config public/user + +/config/master.key diff --git a/app/controllers/suppliers/employee_shifts_controller.rb b/app/controllers/suppliers/employee_shifts_controller.rb index a1df69c8..3b7ed66a 100644 --- a/app/controllers/suppliers/employee_shifts_controller.rb +++ b/app/controllers/suppliers/employee_shifts_controller.rb @@ -4,11 +4,12 @@ module Suppliers @employee_shifts = EmployeeShift.for_supplier(current_supplier, relevant_from: 1.week.ago) #@employee_shifts.include_relations(:employee, :supplier) # Only select shifts from currently linked and employees - @employee_shifts.select! do |shift| - return false unless current_supplier.employee_ids.include?(shift.employee.try(:id)) - shift.employee.enrich_with_settings current_supplier.settings_for(shift.employee) - true - end + #@employee_shifts.select! do |shift| + # return false unless current_supplier.employee_ids.include?(shift.employee.try(:id)) + # shift.employee.enrich_with_settings current_supplier.settings_for(shift.employee) + # true + #end + #@employee_shifts.each { |shift| shift.employee.enrich_with_settings current_supplier.settings_for(shift.employee) render json: @employee_shifts end def create diff --git a/app/controllers/suppliers/employees_controller.rb b/app/controllers/suppliers/employees_controller.rb index bb07f7c9..df1129a8 100644 --- a/app/controllers/suppliers/employees_controller.rb +++ b/app/controllers/suppliers/employees_controller.rb @@ -8,6 +8,7 @@ module Suppliers # GET /employees.json def index @employees = current_supplier.employees + @employees.each { |employee| employee.enrich_with_settings current_supplier.settings_for(employee) } render json: @employees end diff --git a/app/controllers/users/lists_controller.rb b/app/controllers/users/lists_controller.rb index ad9a163c..56bc5cc5 100644 --- a/app/controllers/users/lists_controller.rb +++ b/app/controllers/users/lists_controller.rb @@ -15,8 +15,20 @@ module Users #EMBER def current @list = current_user.active_list - params[:id] = @list.try(:id) # serializer determines collection or not based on the presence of this - show + render json: {}, status: :not_found and return unless @list.present? && Array.wrap(@list.user_ids).include?(current_user.id) + include_config = %w[ + supplier + supplier.product_categories + supplier.product_categories.products + supplier.product_categories.products.product_variants + join_requests + join_requests.user + table + orders + orders.product_orders + ] + include_config << 'users' if @list.user_ids.size > 1 + render json: @list, include: include_config, serializer: Users::ListSerializer, is_collection: false end def table diff --git a/app/controllers/users/suppliers_controller.rb b/app/controllers/users/suppliers_controller.rb index 47cd8261..420f4663 100644 --- a/app/controllers/users/suppliers_controller.rb +++ b/app/controllers/users/suppliers_controller.rb @@ -4,10 +4,16 @@ module Users def show @supplier = Supplier.find(params[:id]) render json: {}, status: :not_found and return unless @supplier.present? - render json: @supplier, include: %w[ - product_categories - product_categories.products - product_categories.products.product_variants + render json: @supplier + end + + def product_categories + @supplier = Supplier.find(params[:id]) + render json: {}, status: :not_found and return unless @supplier.present? + @supplier.product_categories.include_relations products: :product_variants + render json: @supplier.product_categories, serializer: Users::ProductCategorySerializer, is_collection: true, include: %w[ + products + products.product_variants ] end end diff --git a/app/controllers/users/tables_controller.rb b/app/controllers/users/tables_controller.rb index 13566e99..2c26020f 100644 --- a/app/controllers/users/tables_controller.rb +++ b/app/controllers/users/tables_controller.rb @@ -3,19 +3,19 @@ module Users respond_to :json def show @table = Table.find(params[:id]) - render json: JSONAPI::Serializer.serialize(@table, serializer: Users::TableSerializer) + render json: @table, include: ['supplier'] end - def supplier - table = Table.find(params[:id]) - supplier = table.supplier - supplier.product_categories.include_relations(products: :product_variants) - render json: supplier, include: %w[ - product_categories - product_categories.products - product_categories.products.product_variants - ] - end + #def supplier + # table = Table.find(params[:id]) + # supplier = table.supplier + # supplier.product_categories.include_relations(products: :product_variants) + # render json: supplier, include: %w[ + # product_categories + # product_categories.products + # product_categories.products.product_variants + # ] + #end # POST /tables/:id/needs_help.json def needs_help @@ -67,6 +67,7 @@ module Users res = {} res[:active_list_present] = true if active_list.present? res[:occupied] = table.occupied? + res[:active] = table.active? res[:reserved] = table.reserved? res[:supplier_closed] = table.supplier.closed? res[:no_product_orders] = true unless product_orders = new_order_product_orders.presence diff --git a/app/models/list/join_requests.rb b/app/models/list/join_requests.rb index 4904b348..556f855f 100644 --- a/app/models/list/join_requests.rb +++ b/app/models/list/join_requests.rb @@ -32,7 +32,10 @@ class List add_user(user) user.save join_request_user_ids_will_change! - save and broadcast_users 'join_request_approved', id: "jr-#{user.id}" + if save + broadcast_users 'join_request_approved', id: "jr-#{user.id}" + broadcast_supplier supplier_id, 'user_joined_list', list_id: id + end end end diff --git a/app/models/table.rb b/app/models/table.rb index 55dec091..64a7e7c5 100644 --- a/app/models/table.rb +++ b/app/models/table.rb @@ -9,6 +9,7 @@ class Table property :needs_help, type: :boolean, default: false property :width, type: Float, default: 0.8 property :height, type: Float, default: 0.8 + property :active, type: :boolean, default: true belongs_to :supplier belongs_to :section diff --git a/app/serializers/suppliers/table_serializer.rb b/app/serializers/suppliers/table_serializer.rb index 6b5df80a..4cbcbd69 100644 --- a/app/serializers/suppliers/table_serializer.rb +++ b/app/serializers/suppliers/table_serializer.rb @@ -1,4 +1,4 @@ class Suppliers::TableSerializer include Qwaiter::SupplierBaseSerializer - attributes :number, :width, :height, :position_x, :position_y, :section_id#, :active_list_id + attributes :number, :width, :height, :position_x, :position_y, :section_id, :active#, :active_list_id end diff --git a/app/serializers/users/supplier_serializer.rb b/app/serializers/users/supplier_serializer.rb index e5c239b4..08b864b5 100644 --- a/app/serializers/users/supplier_serializer.rb +++ b/app/serializers/users/supplier_serializer.rb @@ -2,4 +2,5 @@ class Users::SupplierSerializer include Qwaiter::UserBaseSerializer attributes :open, :name, :orders_placed_count, :orders_in_process_count, :user_message has_many :product_categories, serializer: Users::ProductCategorySerializer + related_link_for :product_categories end diff --git a/app/serializers/users/table_serializer.rb b/app/serializers/users/table_serializer.rb index 0724bbff..e6a91326 100644 --- a/app/serializers/users/table_serializer.rb +++ b/app/serializers/users/table_serializer.rb @@ -1,13 +1,13 @@ class Users::TableSerializer include Qwaiter::UserBaseSerializer - attributes :number, :width, :height, :position_x, :position_y, :section_id, :occupied #, :supplier_id #, :alist_id + attributes :number, :width, :height, :position_x, :position_y, :section_id, :occupied, :active #, :supplier_id #, :alist_id has_one :supplier, serializer: Users::SupplierSerializer #def list_id #object.active_list_id || object.active_list.try(:id) #end - related_link_for :supplier + #related_link_for :supplier #def list #object.active_list #end diff --git a/app/serializers/waiter/table_serializer.rb b/app/serializers/waiter/table_serializer.rb index e4de4c82..fc652ed8 100644 --- a/app/serializers/waiter/table_serializer.rb +++ b/app/serializers/waiter/table_serializer.rb @@ -1,4 +1,4 @@ class Waiter::TableSerializer include Qwaiter::WaiterBaseSerializer - attributes :number, :width, :height, :position_x, :position_y, :section_id, :needs_help + attributes :number, :width, :height, :position_x, :position_y, :section_id, :needs_help, :active end diff --git a/config/application.rb b/config/application.rb index e73575cd..54c6b2bc 100644 --- a/config/application.rb +++ b/config/application.rb @@ -21,6 +21,7 @@ if Rails.env.development? alias_method :old_execute, :execute def execute(method, path, options, payload = nil, &block) Rails.logger.debug "Couch: #{method} #{Rack::Utils.unescape path} #{options}" + puts "Couch: #{method} #{Rack::Utils.unescape path} #{options}" old_execute(method, path, options, payload, &block) end end diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc new file mode 100644 index 00000000..37b74be3 --- /dev/null +++ b/config/credentials.yml.enc @@ -0,0 +1 @@ +qGuAi9ahLUJEShPQPWLZJXisYOSUQbrHQHNK1FAR0WcDIpK108h/2BRj3UHq29kkXffQx/L685yBZ7+M+BkActkD7ewjiZkeTFoVrs04PpRofA6AuCotSdqP2loBBcm90zHZZJ+NHlxGWNl/+LDxx59hQLLW59iyKZer+rUSXZ13PUVKmzq0JdjKlYmKi+GiNv5loZOH/e8v0qjUlrNZSHXpYrCTLesFFOk+TRs7yyWwz0LDzDhzqMTZqGUe9HtDNmocwFnEcXGASxNeV6DL3BgNs3C7TP2fr/3Mzw5DfoS65JhlE1OVjTHl25VuUc9M6+9t/SIBcgwNk/b5CNwSDzrd5JdFhn9DMJKHNQVV42vQ56K7+7LSurWgpf9LogAF+UOTan/oXz1xg4ckDczJTSHAqDrxD0Mtbc/H--OJqRgtqB2Y1zTwMG--umJWjBt94H2enx6iUyRHqw== \ No newline at end of file diff --git a/config/environments/production.rb b/config/environments/production.rb index f81049c8..804431af 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -62,7 +62,7 @@ Qwaiter::Application.configure do # config.cache_store = :mem_cache_store # Enable serving of images, stylesheets, and JavaScripts from an asset server - config.action_controller.asset_host = "https://assets.mozo.bar" + config.assets.asset_host = "https://assets.mozo.bar" # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) # config.assets.precompile += %w( search.js ) diff --git a/config/routes.rb b/config/routes.rb index 30b89d2f..ee0416a2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -78,7 +78,11 @@ Qwaiter::Application.routes.draw do get '/close_window' => 'dashboard#close_window' namespace :users, path: '/user/api/v1' do resources :product_categories, only: [:index] - resources :suppliers, only: [:show] + resources :suppliers do + member do + get :product_categories + end + end resources :lists, only: [:index, :show] do collection do get :current @@ -102,7 +106,6 @@ Qwaiter::Application.routes.draw do post :join post :order_products get :status_info - get :supplier end end end diff --git a/config/secrets.yml b/config/secrets.yml index 2c4b6def..fcc4ffc8 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -19,4 +19,4 @@ test: # Do not keep production secrets in the repository, # instead read values from the environment. production: - secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> + secret_key_base: 9b7e6a299a820824ebe2c4717e0125e7a5c64c6950dbeb1b69389e41121f891ecc97b4a54f272b8aee20fecb42b3cc03e39825333bd9058fb1b4e033ced892a1 diff --git a/faye/rebuild-docker.sh b/faye/rebuild-docker.sh index e710d808..201d390e 100755 --- a/faye/rebuild-docker.sh +++ b/faye/rebuild-docker.sh @@ -15,7 +15,8 @@ fi if [ -d "$certs_dir" ]; then echo "Found certificates directory, copy it to local for inclusion in the docker build" rm -rf $script_dirname/ssl - cp -r $certs_dir $script_dirname/ssl + # Note the -L option for copy is required, since the target are symbolic links and we want the real files + cp -rL $certs_dir $script_dirname/ssl fi # 2. stop and remove all running/existing containers