diff --git a/Gemfile b/Gemfile index e26b3096..f07a3ecc 100644 --- a/Gemfile +++ b/Gemfile @@ -11,11 +11,6 @@ gem 'exception_notification' gem 'slim-rails' # Gems used only for assets and not required -# in production environments by default. -#gem 'active_model_serializers', '~> 0.10.0.rc2' # explicitly outside assets -#gem 'active_model_serializers', github: 'rails-api/active_model_serializers' # explicitly outside assets -#gem 'active_model_serializers', '0.9.3' # explicitly outside assets -#gem 'jsonapi-serializers', github: 'bterkuile/jsonapi-serializers' #gem 'jsonapi-serializers', path: '/home/benjamin/development/rails/components/jsonapi-serializers' gem 'jsonapi-serializers', github: 'bterkuile/jsonapi-serializers' group :assets do @@ -62,8 +57,8 @@ end # gem 'couchbase-structures', github: 'bterkuile/couchbase-structures' gem 'couch_potato', '~> 1.4.0' #, github: 'bterkuile/couch_potato' -gem 'simply_stored', path: '~/development/rails/components/simply_stored' #, github: 'bterkuile/simply_stored' -#gem 'simply_stored', github: 'bterkuile/simply_stored' +#gem 'simply_stored', path: '~/development/rails/components/simply_stored' #, github: 'bterkuile/simply_stored' +gem 'simply_stored', github: 'bterkuile/simply_stored' #gem 'orm_adapter', github: 'bterkuile/orm_adapter' gem 'devise' #, github: 'plataformatec/devise', branch: 'lm-rails-4-2' #, '3.1.0' #, '2.0.4' gem 'devise_simply_stored', github: 'bterkuile/devise_simply_stored' diff --git a/Gemfile.lock b/Gemfile.lock index 4cebebb3..00a05192 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -28,12 +28,13 @@ GIT jsonapi-serializers (0.2.6) activesupport -PATH - remote: ~/development/rails/components/simply_stored +GIT + remote: git://github.com/bterkuile/simply_stored.git + revision: 91652b8228c368b12acb80c77439a35059ecaaa8 specs: simply_stored (1.0.0) activesupport - couch_potato (>= 0.2.15) + couch_potato (>= 1.4.0) rest-client (>= 1.4.2) GEM diff --git a/app/models/order.rb b/app/models/order.rb index da690e42..9690d674 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -29,6 +29,7 @@ class Order view :by_supplier_id_and_id, key: [:supplier_id, :_id] # Do not comment me out this is for security, TODO: make the security server side for speed and space optimization view :by_supplier_id_and_state, key: [:supplier_id, :state], reduce_function: '_sum' + view :by_list_id, key: :list_id def self.for_supplier(supplier, options = {}) total_entries = database.view(by_supplier_id_and_id({startkey: ["#{supplier.id}\u9999"], endkey: [supplier.id], include_docs: false, reduce: true, descending: true})) diff --git a/app/models/section_area.rb b/app/models/section_area.rb index 75fe87e8..edd91074 100644 --- a/app/models/section_area.rb +++ b/app/models/section_area.rb @@ -12,6 +12,7 @@ class SectionArea belongs_to :supplier view :by_supplier_id, key: :supplier_id + view :by_section_id, key: :section_id def self.for_supplier(supplier) find_all_by_supplier_id(supplier.id) diff --git a/app/models/section_element.rb b/app/models/section_element.rb index 6f17b062..796ce197 100644 --- a/app/models/section_element.rb +++ b/app/models/section_element.rb @@ -10,6 +10,7 @@ class SectionElement belongs_to :svg_element view :by_supplier_id, key: :supplier_id + view :by_section_id, key: :section_id def self.for_supplier(supplier) find_all_by_supplier_id(supplier.id) diff --git a/app/models/table.rb b/app/models/table.rb index 35cdf914..8771018a 100644 --- a/app/models/table.rb +++ b/app/models/table.rb @@ -22,6 +22,7 @@ class Table validates :number, numericality: true #{greater_than: 0} view :by_supplier_id_and_id, key: [:supplier_id, :_id] view :by_supplier_id_and_number, key: [:supplier_id, :number] + view :by_section_id, key: :section_id #validates_uniqueness_of :number view :by_number, key: :number diff --git a/app/serializers/employees/employee_serializer.rb b/app/serializers/employees/employee_serializer.rb new file mode 100644 index 00000000..3a8043d1 --- /dev/null +++ b/app/serializers/employees/employee_serializer.rb @@ -0,0 +1,4 @@ +class Employees::EmployeeSerializer + include Qwaiter::EmployeeBaseSerializer + attributes :name, :email, :manager, :active, :color +end diff --git a/app/serializers/employees/employee_shift_serializer.rb b/app/serializers/employees/employee_shift_serializer.rb index 69f2c4da..80383112 100644 --- a/app/serializers/employees/employee_shift_serializer.rb +++ b/app/serializers/employees/employee_shift_serializer.rb @@ -1,6 +1,6 @@ class Employees::EmployeeShiftSerializer include Qwaiter::EmployeeBaseSerializer attributes :start_from, :end_on, :description - has_one :supplier - has_one :employee + has_one :supplier, serializer: Employees::SupplierSerializer + has_one :employee, serializer: Employees::EmployeeSerializer end diff --git a/lib/qwaiter/employee_base_serializer.rb b/lib/qwaiter/employee_base_serializer.rb index 26c440f5..81cbc81d 100644 --- a/lib/qwaiter/employee_base_serializer.rb +++ b/lib/qwaiter/employee_base_serializer.rb @@ -11,15 +11,15 @@ module Qwaiter::EmployeeBaseSerializer nil end - def format_name(attribute_name) - #attribute_name.to_s.dasherize - attribute_name.to_s - end + #def format_name(attribute_name) + # #attribute_name.to_s.dasherize + # attribute_name.to_s + #end - def unformat_name(attribute_name) - #attribute_name.to_s.underscore - attribute_name.to_s - end + #def unformat_name(attribute_name) + # #attribute_name.to_s.underscore + # attribute_name.to_s + #end #alias_method :default_relationship_related_link, :relationship_related_link def relationship_related_link(attribute_name) diff --git a/lib/qwaiter/supplier_base_serializer.rb b/lib/qwaiter/supplier_base_serializer.rb index 4334ee7f..7bf0d37e 100644 --- a/lib/qwaiter/supplier_base_serializer.rb +++ b/lib/qwaiter/supplier_base_serializer.rb @@ -11,13 +11,13 @@ module Qwaiter::SupplierBaseSerializer nil end - def format_name(attribute_name) - attribute_name.to_s.dasherize - end + #def format_name(attribute_name) + # attribute_name.to_s.dasherize + #end - def unformat_name(attribute_name) - attribute_name.to_s.underscore - end + #def unformat_name(attribute_name) + # attribute_name.to_s.underscore + #end #alias_method :default_relationship_related_link, :relationship_related_link def relationship_related_link(attribute_name) diff --git a/lib/qwaiter/user_base_serializer.rb b/lib/qwaiter/user_base_serializer.rb index 9c3b4226..e3efa570 100644 --- a/lib/qwaiter/user_base_serializer.rb +++ b/lib/qwaiter/user_base_serializer.rb @@ -12,15 +12,15 @@ module Qwaiter::UserBaseSerializer nil end - def format_name(attribute_name) - #attribute_name.to_s.dasherize - attribute_name.to_s - end + #def format_name(attribute_name) + # #attribute_name.to_s.dasherize + # attribute_name.to_s + #end - def unformat_name(attribute_name) - #attribute_name.to_s.underscore - attribute_name.to_s - end + #def unformat_name(attribute_name) + # #attribute_name.to_s.underscore + # attribute_name.to_s + #end #alias_method :default_relationship_related_link, :relationship_related_link def relationship_related_link(attribute_name)