Upgrades and fixes, maintenance

This commit is contained in:
2014-06-09 19:07:46 +02:00
parent 78a894759b
commit 0e4993e8a6
23 changed files with 87 additions and 57 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
GIT
remote: git://github.com/bterkuile/couch_potato.git
revision: c84d3d8931505cfb3a6c25599e08a5d4b6975168
revision: 6fbcb3edcaf3edec63230308f123c1e03417967d
specs:
couch_potato (0.7.1)
activemodel
@@ -345,7 +345,7 @@ GEM
eventmachine (>= 1.0.0)
rack (>= 1.0.0)
thor (0.19.1)
thread_safe (0.3.3)
thread_safe (0.3.4)
tilt (1.4.1)
tinymce-rails (4.0.26)
railties (>= 3.1.1)
@@ -355,7 +355,7 @@ GEM
turnip (1.2.1)
gherkin (>= 2.5)
rspec (>= 2.0, < 4.0)
tzinfo (1.2.0)
tzinfo (1.2.1)
thread_safe (~> 0.1)
uglifier (2.5.0)
execjs (>= 0.3.0)
@@ -6,11 +6,15 @@ Qsupplier.App.List = DS.Model.extend
user_requests_closing: attr('boolean')
users: DS.hasMany('user')
is_paid: attr 'boolean'
has_active_orders: attr 'boolean'
#has_active_orders: attr 'boolean'
has_active_orders: (->
return false unless @get('state') == 'active'
!!@get('orders').filterProperty('state', 'active').length
).property('state', 'orders.@each.state')
price: attr 'number'
closed_at: DS.attr('date')
#table_number: attr 'number'
table: DS.belongsTo('table', inverse: 'active_list')
#table: DS.belongsTo('table', inverse: 'active_list')
#users: DS.hasMany('user', inverse: 'active_list')
orders: DS.hasMany('order')
section: DS.belongsTo('section')
@@ -18,7 +22,7 @@ Qsupplier.App.List = DS.Model.extend
active: ( -> @get('state') == 'active' ).property('state')
markClosed: ->
@set('state', 'closed')
@set 'has_active_orders', false
#@set 'has_active_orders', false
@markHelped()
@markIsPaid()
markHelped: ->
@@ -7,7 +7,9 @@ Qsupplier.App.Table = DS.Model.extend
position_y: attr 'number'
occupied: attr 'boolean'
section: DS.belongsTo('section')
#active_list: DS.belongsTo('list', key: 'active_list')
active_list: DS.belongsTo('list')
#list: DS.belongsTo('list')
#active_list: (->
#@get('list')
#).property('list')
@@ -1,3 +1,8 @@
Qsupplier.App.ApplicationRoute = Ember.Route.extend
beforeModel: ->
# Preload only active lists and orders
@store.find 'product_category'
#@store.find 'order', state: 'active' included in list
setupController: (controller)->
controller.set 'product_categories', @store.find('product_category')
@store.find 'list', state: 'active'
controller.set 'product_categories', @store.all('product_category')
@@ -1,17 +1,16 @@
Qsupplier.App.IndexRoute = Ember.Route.extend
model: (params, queryParams)->
# Preload only active lists and orders
@store.find 'list', state: 'active'
@store.find 'order', state: 'active'
Ember.Object.create
# Find with condition does not work since the resulting array promise is not updated for newly created records
#lists: Qsupplier.App.List.find({state: 'active'})
#orders: Qsupplier.App.Order.find({state: 'active'})
#lists: @store.filter 'list', (l)-> l.get('state') == 'active' # DOES NOT WORK!!!! (yet)
# use filter to create a scope on all the records
lists: @store.filter 'list', -> true
#lists: @store.filter 'list', -> true
lists: @store.all 'list'
# mayby @store.all 'list' will work better!!!! (2014-04-24 a more experienced benjamin :)
orders: @store.filter 'order', -> true
#orders: @store.filter 'order', -> true
orders: @store.all 'order'
sections: @store.find 'section'
setupController: (controller, model)->
controller.set('model', model)
@@ -1,16 +1,25 @@
$ ->
$('.week-day-toggle').each ->
select = $('#week-day-select-'+$(@).data('day'))
$(@).addClass('active') if select.val() == '1'
$(@).click( -> select.val(Math.abs(select.val() - 1)))
$(@).addClass(if select.val() == '1' then 'active' else 'inactive')
$(@).click ->
new_val = Math.abs(select.val() - 1)
select.val new_val
if new_val == 1
$(@).addClass('active')
$(@).removeClass('inactive')
else
$(@).addClass('inactive')
$(@).removeClass('active')
$('#full_day-controller').each ->
control = $('#product_category_full_day')
if control.is(':checked')
$('#sub-day-container').removeClass('hide')
$(@).removeClass 'active'
else
$('#sub-day-container').addClass('hide')
$(@).addClass('active')
else
$(@).removeClass 'active'
$('#sub-day-container').removeClass('hide')
$(@).click ->
if control.is(':checked')
control.prop 'checked', false
@@ -6,20 +6,24 @@
.name
padding: 5px 5px
#week_days-group
.btn
opacity: 0.4
display: inline-block
.week-day-toggle
margin: 0
&.active
opacity: 1
// nothing for now
&.inactive
opacity: 0.4
#full_day-controller
@extend .fa
@extend .fa-clock-o
margin: 0 10px
color: #f70
span
@extend .fa
@extend .fa-clock-o
margin: 0 10px
color: #f70
&.active
// Full day active is not special, highlight when not active,
// because it indicates the being active of a time range
color: #444
span
// Full day active is not special, highlight when not active,
// because it indicates the being active of a time range
color: #444
#sub-day-container
display: inline-block
&.hide
@@ -27,3 +31,9 @@
select
width: 70px
margin-right: 14px
.product-category-visible-never
@extend .fa
@extend .fa-times
.product-category-visible-always
@extend .fa
@extend .fa-circle-o-notch
+2 -2
View File
@@ -7,8 +7,8 @@ module ProductCategoryDecorator
def visible_on
sum = week_days.sum
return content_tag(:span, '', class: 'icon-eye-close icon-white') if sum.zero?
return content_tag(:span, '', class: 'icon-refresh icon-white') if sum == 7 && full_day
return content_tag(:span, '', class: 'product-category-visible-never') if sum.zero?
return content_tag(:span, '', class: 'product-category-visible-always') if sum == 7 && full_day
day_names = I18n.t('date.day_names')
days = week_days.map.with_index{|v,i| v == 1 ? day_names[i] : nil}.compact
days << days.shift if week_days.first == 1 && supplier.week_starts_on_monday?
+3 -3
View File
@@ -200,7 +200,7 @@ class List
def move_to_table! to_table
UserTableMove.create list: self, from_table_id: table_id, to_table: to_table
from_table = self.table_id.try(:dup)
from_table_id = self.table_id.try(:dup)
self.table = to_table
self.section_id = to_table.section_id
if save
@@ -210,8 +210,8 @@ class List
order.save
end
# user performs a client side refresh
broadcast_users 'list_changed_table', list_id: id #, from_table_id: from_table, to_table_id: to_table.id
broadcast_supplier supplier_id, 'list_changed_table', ListSerializer.new(list).as_json
broadcast_users 'list_changed_table', list_id: id, from_table_id: from_table_id, to_table_id: to_table.id
broadcast_supplier supplier_id, 'list_changed_table', ListSerializer.new(self).as_json
end
end
+1 -1
View File
@@ -119,7 +119,7 @@ class Supplier
end
def self.reset_counters!
# Set all known counters to zero
Qwaiter::Couchbase.design_doc('supplier').counters(reduce: false).each{|counter| Qwaiter::Counter.set counter.key, 0}
spec = Order.by_supplier_id_and_state(reduce: true, group_level: 2)
@@ -1,7 +1,7 @@
class SupplierExtendedTableSerializer < Qwaiter::Serializer
root 'table'
embed :ids, include: true
attributes :number, :width, :height, :position_x, :position_y, :section_id, :occupied #, :alist_id
attributes :number, :width, :height, :position_x, :position_y, :section_id, :occupied, :active_list_id
#def list_id
#object.active_list_id || object.active_list.try(:id)
@@ -11,9 +11,5 @@ class SupplierExtendedTableSerializer < Qwaiter::Serializer
#object.active_list
#end
def list
object.active_list
end
has_one :list, key: :active_list_id, serializer: SupplierExtendedListSerializer
#has_one :list, key: :active_list_id, serializer: SupplierExtendedListSerializer
end
+1 -1
View File
@@ -6,7 +6,7 @@ class SupplierListSerializer < Qwaiter::Serializer
:table_id, :table_number, :section_id, :user_ids, :supplier_id, :closed_at
has_many :orders
#has_many :product_categories
has_one :table, serializer: SupplierTableSerializer
#has_one :table, serializer: SupplierTableSerializer # tables are part of the sectoins load
has_many :join_requests
has_many :users, serializer: SupplierUserSerializer
@@ -18,20 +18,20 @@
.form-label
= label_tag nil, ProductCategory.human_attribute_name(:week_days), class: 'control-label'
.form-field.full
#week_days-group.btn-group data-toggle="buttons-checkbox"
ul#week_days-group.button-group
- day_names = week_days.dup; day_names << day_names.shift if current_supplier.week_starts_on_monday?
- day_names.each do |day_name|
button.week-day-toggle.tiny type="button" data-day=day_name data-t="product_category.week_days.abbreviation.#{day_name}"
li: button.week-day-toggle.tiny type="button" data-day=day_name data-t="product_category.week_days.abbreviation.#{day_name}"
span#full_day-controller
span#full_day-controller: span
#sub-day-container.hide
/= f.input_field :start_from, as: :select, collection: (1..24).map{|h| ["#{h}:00", h*60]}
/= f.input_field :end_on, as: :select, collection: (1..24).map{|h| ["#{h}:00", h*60]}
= f.select :start_from, (1..24).map{|h| ["#{h}:00", h*60]}
= f.select :end_on, (1..24).map{|h| ["#{h}:00", h*60]}
.hidden
- @product_category.week_days.each.with_index do |day, i|
= select_tag 'product_category[week_days][]', options_for_select([0,1], day), class: 'week-day-select', id: "week-day-select-#{week_days[i]}", data: {day: week_days[i] }
/= f.input :full_day, as: :select, collection: [true, false], label: false, include_blank: false
/= f.input_field :full_day, as: :boolean, label: false, wrapper: false
/= f.check_box :full_day
= f.check_box :full_day
= f.supplier_form_actions
+1 -1
View File
@@ -26,4 +26,4 @@ end
# use the connection from couchbase-structures/documents
# will be overwritten in the specs since flushing the real
# thing is difficult
Qwaiter::Counter.connection = $cb
Qwaiter::Counter.connection = $cb unless Rails.env.test?
@@ -29,7 +29,7 @@ end
step "the supplier clicks on the edit product category button" do
within "#product_category_#{@product_category.id}" do
find('.edit-resource-button').click
find('.table-edit').click
end
end
@@ -19,7 +19,7 @@ step "the supplier fills in the new product form selecting the first product cat
end
step "the supplier submits the product form" do
find('.save-product-button').click
find('.form-action-submit').click
end
@@ -38,7 +38,7 @@ end
step "the supplier clicks on the edit product button" do
within ".product-row-#{@product.id}" do
find('.edit-resource-button').click
find('.table-edit').click
end
end
@@ -10,6 +10,7 @@ end
step "the section table should be marked as having an active order" do
table = page.find(".section-table-#{@table.id}")
binding.pry
table['class'].should include 'active_order'
end
@@ -10,7 +10,8 @@ step "the supplier fills in the new table form selecting the first section" do
end
step "the supplier submits the table form" do
find('.save-table-button').click
#find('.save-table-button').click
find('.form-action-submit').click
end
step "the new supplier table with proper properties should have been created" do
@@ -35,12 +35,12 @@ describe ProductCategoryDecorator do
it "shows a dash when it is never visible" do
product_category.stub(:week_days).and_return([0,0,0,0,0,0,0])
subject.visible_on.should include 'icon-eye-close'
subject.visible_on.should include 'product-category-visible-never'
end
it "should display an icon when always visible" do
product_category.stub(:week_days).and_return([1,1,1,1,1,1,1])
subject.visible_on.should include 'icon-refresh'
subject.visible_on.should include 'product-category-visible-always'
end
it "should only display time when all days active and time range given" do
+2
View File
@@ -17,6 +17,7 @@ describe Supplier do
end
it 'cleans counter values if orders are no longer available' do
old_connection = Qwaiter::Counter.connection
# this spec should run on the couchbase database
Qwaiter::Counter.connection = $cb
supplier = create :supplier
@@ -24,6 +25,7 @@ describe Supplier do
supplier.orders_placed_count.should == 9
Supplier.reset_counters!
supplier.orders_placed_count.should == 0
Qwaiter::Counter.connection = old_connection
end
end
+2 -2
View File
@@ -44,8 +44,6 @@ module SpecSelectorHelpers
end
end
# NOT THREADSAFE!!!!!! but good enough for testing since the real couchbase flush is slowwwwww....
Qwaiter::Counter.connection = InMemoryQCounter.new
class Couchbase::View
alias :old_initialize :initialize
def initialize(bucket, endpoint, params = {})
@@ -108,6 +106,8 @@ RSpec.configure do |config|
#config.use_transactional_fixtures = true
config.before :suite do
Qwaiter::Couchbase.load_design_docs!
# NOT THREADSAFE!!!!!! but good enough for testing since the real couchbase flush is slowwwwww....
Qwaiter::Counter.connection = InMemoryQCounter.new
end
config.before :each do
+1
View File
@@ -282,6 +282,7 @@ define("activemodel-adapter/lib/system/active_model_serializer",
*/
keyForRelationship: function(key, kind) {
key = decamelize(key);
//if(key === 'active_list') debugger;
if (kind === "belongsTo") {
return key + "_id";
} else if (kind === "hasMany") {