c80_shared 0.1.38 → 0.1.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe910329bcff3b21b0e4f5426362fee42c56a70cfe2dc0d253c65f3b96eb76c5
4
- data.tar.gz: 4721fee3ab0be6dbf2a84e2acfca44400f96f0cc07e1dbfded0a7876b0181475
3
+ metadata.gz: d59448f06caa5565bd1789750343b0f14d15473d164ffbe47d8950e0927c75b8
4
+ data.tar.gz: 92ecb6ca525b561ea10b69c0bcde1e5b361e8a973b29bc6c237c9ee6bd443742
5
5
  SHA512:
6
- metadata.gz: 1da074bf84e3f1297a73107c335ca9b5cc65a9ccdf8f22146c2bf26646332fd5971d2dbc6294be84bfd969d5ab1bae445e4dbcd4a9aa60c9899d3f7b5c0df5da
7
- data.tar.gz: 17619064f8a7614206a951b5104a3236e553fee64de05685cdc1b302527bdc7b3bbd2ba72b3ef0fd1ea7c6d89653ee3ad88da9c3db05016faa84bd754b8b7abf
6
+ metadata.gz: a7dbbb0f5cf2c6ce18bf170cf305e9ef710ae04f8fcc55886bc3b33a1ea3db65e3272c5b8b725c39414a39ce8ccf1171a2acc202405a95a7f14ef3bd2ff671c6
7
+ data.tar.gz: c87b8bba8dd1a9de71d7809a412eb877e796427f0827d003fb116d21c68a011a4f35b7ec1358885048ffa73ebdc486097721c8c1cf350fbad4c139d212de5b68
@@ -7,5 +7,6 @@ module Dicts
7
7
  SAILING = new(11, 'sailing')
8
8
  CATAMARAN = new(12, 'catamaran')
9
9
  MEGA_YACHT = new(13, 'mega_yacht')
10
+ EXPLORER = new(17, 'explorer')
10
11
  end
11
12
  end
@@ -5,18 +5,12 @@ class BoatSerializer < AbstractSerializer
5
5
  %i[
6
6
  boat_beam
7
7
  boat_beam_metrics
8
- boat_beam_metrics_ft
9
- boat_beam_metrics_meters
10
8
  boat_contacts
11
9
  boat_draft
12
10
  boat_draft_metrics
13
- boat_draft_metrics_ft
14
- boat_draft_metrics_meters
15
11
  boat_hull_id
16
12
  boat_length
17
13
  boat_length_metrics
18
- boat_length_metrics_ft
19
- boat_length_metrics_meters
20
14
  boat_model
21
15
  boat_photos
22
16
  boat_type
@@ -24,9 +18,13 @@ class BoatSerializer < AbstractSerializer
24
18
  builder
25
19
  built_year
26
20
  crew_total
21
+ crew_cabins
27
22
  description
28
23
  exterior_color
24
+ equipment
29
25
  guest_cabins
26
+ guest_heads
27
+ guest_sleeps
30
28
  guests_total
31
29
  hull_material
32
30
  id
@@ -34,6 +32,7 @@ class BoatSerializer < AbstractSerializer
34
32
  latitude
35
33
  location_address
36
34
  longitude
35
+ maximum_guests_during_cruise
37
36
  main_boat_photo_id
38
37
  motor
39
38
  motor_id
@@ -47,6 +46,7 @@ class BoatSerializer < AbstractSerializer
47
46
  sale_price
48
47
  short_description
49
48
  state
49
+ toys
50
50
  visits_today
51
51
  visits_total
52
52
  ].freeze
@@ -68,16 +68,76 @@ class BoatSerializer < AbstractSerializer
68
68
  result
69
69
  end
70
70
 
71
- def id(boat)
72
- { id: boat.id }
71
+ # определяем "простые" методы
72
+ %i[id comments tender name description built_year boat_model location_address latitude longitude boat_type_id boat_hull_id refit_year
73
+ crew_cabins crew_total guest_heads guest_sleeps maximum_guests_during_cruise interior_designer
74
+ naval_architect guests_total guest_cabins state visits_today visits_total].each do |f|
75
+ define_method f do |boat|
76
+ { f => boat.send(f) }
77
+ end
78
+ end
79
+
80
+ def toys_attributes
81
+ %i[
82
+ banana
83
+ beach_kids_toys
84
+ donut
85
+ exercise_equipment
86
+ fishing_gear
87
+ flyboard
88
+ inflatable_sailboat
89
+ jet_ski
90
+ kayak
91
+ kneeboard
92
+ paddle_boards
93
+ sailing_boat
94
+ scuba_tanks
95
+ skiboard
96
+ snorkelling_gear
97
+ stand_up_jet_ski
98
+ underwater_gear
99
+ wakeboard
100
+ water_ski
101
+ windsurfing_board
102
+ ].freeze
73
103
  end
74
104
 
75
- def interior_designer(boat)
76
- { interior_designer: boat.interior_designer }
105
+ def toys(boat)
106
+ {
107
+ toys: toys_attributes.map do |f|
108
+ [f, boat.send(f)]
109
+ end.to_h
110
+ }
77
111
  end
78
112
 
79
- def naval_architect(boat)
80
- { naval_architect: boat.naval_architect }
113
+ def equipment_attributes
114
+ %i[
115
+ apple_tv
116
+ autopilot
117
+ cd_player
118
+ chartplotter
119
+ cockpit_loudspeakers
120
+ entertainment
121
+ excellent_sound_system
122
+ gps
123
+ internet
124
+ lcd_tv
125
+ navigation
126
+ radar
127
+ satellite_internet
128
+ satellite_phone
129
+ tv
130
+ vhf
131
+ wi_fi
132
+ ]
133
+ end
134
+
135
+ def equipment(boat)
136
+ {
137
+ equipment: equipment_attributes.map do |f|
138
+ [f, boat.send(f)]
139
+ end.to_h
140
+ }
81
141
  end
82
142
 
83
143
  # noinspection RubyResolve
@@ -91,10 +151,6 @@ class BoatSerializer < AbstractSerializer
91
151
  { picture_medium_url: url }
92
152
  end
93
153
 
94
- def name(boat)
95
- { name: boat.name }
96
- end
97
-
98
154
  def motor(boat)
99
155
  m = ::Dicts::Motor.find boat.motor
100
156
  {
@@ -117,10 +173,6 @@ class BoatSerializer < AbstractSerializer
117
173
  { builder: boat.builder&.strip }
118
174
  end
119
175
 
120
- def description(boat)
121
- { description: boat.description }
122
- end
123
-
124
176
  def short_description(boat)
125
177
  attr = 'short_description_%s' % @opts[:locale]
126
178
  value = boat.send(attr.to_sym)
@@ -168,14 +220,6 @@ class BoatSerializer < AbstractSerializer
168
220
  # { price_discount: value }
169
221
  # end
170
222
 
171
- def guests_total(boat)
172
- { guests_total: boat.guests_total }
173
- end
174
-
175
- def guest_cabins(boat)
176
- { guest_cabins: boat.guest_cabins }
177
- end
178
-
179
223
  def hull_material(boat)
180
224
  hm = ::Dicts::HullMaterial.find boat.hull_material
181
225
  {
@@ -196,39 +240,6 @@ class BoatSerializer < AbstractSerializer
196
240
  }
197
241
  end
198
242
 
199
- def crew_total(boat)
200
- { crew_total: boat.crew_total }
201
- end
202
-
203
- def built_year(boat)
204
- { built_year: boat.built_year }
205
- end
206
-
207
- def refit_year(boat)
208
- value = boat.refit_year
209
- { refit_year: value }
210
- end
211
-
212
- def boat_model(boat)
213
- { boat_model: boat.boat_model }
214
- end
215
-
216
- def location_address(boat)
217
- { location_address: boat.location_address }
218
- end
219
-
220
- def latitude(boat)
221
- { latitude: boat.latitude }
222
- end
223
-
224
- def longitude(boat)
225
- { longitude: boat.longitude }
226
- end
227
-
228
- def boat_type_id(boat)
229
- { boat_type_id: boat.boat_type_id }
230
- end
231
-
232
243
  def boat_type(boat)
233
244
  {
234
245
  boat_type: {
@@ -238,6 +249,27 @@ class BoatSerializer < AbstractSerializer
238
249
  }
239
250
  end
240
251
 
252
+ # для формы редактирования в кабинете агента
253
+ def boat_beam_metrics(boat)
254
+ {
255
+ boat_beam_metrics: {
256
+ value: boat.send('boat_beam_metrics_%s' % @opts[:uol]),
257
+ uol: @opts[:uol]
258
+ }
259
+ }
260
+ end
261
+
262
+ # для формы редактирования в кабинете агента
263
+ def boat_draft_metrics(boat)
264
+ {
265
+ boat_draft_metrics: {
266
+ value: boat.send('boat_draft_metrics_%s' % @opts[:uol]),
267
+ uol: @opts[:uol]
268
+ }
269
+ }
270
+ end
271
+
272
+ # используется в списке лодок агента, в preview-блоке на сайте
241
273
  def boat_length(boat)
242
274
  {
243
275
  boat_length: {
@@ -247,13 +279,12 @@ class BoatSerializer < AbstractSerializer
247
279
  }
248
280
  end
249
281
 
250
- # [bcff00da] : вся подобная логика переезжает во фронт, переделано должно быть по образу `def boat_length`
282
+ # для формы редактирования в кабинете агента
283
+ def boat_length_metrics(boat)
284
+ { boat_length_metrics: boat_length(boat)[:boat_length] }
285
+ end
251
286
 
252
- # TODO:: [bcff00da] УДАЛИТЬ
253
- # def boat_length_metrics(boat)
254
- # value = ::Lib::Boats::Dimensions.boatlength(boat, @opts[:uol])
255
- # { boat_length_metrics: value }
256
- # end
287
+ # [bcff00da] : вся подобная логика переезжает во фронт, переделано должно быть по образу `def boat_length`
257
288
 
258
289
  # TODO:: [bcff00da] УДАЛИТЬ - пока используется при обновлении/создании лодки в админке
259
290
  def boat_length_metrics_meters(boat)
@@ -265,42 +296,6 @@ class BoatSerializer < AbstractSerializer
265
296
  { boat_length_metrics_ft: boat.boat_length_metrics_ft }
266
297
  end
267
298
 
268
- # TODO:: [bcff00da] УДАЛИТЬ
269
- # def boat_beam_metrics(boat)
270
- # value = ::Lib::Boats::Dimensions.boatbeam(boat, @opts[:uol])
271
- # { boat_beam_metrics: value }
272
- # end
273
-
274
- # TODO:: [bcff00da] УДАЛИТЬ
275
- # def boat_beam_metrics_ft(boat)
276
- # { boat_beam_metrics_ft: boat.boat_beam_metrics_ft }
277
- # end
278
-
279
- # TODO:: [bcff00da] УДАЛИТЬ
280
- # def boat_beam_metrics_meters(boat)
281
- # { boat_beam_metrics_meters: boat.boat_beam_metrics_meters }
282
- # end
283
-
284
- # TODO:: [bcff00da] УДАЛИТЬ
285
- # def boat_draft_metrics(boat)
286
- # value = ::Lib::Boats::Dimensions.boatdraft(boat, @opts[:uol])
287
- # { boat_draft_metrics: value }
288
- # end
289
-
290
- # TODO:: [bcff00da] УДАЛИТЬ
291
- # def boat_draft_metrics_ft(boat)
292
- # { boat_draft_metrics_ft: boat.boat_draft_metrics_ft }
293
- # end
294
-
295
- # TODO:: [bcff00da] УДАЛИТЬ
296
- # def boat_draft_metrics_meters(boat)
297
- # { boat_draft_metrics_meters: boat.boat_draft_metrics_meters }
298
- # end
299
-
300
- def boat_hull_id(boat)
301
- { boat_hull_id: boat.boat_hull_id }
302
- end
303
-
304
299
  def prices(boat)
305
300
  currency_id = ::Dicts::Currency.find_by_index(@opts[:currency]).id
306
301
  business = ::Dicts::Business.find_by_index @opts[:business]
@@ -342,162 +337,6 @@ class BoatSerializer < AbstractSerializer
342
337
  }
343
338
  end
344
339
 
345
- # --[low]-----------------------------------------------------------------------------------------------------------
346
-
347
- # def charter_1_hour_low_usd(boat)
348
- # { charter_1_hour_low_usd: boat.charter_1_hour_low_usd }
349
- # end
350
- #
351
- # def charter_1_hour_low_rub(boat)
352
- # { charter_1_hour_low_rub: boat.charter_1_hour_low_rub }
353
- # end
354
- #
355
- # def charter_1_hour_low_eur(boat)
356
- # { charter_1_hour_low_eur: boat.charter_1_hour_low_eur }
357
- # end
358
- #
359
- # def charter_1_day_low_usd(boat)
360
- # { charter_1_day_low_usd: boat.charter_1_day_low_usd }
361
- # end
362
- #
363
- # def charter_1_day_low_rub(boat)
364
- # { charter_1_day_low_rub: boat.charter_1_day_low_rub }
365
- # end
366
- #
367
- # def charter_1_day_low_eur(boat)
368
- # { charter_1_day_low_eur: boat.charter_1_day_low_eur }
369
- # end
370
- #
371
- # def charter_1_week_low_usd(boat)
372
- # { charter_1_week_low_usd: boat.charter_1_week_low_usd }
373
- # end
374
- #
375
- # def charter_1_week_low_rub(boat)
376
- # { charter_1_week_low_rub: boat.charter_1_week_low_rub }
377
- # end
378
- #
379
- # def charter_1_week_low_eur(boat)
380
- # { charter_1_week_low_eur: boat.charter_1_week_low_eur }
381
- # end
382
- #
383
- # def charter_1_month_low_usd(boat)
384
- # { charter_1_month_low_usd: boat.charter_1_month_low_usd }
385
- # end
386
- #
387
- # def charter_1_month_low_rub(boat)
388
- # { charter_1_month_low_rub: boat.charter_1_month_low_rub }
389
- # end
390
- #
391
- # def charter_1_month_low_eur(boat)
392
- # { charter_1_month_low_eur: boat.charter_1_month_low_eur }
393
- # end
394
-
395
- # --[high]-----------------------------------------------------------------------------------------------------------
396
-
397
- # def charter_1_hour_high_usd(boat)
398
- # { charter_1_hour_high_usd: boat.charter_1_hour_high_usd }
399
- # end
400
- #
401
- # def charter_1_hour_high_rub(boat)
402
- # { charter_1_hour_high_rub: boat.charter_1_hour_high_rub }
403
- # end
404
- #
405
- # def charter_1_hour_high_eur(boat)
406
- # { charter_1_hour_high_eur: boat.charter_1_hour_high_eur }
407
- # end
408
- #
409
- # def charter_1_day_high_usd(boat)
410
- # { charter_1_day_high_usd: boat.charter_1_day_high_usd }
411
- # end
412
- #
413
- # def charter_1_day_high_rub(boat)
414
- # { charter_1_day_high_rub: boat.charter_1_day_high_rub }
415
- # end
416
- #
417
- # def charter_1_day_high_eur(boat)
418
- # { charter_1_day_high_eur: boat.charter_1_day_high_eur }
419
- # end
420
- #
421
- # def charter_1_week_high_usd(boat)
422
- # { charter_1_week_high_usd: boat.charter_1_week_high_usd }
423
- # end
424
- #
425
- # def charter_1_week_high_rub(boat)
426
- # { charter_1_week_high_rub: boat.charter_1_week_high_rub }
427
- # end
428
- #
429
- # def charter_1_week_high_eur(boat)
430
- # { charter_1_week_high_eur: boat.charter_1_week_high_eur }
431
- # end
432
- #
433
- # def charter_1_month_high_usd(boat)
434
- # { charter_1_month_high_usd: boat.charter_1_month_high_usd }
435
- # end
436
- #
437
- # def charter_1_month_high_rub(boat)
438
- # { charter_1_month_high_rub: boat.charter_1_month_high_rub }
439
- # end
440
- #
441
- # def charter_1_month_high_eur(boat)
442
- # { charter_1_month_high_eur: boat.charter_1_month_high_eur }
443
- # end
444
-
445
- # --[sale]----------------------------------------------------------------------------------------------------------
446
-
447
- # def sale_price_usd(boat)
448
- # { sale_price_usd: boat.sale_price_usd }
449
- # end
450
- #
451
- # def sale_price_rub(boat)
452
- # { sale_price_rub: boat.sale_price_rub }
453
- # end
454
- #
455
- # def sale_price_eur(boat)
456
- # { sale_price_eur: boat.sale_price_eur }
457
- # end
458
-
459
- # --[discount]------------------------------------------------------------------------------------------------------
460
-
461
- # def charter_1_day_high_discount(boat)
462
- # { charter_1_day_high_discount: boat.charter_1_day_high_discount }
463
- # end
464
- #
465
- # def charter_1_day_low_discount(boat)
466
- # { charter_1_day_low_discount: boat.charter_1_day_low_discount }
467
- # end
468
- #
469
- # def charter_1_hour_high_discount(boat)
470
- # { charter_1_hour_high_discount: boat.charter_1_hour_high_discount }
471
- # end
472
- #
473
- # def charter_1_hour_low_discount(boat)
474
- # { charter_1_hour_low_discount: boat.charter_1_hour_low_discount }
475
- # end
476
- #
477
- # def charter_1_month_high_discount(boat)
478
- # { charter_1_month_high_discount: boat.charter_1_month_high_discount }
479
- # end
480
- #
481
- # def charter_1_month_low_discount(boat)
482
- # { charter_1_month_low_discount: boat.charter_1_month_low_discount }
483
- # end
484
- #
485
- # def charter_1_week_high_discount(boat)
486
- # { charter_1_week_high_discount: boat.charter_1_week_high_discount }
487
- # end
488
- #
489
- # def charter_1_week_low_discount(boat)
490
- # { charter_1_week_low_discount: boat.charter_1_week_low_discount }
491
- # end
492
-
493
- # def sale_price_discount(boat)
494
- # { sale_price_discount: boat.sale_price_discount }
495
- # end
496
-
497
- def state(boat)
498
- { state: boat.state }
499
- end
500
-
501
340
  def boat_photos(boat)
502
341
  # FIXME:: выяснить, нужно ли всётаки использовать .gsub('\'', '&#39;') для строк с путями к фоткам?
503
342
  boat_photos = boat.boat_photos.map do |boat_photo|
@@ -521,14 +360,6 @@ class BoatSerializer < AbstractSerializer
521
360
  { boat_contacts: boat_contacts }
522
361
  end
523
362
 
524
- def visits_today(boat)
525
- { visits_today: boat.visits_today }
526
- end
527
-
528
- def visits_total(boat)
529
- { visits_total: boat.visits_total }
530
- end
531
-
532
363
  def serialize_opts
533
364
  locale = ::Dicts::Locale.find_by_index @opts[:locale].to_s
534
365
  uol = ::Dicts::Length.find_by_index @opts[:uol]
@@ -1,3 +1,3 @@
1
1
  module C80Shared
2
- VERSION = "0.1.38"
2
+ VERSION = "0.1.39"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: c80_shared
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.38
4
+ version: 0.1.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - C80609A
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-25 00:00:00.000000000 Z
11
+ date: 2019-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler