bbmb 2.1.8 → 2.1.9

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: 702ceb3e0e1946a527ab2c659f28c75e0a2c97d9
4
- data.tar.gz: ffeb8fe8bdd1391bb3b164efcbed9921a8e45bbf
3
+ metadata.gz: 02ac82813c6ae6fe3a129dc874acd6135b85147a
4
+ data.tar.gz: 2651afaf8bce34e014edc3f1db4bf893b5601ee8
5
5
  SHA512:
6
- metadata.gz: ba0abb06a32f248d24ac11d2ec49e3920ea738e32f48564464664099e206485badc27bf37212c7ec293ed8659bb61a17600a77d932b9f87657fd043c5e7bea7d
7
- data.tar.gz: 5b01e5c6bae2b33a441e0035dc85b6d3453ff47e397d9b85d751af0fc54c557b8c8dcdcf0a871639e626330f25f2a200a9170bb6a947be87b52238c96b70eff3
6
+ metadata.gz: fac65074880f3c4204c1a79248498a024220726579fd22ccc432a82ea37d1493d25bee4714bdfcc2704749a265b9872e9eee23e3b3b6f53f65a29a07de170293
7
+ data.tar.gz: a133950797b7b90f42efdbf523cd8fe7e9f4728d6be360517274fe013dd131b785305b41b5a4af136b241e00a3a8f68a8e4dffc1ec270a5b6af1c121d5109cac
@@ -1,3 +1,8 @@
1
+ === 2.1.9 / 17.05.2017
2
+
3
+ * Trying to set a customer to an already existing e-mail-address fails correctly
4
+ (Pending: When no customer with the given e-mail exists, allow it)
5
+
1
6
  === 2.1.8 / 17.05.2017
2
7
 
3
8
  * Fix logging the number of imported items
@@ -21,26 +21,18 @@ class Session < SBSM::Session
21
21
  SERVER_NAME = uri.host
22
22
  end
23
23
  attr_reader :email, :pass, :auth_session
24
- def initializexx(app:, cookie_name:, trans_handler:, validator:)
25
- super(app, cookie_name, trans_handler, validator)
26
- end
27
24
  def login
28
25
  @email = user_input(:email)
29
26
  @password = user_input(:pass)
30
- # @user.respond_to?(:session=)) is FALSE!!!!
31
27
  @user.session = self if(@user.respond_to?(:session=))
32
28
  # Before rack: @user = @app.login(user_input(:email), user_input(:pass))
33
- @auth = DRb::DRbObject.new(nil, BBMB.config.auth_url)
34
- @auth_session = @auth.login(user_input(:email), user_input(:pass), BBMB.config.auth_domain) # logs in claude meier without problem, but not admin
29
+ @auth_session = BBMB.auth.login(user_input(:email), user_input(:pass), BBMB.config.auth_domain) # logs in claude meier without problem, but not admin
35
30
  if @auth_session.valid?
36
31
  @user = BBMB::Html::Util::KnownUser.new(self) # TODO:Should we set it already in the initialize method?
37
32
  else
38
33
  @user = SBSM::UnknownUser
39
34
  end
40
- SBSM.info "BBMB::Html::Util::Session login #{user_input(:email)} #{user_input(:pass)} #{@user.class} @auth #{@auth} auth_session #{@auth_session}"
41
- pp @auth
42
- pp @auth_session
43
- pp @user
35
+ SBSM.info "BBMB::Html::Util::Session login #{user_input(:email)} #{user_input(:pass)} #{@user.class} BBMB.auth #{BBMB.auth} auth_session #{@auth_session}"
44
36
  @user
45
37
  end
46
38
  def logout
@@ -27,29 +27,27 @@ module BBMB
27
27
  module Util
28
28
  class App < SBSM::App
29
29
  attr_accessor :db_manager, :yus_server
30
- attr_accessor :auth, :config, :persistence, :server
31
-
32
30
  def start_service
33
31
  case BBMB.config.persistence
34
32
  when 'odba'
35
33
  DRb.install_id_conv ODBA::DRbIdConv.new
36
- @persistence = BBMB::Persistence::ODBA
34
+ BBMB.persistence = BBMB::Persistence::ODBA
37
35
  end
38
- @auth = DRb::DRbObject.new(nil, BBMB.config.auth_url)
39
- puts "installed @auth #{@auth}"
40
- @server = BBMB::Util::Server.new(@persistence, self)
41
- @server.extend(DRbUndumped)
42
- BBMB.server = @server
36
+ BBMB.auth = DRb::DRbObject.new(nil, BBMB.config.auth_url)
37
+ puts "installed BBMB.auth for #{BBMB.config.auth_url}"
38
+ BBMB.server = BBMB::Util::Server.new(BBMB.persistence, self)
39
+ BBMB.server.extend(DRbUndumped)
40
+ BBMB.server = BBMB.server
43
41
  puts "installed BBMB.server #{BBMB.server}"
44
42
  if(BBMB.config.update?)
45
- @server.run_updater
43
+ BBMB.server.run_updater
46
44
  end
47
45
  if(BBMB.config.invoice?)
48
- @server.run_invoicer
46
+ BBMB.server.run_invoicer
49
47
  end
50
48
  url = BBMB.config.server_url
51
49
  url.untaint
52
- DRb.start_service(url, @server)
50
+ DRb.start_service(url, BBMB.server)
53
51
  $SAFE = 1
54
52
  $0 = BBMB.config.name
55
53
  SBSM.logger.info('start') { sprintf("starting bbmb-server on %s", url) }
@@ -66,15 +64,6 @@ module BBMB
66
64
  start_service
67
65
  }
68
66
  end
69
- def login(email, pass)
70
- session = BBMB.auth.login(email, pass, BBMB.config.auth_domain)
71
- Html::Util::KnownUser.new(session)
72
- end
73
- def logout(session)
74
- # Here we start when logging in from the home page
75
- BBMB.auth.logout(session)
76
- rescue DRb::DRbError, RangeError, NameError
77
- end
78
67
  end
79
68
  end
80
69
  end
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+ # Util::Server -- de.bbmb.org -- 01.09.2006 -- hwyss@ywesee.com
3
+
4
+ require 'bbmb/config'
5
+ require 'bbmb/html/util/known_user'
6
+ require 'bbmb/html/util/session'
7
+ require 'bbmb/html/util/validator'
8
+ require 'bbmb/util/invoicer'
9
+ require 'bbmb/util/invoicer'
10
+ require 'bbmb/util/mail'
11
+ require 'bbmb/model/order' # needed to be enable to invoice later
12
+ require 'bbmb/model/customer'
13
+ require 'date'
14
+ require 'sbsm/app'
15
+ require 'bbmb/persistence/odba'
16
+ require 'bbmb/model/customer'
17
+ require 'bbmb/model/quota'
18
+ require 'bbmb/model/product'
19
+ require 'bbmb/model/promotion'
20
+
21
+ module BBMB
22
+ module Util
23
+ class RackInterface < SBSM::RackInterface
24
+ ENABLE_ADMIN = true
25
+ SESSION = Html::Util::Session
26
+ VALIDATOR = Html::Util::Validator
27
+ def initialize(app: BBMB::Util::App.new,
28
+ auth: nil,
29
+ validator: BBMB::Html::Util::Validator)
30
+ [ File.join(Dir.pwd, 'etc', 'config.yml'),
31
+ ].each do |config_file|
32
+ if File.exist?(config_file)
33
+ SBSM.info "BBMB.config.load from #{config_file}"
34
+ BBMB.config.load (config_file)
35
+ break
36
+ end
37
+ end
38
+ @app = app
39
+ super(app: app,
40
+ session_class: BBMB::Html::Util::Session,
41
+ unknown_user: Html::Util::KnownUser,
42
+ validator: validator,
43
+ cookie_name: 'virbac.bbmb'
44
+ )
45
+ end
46
+ end
47
+ end
48
+ end
@@ -45,7 +45,7 @@ module BBMB
45
45
  end
46
46
  def rename_user(old_name, new_name)
47
47
  return if old_name.eql?(new_name)
48
- @app.auth.autosession(BBMB.config.auth_domain) do |session|
48
+ BBMB.auth.autosession(BBMB.config.auth_domain) do |session|
49
49
  if(old_name.nil?)
50
50
  session.create_entity(new_name)
51
51
  else
@@ -92,120 +92,5 @@ module BBMB
92
92
  }
93
93
  end
94
94
  end
95
- class RackInterface < SBSM::RackInterface
96
- ENABLE_ADMIN = true
97
- SESSION = Html::Util::Session
98
- VALIDATOR = Html::Util::Validator
99
- attr_reader :updater, :auth
100
- def initialize(app: BBMB::Util::App.new,
101
- auth: nil,
102
- validator: BBMB::Html::Util::Validator)
103
- [ File.join(Dir.pwd, 'etc', 'config.yml'),
104
- ].each do |config_file|
105
- if File.exist?(config_file)
106
- SBSM.info "BBMB.config.load from #{config_file}"
107
- BBMB.config.load (config_file)
108
- break
109
- end
110
- end
111
- @auth = DRb::DRbObject.new(nil, BBMB.config.auth_url)
112
- @app = app
113
- super(app: app,
114
- session_class: BBMB::Html::Util::Session,
115
- unknown_user: Html::Util::KnownUser,
116
- validator: validator,
117
- cookie_name: 'virbac.bbmb'
118
- )
119
- end
120
- def inject_order(customer_id, products, infos, opts={})
121
- customer = Model::Customer.find_by_customer_id(customer_id) \
122
- || Model::Customer.find_by_ean13(customer_id)
123
- needed_create = false
124
- unless customer
125
- if idtype = opts[:create_missing_customer] && !customer_id.empty?
126
- customer = Model::Customer.new(customer_id)
127
- if idtype.to_s == 'ean13'
128
- customer.ean13 = customer_id
129
- end
130
- BBMB.persistence.save(customer)
131
- needed_create = true
132
- else
133
- raise "Unknown Customer #{customer_id}"
134
- end
135
- end
136
- order = Model::Order.new(customer)
137
- products.each { |info|
138
- if(product = Model::Product.find_by_pcode(info[:pcode]) \
139
- || Model::Product.find_by_ean13(info[:ean13]) \
140
- || Model::Product.find_by_article_number(info[:article_number]))
141
- order.add(info[:quantity], product)
142
- [:article_number, :backorder].each do |key|
143
- info.store key, product.send(key)
144
- end
145
- info.store :description, product.description.de
146
- info[:deliverable] = info[:quantity]
147
- else
148
- info[:deliverable] = 0
149
- end
150
- }
151
- infos.each { |key, value|
152
- order.send("#{key}=", value)
153
- }
154
- customer.inject_order(order)
155
- if opts[:deliver]
156
- async do
157
- send_order order, customer
158
- end
159
- end
160
- if needed_create
161
- BBMB::Util::Mail.notify_inject_error(order, opts)
162
- end
163
- { :order_id => order.order_id, :products => products }
164
- end
165
- def login(email, pass)
166
- session = BBMB.auth.login(email, pass, BBMB.config.auth_domain)
167
- Html::Util::KnownUser.new(session)
168
- end
169
- def logout(session)
170
- BBMB.auth.logout(session)
171
- rescue DRb::DRbError, RangeError, NameError
172
- end
173
- def rename_user(old_name, new_name)
174
- return if old_name.eql?(new_name)
175
- BBMB.auth.autosession(BBMB.config.auth_domain) do |session|
176
- if(old_name.nil?)
177
- session.create_entity(new_name)
178
- else
179
- session.rename(old_name, new_name)
180
- end
181
- end
182
- end
183
- def send_order order, customer
184
- begin
185
- Timeout.timeout(300) {
186
- BBMB::Util::TargetDir.send_order(order)
187
- }
188
- rescue StandardError => err
189
- err.message << " (Email: #{customer.email} - Customer-Id: #{customer.customer_id})"
190
- BBMB::Util::Mail.notify_error(err)
191
- end
192
- begin
193
- Timeout.timeout(300) {
194
- BBMB::Util::Mail.send_order(order)
195
- }
196
- rescue StandardError => err
197
- err.message << " (Email: #{customer.email} - Customer-Id: #{customer.customer_id})"
198
- BBMB::Util::Mail.notify_error(err)
199
- end
200
- begin
201
- Timeout.timeout(300) {
202
- BBMB::Util::Mail.send_confirmation(order)
203
- }
204
- rescue StandardError => err
205
- err.message << " (Email: #{customer.email} - Customer-Id: #{customer.customer_id})"
206
- BBMB::Util::Mail.notify_error(err)
207
- end
208
- end
209
- end
210
95
  end
211
96
  end
@@ -1,3 +1,3 @@
1
1
  module BBMB
2
- VERSION = '2.1.8'
2
+ VERSION = '2.1.9'
3
3
  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.1.8
4
+ version: 2.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaomi Hatakeyama, Zeno R.R. Davatz, Niklaus Giger
@@ -421,6 +421,7 @@ files:
421
421
  - lib/bbmb/util/numbers.rb
422
422
  - lib/bbmb/util/password_generator.rb
423
423
  - lib/bbmb/util/polling_manager.rb
424
+ - lib/bbmb/util/rack_interface.rb
424
425
  - lib/bbmb/util/server.rb
425
426
  - lib/bbmb/util/target_dir.rb
426
427
  - lib/bbmb/util/transfer_dat.rb