c80_shared 0.1.47 → 0.1.48
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 +4 -4
- data/app/dicts/length.rb +1 -1
- data/app/serializers/boat_location_serializer.rb +39 -0
- data/app/serializers/boat_serializer.rb +60 -1
- data/lib/c80_shared/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f2e77e7dbf7e8a1279e7b352b677027059cfadad92b286d3f89d02af8583ed9
|
4
|
+
data.tar.gz: 4c0501164cb9f5e47242c6a2d6a0f15f4c63cfe910ea1c2b4fa2256175d9ecca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b28f1132f4558b46d6ac1afeb5f56e710525d24fda8af17626debd201070590bca2d8a3ca85b6357927e8fda86601662e74dd2a32dfc3003aa8c29b0f5c6ba7
|
7
|
+
data.tar.gz: 3427cf33ce35082fa55ea7038895f12a0b23b5f87cd33518c274ef24dea387b14adc2fb16e9eb9d799e91fc03b485248c60e5f435c3757f011a48bd6bf4b833d
|
data/app/dicts/length.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
class BoatLocationSerializer < AbstractSerializer
|
2
|
+
|
3
|
+
class << self
|
4
|
+
def available_attributes
|
5
|
+
%i[
|
6
|
+
id
|
7
|
+
latitude
|
8
|
+
longitude
|
9
|
+
address
|
10
|
+
is_main
|
11
|
+
radius
|
12
|
+
]
|
13
|
+
end
|
14
|
+
|
15
|
+
def id(location)
|
16
|
+
{ id: location.id }
|
17
|
+
end
|
18
|
+
|
19
|
+
def latitude(location)
|
20
|
+
{ latitude: location.latitude }
|
21
|
+
end
|
22
|
+
|
23
|
+
def longitude(location)
|
24
|
+
{ longitude: location.longitude }
|
25
|
+
end
|
26
|
+
|
27
|
+
def address(location)
|
28
|
+
{ address: location.address }
|
29
|
+
end
|
30
|
+
|
31
|
+
def is_main(location)
|
32
|
+
{ is_main: location.is_main }
|
33
|
+
end
|
34
|
+
|
35
|
+
def radius(location)
|
36
|
+
{ radius: location.radius }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -13,8 +13,10 @@ class BoatSerializer < AbstractSerializer
|
|
13
13
|
boat_length_metrics
|
14
14
|
boat_length_metrics_ft
|
15
15
|
boat_length_metrics_meters
|
16
|
+
boat_locations_attributes
|
16
17
|
boat_model
|
17
18
|
boat_photos
|
19
|
+
boat_photos_attributes
|
18
20
|
boat_type
|
19
21
|
boat_type_id
|
20
22
|
builder
|
@@ -31,8 +33,10 @@ class BoatSerializer < AbstractSerializer
|
|
31
33
|
hull_material
|
32
34
|
id
|
33
35
|
interior_designer
|
36
|
+
length
|
34
37
|
latitude
|
35
38
|
location_address
|
39
|
+
locations
|
36
40
|
longitude
|
37
41
|
maximum_guests_during_cruise
|
38
42
|
main_boat_photo_id
|
@@ -71,7 +75,7 @@ class BoatSerializer < AbstractSerializer
|
|
71
75
|
end
|
72
76
|
|
73
77
|
# определяем "простые" методы
|
74
|
-
%i[id comments tender name description built_year boat_model
|
78
|
+
%i[id comments tender name description built_year boat_model boat_type_id boat_hull_id refit_year
|
75
79
|
crew_cabins crew_total guest_heads guest_sleeps maximum_guests_during_cruise interior_designer
|
76
80
|
naval_architect guests_total guest_cabins state visits_today visits_total].each do |f|
|
77
81
|
define_method f do |boat|
|
@@ -281,6 +285,16 @@ class BoatSerializer < AbstractSerializer
|
|
281
285
|
}
|
282
286
|
end
|
283
287
|
|
288
|
+
# используется для валидации лодки при обновлении стейта
|
289
|
+
def length(boat)
|
290
|
+
{
|
291
|
+
length: {
|
292
|
+
value: boat.send('boat_length_metrics_%s' % @opts[:uol]),
|
293
|
+
length_id: ::Dicts::Length.find_by_index(@opts[:uol]).id
|
294
|
+
}
|
295
|
+
}
|
296
|
+
end
|
297
|
+
|
284
298
|
# для формы редактирования в кабинете агента
|
285
299
|
def boat_length_metrics(boat)
|
286
300
|
{ boat_length_metrics: boat_length(boat)[:boat_length] }
|
@@ -352,6 +366,15 @@ class BoatSerializer < AbstractSerializer
|
|
352
366
|
{ boat_photos: boat_photos }
|
353
367
|
end
|
354
368
|
|
369
|
+
# используется для валидации лодки при обновлении стейта
|
370
|
+
def boat_photos_attributes(boat)
|
371
|
+
{
|
372
|
+
boat_photos_attributes: boat.boat_photos.map do |boat_photo|
|
373
|
+
{ id: boat_photo.id }
|
374
|
+
end
|
375
|
+
}
|
376
|
+
end
|
377
|
+
|
355
378
|
# Контакты владельцев: то, что приходит в `boat_users_attributes` из админской формы
|
356
379
|
def boat_contacts(boat)
|
357
380
|
boat_contacts = boat.boat_users.map do |user|
|
@@ -362,6 +385,42 @@ class BoatSerializer < AbstractSerializer
|
|
362
385
|
{ boat_contacts: boat_contacts }
|
363
386
|
end
|
364
387
|
|
388
|
+
# TODO
|
389
|
+
def latitude(boat)
|
390
|
+
{ latitude: 1 }
|
391
|
+
end
|
392
|
+
|
393
|
+
# TODO
|
394
|
+
def longitude(boat)
|
395
|
+
{ longitude: 1 }
|
396
|
+
end
|
397
|
+
|
398
|
+
# под видом этого атрибута будет приходить текст - название главной локации
|
399
|
+
def location_address(boat)
|
400
|
+
loc = boat.boat_locations.select { |bl| bl.is_main }.first # если не применяется поиск по адресу
|
401
|
+
loc ||= boat.boat_locations.first # если поиск по адресу применён -- в результат поиска может не попасть главная локация
|
402
|
+
{
|
403
|
+
location_address: loc&.address || ''
|
404
|
+
}
|
405
|
+
end
|
406
|
+
|
407
|
+
def locations(boat)
|
408
|
+
{
|
409
|
+
locations: boat.boat_locations.map do |location|
|
410
|
+
::BoatLocationSerializer.serialize location
|
411
|
+
end
|
412
|
+
}
|
413
|
+
end
|
414
|
+
|
415
|
+
# используется для валидации лодки при обновлении стейта
|
416
|
+
def boat_locations_attributes(boat)
|
417
|
+
{
|
418
|
+
boat_locations_attributes: boat.boat_locations.map do |location|
|
419
|
+
::BoatLocationSerializer.serialize location
|
420
|
+
end
|
421
|
+
}
|
422
|
+
end
|
423
|
+
|
365
424
|
def serialize_opts
|
366
425
|
locale = ::Dicts::Locale.find_by_index @opts[:locale].to_s
|
367
426
|
uol = ::Dicts::Length.find_by_index @opts[:uol]
|
data/lib/c80_shared/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.48
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- C80609A
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- app/helpers/custom/select_helper.rb
|
71
71
|
- app/helpers/site/time_helper.rb
|
72
72
|
- app/serializers/account_serializer.rb
|
73
|
+
- app/serializers/boat_location_serializer.rb
|
73
74
|
- app/serializers/boat_price_serializer.rb
|
74
75
|
- app/serializers/boat_sale_price_serializer.rb
|
75
76
|
- app/serializers/boat_serializer.rb
|