bbmb 2.0.7 → 2.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 67ee64829561f37c9cf3c4eb2346f7add7bb7092
4
- data.tar.gz: 34b5e99df58800d3193b7d89328a0828ee9501ee
3
+ metadata.gz: c2eb42efa3ac9ef669280070946e16ae722ef14c
4
+ data.tar.gz: 69a025978a868913d8080c42b4ce574a5a1a33aa
5
5
  SHA512:
6
- metadata.gz: 8ffe4cd1c37bca62263f89e50277040889f4ea6b5bce32da42b6308b97a5c60a5e36e295ce06afe6042aa3ee635fb8f372ef42f41124269a7879e6dc9dbb3e2d
7
- data.tar.gz: 4699bbcbddc0678a2dd359a17bd772bda1f89a48b1d25969cb8f9e325fc008005f46e4374023d074c58ea55ebe7a2770b315a01a4e65bab897d84d80ba1aa12c
6
+ metadata.gz: 6aac0c230d1189d36609914bc5a8b495ed3543bf29ecf3563da1efe718ef486da98b8efe32d6924ed54651a5c1b03834ad50e6deb6b9cfb64026fd7847d622f0
7
+ data.tar.gz: e552995962a29f4765599c010b53823362198dac681a328bd2ef5ef4f1aab497312462b9c2bb5d92751a32a42b67fcdafd38f01d5d3add14365b4dfdceabf215
@@ -1,3 +1,9 @@
1
+ === 2.0.8 / 18.07.2016
2
+
3
+ * Replaced Thread.exclusive with Mutex#synchronize
4
+ * Implemented sorting for aktiviert and letztes login columns
5
+ * Append executable permisson to bin commands
6
+
1
7
  === 2.0.7 / 18.07.2016
2
8
 
3
9
  * Fixed search filter
File without changes
File without changes
@@ -1,10 +1,10 @@
1
1
  # Html::State::Customers -- bbmb.ch -- 18.09.2006 -- hwyss@ywesee.com
2
2
 
3
+ require 'ostruct'
3
4
  require 'bbmb/html/state/global_predefine'
4
5
  require 'bbmb/html/state/customer'
5
6
  require 'bbmb/html/view/customers'
6
7
  require 'bbmb/model/customer'
7
- require 'ostruct'
8
8
 
9
9
  module BBMB
10
10
  module Html
@@ -15,13 +15,29 @@ class Customers < Global
15
15
  FILTER = [ :customer_id, :organisation, :plz, :city, :email ]
16
16
  def init
17
17
  start = Time.now
18
- @model = BBMB.persistence.all(Model::Customer)
18
+ @model = BBMB.persistence.all(Model::Customer)
19
19
  @sortby = [:organisation]
20
20
  BBMB.logger.debug('State') {
21
21
  sprintf("Customers#init: loaded %i customers in %1.5fs",
22
22
  @model.size, Time.now - start)
23
23
  }
24
- @filter = Proc.new { |model|
24
+ @filter = make_filter
25
+ end
26
+ def page(model)
27
+ page = OpenStruct.new
28
+ index = @session.user_input(:index).to_i
29
+ step = @session.user.pagestep || BBMB.config.pagestep
30
+ page.index = index
31
+ page.first = index + 1
32
+ page.step = step
33
+ page.total = model.size
34
+ page.customers = model[index, step]
35
+ page.last = index + page.customers.size
36
+ page
37
+ end
38
+ private
39
+ def make_filter
40
+ Proc.new { |model|
25
41
  input = @session.event_bound_user_input(:filter)
26
42
  if input
27
43
  pattern = Regexp.new(input.gsub('*', '.*'), 'ui')
@@ -38,22 +54,27 @@ class Customers < Global
38
54
  }
39
55
  end
40
56
  get_sortby!
57
+ if @sortby.include?(:valid) || @sortby.include?(:last_login)
58
+ # decorates customer objects with (yus) session
59
+ model = model.map { |m| CustomerDecorator.new(m, @session) }
60
+ end
41
61
  model.sort! { |a, b| compare_entries(a, b) }
42
- @sort_reverse && model.reverse!
62
+ @sort_reverse && model.reverse!
43
63
  page(model)
44
64
  }
45
65
  end
46
- def page(model)
47
- page = OpenStruct.new
48
- index = @session.user_input(:index).to_i
49
- step = @session.user.pagestep || BBMB.config.pagestep
50
- page.index = index
51
- page.first = index + 1
52
- page.step = step
53
- page.total = model.size
54
- page.customers = model[index, step]
55
- page.last = index + page.customers.size
56
- page
66
+ end
67
+ class CustomerDecorator < SimpleDelegator
68
+ def initialize(model, session)
69
+ @source = model
70
+ @session = session
71
+ self.__setobj__(@source)
72
+ end
73
+ def last_login
74
+ @last_login ||= @session.user.last_login(email)
75
+ end
76
+ def valid
77
+ @valid ||= @session.user.entity_valid?(email).to_s
57
78
  end
58
79
  end
59
80
  end
@@ -95,10 +95,18 @@ class CustomersList < HtmlGrid::List
95
95
  end
96
96
  =end
97
97
  def last_login(model)
98
- @session.user.last_login(model.email)
98
+ if model.respond_to?(:last_login)
99
+ model.last_login
100
+ else
101
+ @session.user.last_login(model.email)
102
+ end
99
103
  end
100
104
  def valid(model)
101
- @lookandfeel.lookup(@session.user.entity_valid?(model.email).to_s)
105
+ if model.respond_to?(:valid)
106
+ @lookandfeel.lookup(model.valid)
107
+ else
108
+ @lookandfeel.lookup(@session.user.entity_valid?(model.email).to_s)
109
+ end
102
110
  end
103
111
  private
104
112
  def sort_link(header_key, matrix, component)
@@ -7,6 +7,8 @@ require 'bbmb/model/order'
7
7
  module BBMB
8
8
  module Model
9
9
  class Customer
10
+ MUTEX = Mutex.new
11
+
10
12
  attr_reader :customer_id, :email, :archive, :quotas
11
13
  attr_accessor :address1, :address2, :address3, :canton, :city,
12
14
  :drtitle, :ean13, :fax, :firstname, :language, :lastname,
@@ -35,7 +37,7 @@ class Customer
35
37
  ].compact
36
38
  end
37
39
  def commit_order!(commit_time = Time.now)
38
- Thread.exclusive {
40
+ MUTEX.synchronize {
39
41
  id = @archive.keys.max.to_i.next
40
42
  order = current_order
41
43
  order.commit!(id, commit_time)
@@ -72,7 +74,7 @@ class Customer
72
74
  @favorites ||= Order.new(self)
73
75
  end
74
76
  def inject_order(order, commit_time = Time.now)
75
- Thread.exclusive {
77
+ MUTEX.synchronize {
76
78
  id = @archive.keys.max.to_i.next
77
79
  order.commit!(id, commit_time)
78
80
  @archive.store(id, order)
@@ -2,5 +2,5 @@
2
2
  # Bbmb -- bbmb.ch -- 17.12.2019 -- zdavatz@ywesee.com
3
3
 
4
4
  module BBMB
5
- VERSION = '2.0.7'
5
+ VERSION = '2.0.8'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bbmb
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.7
4
+ version: 2.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaomi Hatakeyama, Zeno R.R. Davatz, Niklaus Giger