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 +4 -4
- data/History.txt +6 -0
- data/bin/bbmb_admin +0 -0
- data/bin/update_articles_and_products +0 -0
- data/lib/bbmb/html/state/customers.rb +36 -15
- data/lib/bbmb/html/view/customers.rb +10 -2
- data/lib/bbmb/model/customer.rb +4 -2
- data/lib/bbmb/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2eb42efa3ac9ef669280070946e16ae722ef14c
|
4
|
+
data.tar.gz: 69a025978a868913d8080c42b4ce574a5a1a33aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6aac0c230d1189d36609914bc5a8b495ed3543bf29ecf3563da1efe718ef486da98b8efe32d6924ed54651a5c1b03834ad50e6deb6b9cfb64026fd7847d622f0
|
7
|
+
data.tar.gz: e552995962a29f4765599c010b53823362198dac681a328bd2ef5ef4f1aab497312462b9c2bb5d92751a32a42b67fcdafd38f01d5d3add14365b4dfdceabf215
|
data/History.txt
CHANGED
data/bin/bbmb_admin
CHANGED
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
|
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 =
|
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
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
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
|
-
|
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
|
-
|
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)
|
data/lib/bbmb/model/customer.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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)
|
data/lib/bbmb/version.rb
CHANGED