c80_shared 0.1.28 → 0.1.29

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: 6deb84a52d6a6dc93858a56c1c86533e119940d29d42e3e249c6c0ddf625e06f
4
- data.tar.gz: c77b17bd5c63867036ebacf04093ebf51e0048b01b6eaa71df3292e479b4e84f
3
+ metadata.gz: ab60ae319ce4abda842e353e0cad39fa295bc88096e214cc7a3d86850f4d3087
4
+ data.tar.gz: d10e052afbc0877695637471f02ce8bc44a19dfff3ea2574ace257e7423ac11f
5
5
  SHA512:
6
- metadata.gz: 217ee99e49fdab5820a6c693bf28542e1098899c2974d48329c358bbb37d54332aace30c3438e161ce92f827e9beae2d4004a31bd19dd9bca304531e34c3316d
7
- data.tar.gz: 9a71b09423edf3f2de57230013b07165d8839a6939b2545aa21f61f42db82080e79ac1c6d45d807f4ba27ee8bb0eb9b245ed0afe755921e6065d7ed17591d3ec
6
+ metadata.gz: bcf6825cf48b47fb057cf19bbed53905bc95ea41a154561150ea1db176d748ce9e7ac22a3ea3d7f6574a6b33372004df0af917a1c4e443866acb3ee169954418
7
+ data.tar.gz: a82ee96f349039cd1e772b511e78088b574b4ca0fc4263bc1028c2070836db9318fb4e0d35a89c1c2bfcdcdbe83a90717aba88e6f400efdc412b8d68bcc7e9fe
@@ -0,0 +1,11 @@
1
+ module Dicts
2
+ class BoatType < ::Dict
3
+ BOAT_30FT = new(4, 'boat_30ft')
4
+ PARTY_BOAT = new(7, 'party_boat')
5
+ YACHT = new(8, 'yacht')
6
+ FISHING_BOAT = new(10, 'fishing_boat')
7
+ SAILING = new(11, 'sailing')
8
+ CATAMARAN = new(12, 'catamaran')
9
+ MEGA_YACHT = new(13, 'mega_yacht')
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ module Dicts
2
+ class Business < ::Dict
3
+ RENT = new(1, 'rent')
4
+ SALE = new(1, 'sale')
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ module Dicts
2
+ class CharterSeason < ::Dict
3
+ LOW = new(1, 'low')
4
+ HIGH = new(2, 'high')
5
+
6
+ ALL = [ LOW, HIGH ]
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ module Dicts
2
+ class CharterUom < ::Dict
3
+ HOUR = new(1, 'hour')
4
+ DAY = new(2, 'day')
5
+ WEEK = new(3, 'week')
6
+ MONTH = new(4, 'month')
7
+
8
+ ALL = [ HOUR, DAY, WEEK, MONTH ]
9
+ end
10
+ end
@@ -1,7 +1,71 @@
1
1
  module Dicts
2
2
  class Currency < ::Dict
3
- USD = new(1, 'USD')
4
- EUR = new(2, 'EUR')
5
- RUB = new(3, 'RUB')
3
+ attr_reader :symbol
4
+
5
+ def initialize(id, index, symbol)
6
+ @symbol = symbol
7
+ super(id, index)
8
+ end
9
+
10
+ AED = new(17, 'AED', "\u062f.\u0625.")
11
+ ARS = new(9, 'ARS', "$")
12
+ AUD = new(7, 'AUD', "$")
13
+ BGN = new(11, 'BGN', "lev")
14
+ BHD = new(10, 'BHD', "\u062f.\u0628.")
15
+ BRL = new(12, 'BRL', "R$")
16
+ CAD = new(25, 'CAD', "$")
17
+ CHF = new(47, 'CHF', "\u20a3")
18
+ CLP = new(45, 'CLP', "$")
19
+ CNY = new(6, 'CNY', "\uffe5")
20
+ COP = new(27, 'COP', "$")
21
+ CZK = new(44, 'CZK', "K\u010d")
22
+ DKK = new(16, 'DKK', "kr.")
23
+ EGP = new(19, 'EGP', "\u062c.\u0645.")
24
+ EUR = new(2, 'EUR', "\u20ac")
25
+ FJD = new(18, 'FJD', "FJ$")
26
+ GBP = new(4, 'GBP', "\u00a3")
27
+ HKD = new(14, 'HKD', "$")
28
+ HUF = new(13, 'HUF', "Ft")
29
+ IDR = new(22, 'IDR', "Rp")
30
+ ILS = new(20, 'ILS', "\u20aa")
31
+ INR = new(21, 'INR', "\u20b9")
32
+ JOD = new(23, 'JOD', "\u062f.\u0627.")
33
+ JPY = new(50, 'JPY', "\u00a5")
34
+ KRW = new(49, 'KRW', "\u20a9")
35
+ KWD = new(28, 'KWD', "\u062f.\u0643.")
36
+ KZT = new(24, 'KZT', "\u0422")
37
+ MDL = new(31, 'MDL', "lei")
38
+ MXN = new(30, 'MXN', "$")
39
+ MYR = new(29, 'MYR', "RM")
40
+ NAD = new(32, 'NAD', "N$")
41
+ NOK = new(35, 'NOK', "kr")
42
+ NZD = new(33, 'NZD', "$")
43
+ OMR = new(36, 'OMR', "\u0631.\u0639.")
44
+ PLN = new(37, 'PLN', "z\u0142")
45
+ QAR = new(26, 'QAR', "\u0631.\u0642.")
46
+ RON = new(34, 'RON', "lei")
47
+ RUB = new(3, 'RUB', "\u20bd")
48
+ SAR = new(38, 'SAR', "\u0631.\u0633.")
49
+ SEK = new(46, 'SEK', "kr")
50
+ SGD = new(39, 'SGD', "$")
51
+ THB = new(5, 'THB', "\u0e3f")
52
+ TRY = new(41, 'TRY', "TL")
53
+ TWD = new(40, 'TWD', "NT$")
54
+ UAH = new(42, 'UAH', "\u20B4")
55
+ USD = new(1, 'USD', "$")
56
+ ZAR = new(48, 'ZAR', "R")
57
+
58
+ # старый
59
+ ALL = [USD, EUR, RUB]
60
+
61
+ # новый
62
+ ALL2 = [USD,EUR,THB,ARS,AUD,BGN,BHD,
63
+ BRL,CAD,CHF,CLP,CNY,COP,
64
+ CZK,DKK,EGP,FJD,GBP,
65
+ HKD,HUF,IDR,ILS,INR,JOD,
66
+ JPY,KRW,KWD,KZT,MDL,MXN,
67
+ MYR,NAD,NOK,NZD,OMR,PLN,
68
+ QAR,RON,RUB,SAR,SEK,SGD,
69
+ TRY,TWD,UAH,AED,ZAR]
6
70
  end
7
71
  end
@@ -0,0 +1,6 @@
1
+ module Dicts
2
+ class Length < ::Dict
3
+ METRE = new(1, 'meters')
4
+ FOOT = new(1, 'ft')
5
+ end
6
+ end
@@ -10,7 +10,11 @@ module Custom
10
10
  def collection_for_select(collection, name, id, options = {})
11
11
  return [] unless collection.is_a?(Array)
12
12
 
13
- collection = collection.map { |h| [ h[name], h[id] ] }
13
+ collection = if options[:collection_is_not_hash]
14
+ collection.map { |h| [ h.try(name), h.try(id) ] }
15
+ else
16
+ collection.map { |h| [ h[name], h[id] ] }
17
+ end
14
18
  collection = options_for_select(collection, options[:value]) if options[:options_for_select].present?
15
19
  collection
16
20
  end
@@ -8,20 +8,20 @@ module Site
8
8
  # Вернёт отформатированную строку с датой ~ от локали.
9
9
  # @param with_time [Boolean] Если true - вернёт и время
10
10
  #
11
- def format_date(date, locale = :en, with_time = false)
12
- date.strftime locale_date_format(locale, with_time)
11
+ def format_date(date, locale = :en, with_time = false, with_html = false)
12
+ date.strftime locale_date_format(locale, with_time, with_html)
13
13
  end
14
14
 
15
15
  # В зависимости от локали выдаст соответствующий формат для отображения дат.
16
16
  # https://en.wikipedia.org/wiki/Date_format_by_country
17
17
  # @param with_time [Boolean] Если true - вернёт и время
18
18
  #
19
- def locale_date_format(locale = :en, with_time = false)
19
+ def locale_date_format(locale = :en, with_time = false, with_html = false)
20
20
  res = case locale.to_s
21
21
  when 'en'
22
- '%Y/%m/%d'
22
+ with_html ? '<span class="year">%Y</span>/<span class="month">%m</span>/<span class="day">%d</span>' : '%Y/%m/%d'
23
23
  when 'ru'
24
- '%d.%m.%Y'
24
+ '<span class="day">%d</span>.<span class="month">%m</span>.<span class="year">%Y</span>'
25
25
  else
26
26
  '%Y/%m/%d'
27
27
  end
@@ -0,0 +1,58 @@
1
+ class BoatPriceSerializer < AbstractSerializer
2
+
3
+ class << self
4
+ def available_attributes
5
+ %i[season uom duration currency value discount]
6
+ end
7
+
8
+ def season(boat_price)
9
+ {
10
+ season: {
11
+ id: boat_price.season_id,
12
+ index: ::Dicts::CharterSeason.find(boat_price.season_id).index
13
+ }
14
+ }
15
+ end
16
+
17
+ # час, день, неделя, месяц
18
+ def uom(boat_price)
19
+ {
20
+ uom: {
21
+ id: boat_price.uom_id,
22
+ index: ::Dicts::CharterUom.find(boat_price.uom_id).index
23
+ }
24
+ }
25
+ end
26
+
27
+ def duration(boat_price)
28
+ { duration: boat_price.duration }
29
+ end
30
+
31
+ def currency(boat_price)
32
+ bp = ::Dicts::Currency.find(boat_price.currency_id)
33
+
34
+ {
35
+ currency: {
36
+ id: bp.id,
37
+ index: bp.index,
38
+ symbol: bp.symbol
39
+ }
40
+ }
41
+ end
42
+
43
+ # цена за указанный период
44
+ def value(boat_price)
45
+ { value: sprintf('%d', boat_price.value) }
46
+ end
47
+
48
+ def discount(boat_price)
49
+ { discount: sprintf('%.2f', boat_price.discount) }
50
+ end
51
+
52
+ # TODO:: прояснить надобность, проработать тему
53
+ def is_orig(boat_price)
54
+ { is_orig: boat_price.is_orig }
55
+ end
56
+
57
+ end
58
+ end
@@ -0,0 +1,33 @@
1
+ class BoatSalePriceSerializer < AbstractSerializer
2
+
3
+ class << self
4
+ def available_attributes
5
+ %i[id currency value discount]
6
+ end
7
+
8
+ def id(sale_price)
9
+ { id: sale_price.id }
10
+ end
11
+
12
+ def currency(sale_price)
13
+ currency = ::Dicts::Currency.find(sale_price.currency_id)
14
+
15
+ {
16
+ currency: {
17
+ id: currency.id,
18
+ index: currency.index,
19
+ symbol: currency.symbol
20
+ }
21
+ }
22
+ end
23
+
24
+ # цена за указанный период
25
+ def value(sale_price)
26
+ { value: sprintf('%d', sale_price.value) }
27
+ end
28
+
29
+ def discount(sale_price)
30
+ { discount: sprintf('%.2f', sale_price.discount) }
31
+ end
32
+ end
33
+ end
@@ -3,14 +3,17 @@ class BoatSerializer < AbstractSerializer
3
3
  class << self
4
4
  def available_attributes
5
5
  %i[
6
+ boat_beam
6
7
  boat_beam_metrics
7
8
  boat_beam_metrics_ft
8
9
  boat_beam_metrics_meters
9
10
  boat_contacts
11
+ boat_draft
10
12
  boat_draft_metrics
11
13
  boat_draft_metrics_ft
12
14
  boat_draft_metrics_meters
13
15
  boat_hull_id
16
+ boat_length
14
17
  boat_length_metrics
15
18
  boat_length_metrics_ft
16
19
  boat_length_metrics_meters
@@ -20,38 +23,6 @@ class BoatSerializer < AbstractSerializer
20
23
  boat_type_id
21
24
  builder
22
25
  built_year
23
- charter_1_day_high_discount
24
- charter_1_day_high_eur
25
- charter_1_day_high_rub
26
- charter_1_day_high_usd
27
- charter_1_day_low_discount
28
- charter_1_day_low_eur
29
- charter_1_day_low_rub
30
- charter_1_day_low_usd
31
- charter_1_hour_high_discount
32
- charter_1_hour_high_eur
33
- charter_1_hour_high_rub
34
- charter_1_hour_high_usd
35
- charter_1_hour_low_discount
36
- charter_1_hour_low_eur
37
- charter_1_hour_low_rub
38
- charter_1_hour_low_usd
39
- charter_1_month_high_discount
40
- charter_1_month_high_eur
41
- charter_1_month_high_rub
42
- charter_1_month_high_usd
43
- charter_1_month_low_discount
44
- charter_1_month_low_eur
45
- charter_1_month_low_rub
46
- charter_1_month_low_usd
47
- charter_1_week_high_discount
48
- charter_1_week_high_eur
49
- charter_1_week_high_rub
50
- charter_1_week_high_usd
51
- charter_1_week_low_discount
52
- charter_1_week_low_eur
53
- charter_1_week_low_rub
54
- charter_1_week_low_usd
55
26
  crew_total
56
27
  guest_cabins
57
28
  guests_total
@@ -64,17 +35,10 @@ class BoatSerializer < AbstractSerializer
64
35
  main_boat_photo_id
65
36
  motor
66
37
  name
67
- name_builder
68
38
  naval_architect
69
- per_season
70
39
  picture_medium_url
71
- price
72
- price_discount
40
+ prices
73
41
  refit_year
74
- sale_price_discount
75
- sale_price_eur
76
- sale_price_rub
77
- sale_price_usd
78
42
  short_description
79
43
  state
80
44
  visits_today
@@ -84,10 +48,11 @@ class BoatSerializer < AbstractSerializer
84
48
 
85
49
  def default_opts
86
50
  {
87
- uom: 'ft',
88
- currency: 'USD',
51
+ uol: 'ft',
52
+ currency: ::Dicts::Currency::USD.index,
89
53
  locale: 'en',
90
- is_for_rent: true
54
+ is_for_rent: true, # TODO:: [bcff00da] УДАЛИТЬ
55
+ business: ::Dicts::Business::RENT.index
91
56
  }
92
57
  end
93
58
 
@@ -107,21 +72,6 @@ class BoatSerializer < AbstractSerializer
107
72
  { naval_architect: boat.naval_architect }
108
73
  end
109
74
 
110
- # Для страницы просмотра лодки
111
- #
112
- # example: Carpe Diem by Lazzara
113
- # example: Ismail
114
- def name_builder(boat)
115
- arr = []
116
- arr << boat.name&.strip
117
- if boat.builder.present?
118
- arr << I18n.t('boat.builder.prefix')
119
- arr << boat.builder.strip
120
- end
121
-
122
- { name_builder: arr * ' ' }
123
- end
124
-
125
75
  # noinspection RubyResolve
126
76
  def picture_medium_url(boat)
127
77
  url = if boat.boat_photo.present?
@@ -160,35 +110,35 @@ class BoatSerializer < AbstractSerializer
160
110
  end
161
111
 
162
112
  # per day, per week; в день, в час, за месяц;
163
- def per_season(boat)
164
- season_key = ::Lib::Boats::RentPricePerSeason.spot_rentprice_id(boat, @opts[:currency], @opts[:rent_price_id]).gsub(/_low|_high/, '')
113
+ # def per_season(boat)
114
+ # season_key = ::Lib::Boats::RentPricePerSeason.spot_rentprice_id(boat, @opts[:currency], @opts[:rent_price_id]).gsub(/_low|_high/, '')
165
115
  #=> charter_1_week_low, charter_1_day_high
166
- translate = I18n.t("boat.rent_price.per_#{season_key}")
167
- value = @opts[:is_for_rent] ? translate : ''
168
-
169
- { per_season: value }
170
- end
116
+ # translate = I18n.t("boat.rent_price.per_#{season_key}")
117
+ # value = @opts[:is_for_rent] ? translate : ''
118
+ #
119
+ # { per_season: value }
120
+ # end
171
121
 
172
122
  # ₽ 293,885
173
- def price(boat)
174
- value = if @opts[:is_for_rent]
175
- ::Lib::Boats::RentPricePerSeason.price(boat, @opts[:currency], @opts[:rent_price_id])
176
- else
177
- ::Lib::Boats::SalePrice.price(boat, @opts[:currency])
178
- end
179
-
180
- { price: value }
181
- end
123
+ # def price(boat)
124
+ # value = if @opts[:is_for_rent]
125
+ # ::Lib::Boats::RentPricePerSeason.price(boat, @opts[:currency], @opts[:rent_price_id])
126
+ # else
127
+ # ::Lib::Boats::SalePrice.price(boat, @opts[:currency])
128
+ # end
129
+ #
130
+ # { price: value }
131
+ # end
182
132
 
183
133
  # 12%
184
- def price_discount(boat)
185
- value = if @opts[:is_for_rent]
186
- ::Lib::Boats::RentPricePerSeason.price_discount(boat, @opts[:currency])
187
- else
188
- ::Lib::Boats::SalePrice.price_discount(boat)
189
- end
190
- { price_discount: value }
191
- end
134
+ # def price_discount(boat)
135
+ # value = if @opts[:is_for_rent]
136
+ # ::Lib::Boats::RentPricePerSeason.price_discount(boat, @opts[:currency])
137
+ # else
138
+ # ::Lib::Boats::SalePrice.price_discount(boat)
139
+ # end
140
+ # { price_discount: value }
141
+ # end
192
142
 
193
143
  def guests_total(boat)
194
144
  { guests_total: boat.guests_total }
@@ -244,200 +194,237 @@ class BoatSerializer < AbstractSerializer
244
194
  }
245
195
  end
246
196
 
247
- def boat_length_metrics(boat)
248
- value = ::Lib::Boats::Dimensions.boatlength(boat, @opts[:uom])
249
- { boat_length_metrics: value }
197
+ def boat_length(boat)
198
+ {
199
+ boat_length: {
200
+ value: boat.send('boat_length_metrics_%s' % @opts[:uol]),
201
+ uol: @opts[:uol]
202
+ }
203
+ }
250
204
  end
251
205
 
206
+ # [bcff00da] : вся подобная логика переезжает во фронт, переделано должно быть по образу `def boat_length`
207
+
208
+ # TODO:: [bcff00da] УДАЛИТЬ
209
+ # def boat_length_metrics(boat)
210
+ # value = ::Lib::Boats::Dimensions.boatlength(boat, @opts[:uol])
211
+ # { boat_length_metrics: value }
212
+ # end
213
+
214
+ # TODO:: [bcff00da] УДАЛИТЬ - пока используется при обновлении/создании лодки в админке
252
215
  def boat_length_metrics_meters(boat)
253
216
  { boat_length_metrics_meters: boat.boat_length_metrics_meters }
254
217
  end
255
218
 
219
+ # TODO:: [bcff00da] УДАЛИТЬ - пока используется при обновлении/создании лодки в админке
256
220
  def boat_length_metrics_ft(boat)
257
221
  { boat_length_metrics_ft: boat.boat_length_metrics_ft }
258
222
  end
259
223
 
260
- def boat_beam_metrics(boat)
261
- value = ::Lib::Boats::Dimensions.boatbeam(boat, @opts[:uom])
262
- { boat_beam_metrics: value }
263
- end
224
+ # TODO:: [bcff00da] УДАЛИТЬ
225
+ # def boat_beam_metrics(boat)
226
+ # value = ::Lib::Boats::Dimensions.boatbeam(boat, @opts[:uol])
227
+ # { boat_beam_metrics: value }
228
+ # end
264
229
 
265
- def boat_beam_metrics_ft(boat)
266
- { boat_beam_metrics_ft: boat.boat_beam_metrics_ft }
267
- end
230
+ # TODO:: [bcff00da] УДАЛИТЬ
231
+ # def boat_beam_metrics_ft(boat)
232
+ # { boat_beam_metrics_ft: boat.boat_beam_metrics_ft }
233
+ # end
268
234
 
269
- def boat_beam_metrics_meters(boat)
270
- { boat_beam_metrics_meters: boat.boat_beam_metrics_meters }
271
- end
235
+ # TODO:: [bcff00da] УДАЛИТЬ
236
+ # def boat_beam_metrics_meters(boat)
237
+ # { boat_beam_metrics_meters: boat.boat_beam_metrics_meters }
238
+ # end
272
239
 
273
- def boat_draft_metrics(boat)
274
- value = ::Lib::Boats::Dimensions.boatdraft(boat, @opts[:uom])
275
- { boat_draft_metrics: value }
276
- end
240
+ # TODO:: [bcff00da] УДАЛИТЬ
241
+ # def boat_draft_metrics(boat)
242
+ # value = ::Lib::Boats::Dimensions.boatdraft(boat, @opts[:uol])
243
+ # { boat_draft_metrics: value }
244
+ # end
277
245
 
278
- def boat_draft_metrics_ft(boat)
279
- { boat_draft_metrics_ft: boat.boat_draft_metrics_ft }
280
- end
246
+ # TODO:: [bcff00da] УДАЛИТЬ
247
+ # def boat_draft_metrics_ft(boat)
248
+ # { boat_draft_metrics_ft: boat.boat_draft_metrics_ft }
249
+ # end
281
250
 
282
- def boat_draft_metrics_meters(boat)
283
- { boat_draft_metrics_meters: boat.boat_draft_metrics_meters }
284
- end
251
+ # TODO:: [bcff00da] УДАЛИТЬ
252
+ # def boat_draft_metrics_meters(boat)
253
+ # { boat_draft_metrics_meters: boat.boat_draft_metrics_meters }
254
+ # end
285
255
 
286
256
  def boat_hull_id(boat)
287
257
  { boat_hull_id: boat.boat_hull_id }
288
258
  end
289
259
 
290
- # --[low]-----------------------------------------------------------------------------------------------------------
291
-
292
- def charter_1_hour_low_usd(boat)
293
- { charter_1_hour_low_usd: boat.charter_1_hour_low_usd }
294
- end
295
-
296
- def charter_1_hour_low_rub(boat)
297
- { charter_1_hour_low_rub: boat.charter_1_hour_low_rub }
298
- end
299
-
300
- def charter_1_hour_low_eur(boat)
301
- { charter_1_hour_low_eur: boat.charter_1_hour_low_eur }
302
- end
303
-
304
- def charter_1_day_low_usd(boat)
305
- { charter_1_day_low_usd: boat.charter_1_day_low_usd }
306
- end
260
+ def prices(boat)
261
+ currency_id = ::Dicts::Currency.find_by_index(@opts[:currency]).id
262
+ prices = if @opts[:business] == ::Dicts::Business::RENT.index
263
+ boat.boat_prices.select { |bp| bp.currency_id == currency_id }.map { |bp| ::BoatPriceSerializer.serialize bp }
264
+ else
265
+ # noinspection RubyResolve
266
+ boat.boat_sale_prices.select { |bp| bp.currency_id == currency_id }.map { |bps| ::BoatSalePriceSerializer.serialize bps }
267
+ end
307
268
 
308
- def charter_1_day_low_rub(boat)
309
- { charter_1_day_low_rub: boat.charter_1_day_low_rub }
310
- end
311
-
312
- def charter_1_day_low_eur(boat)
313
- { charter_1_day_low_eur: boat.charter_1_day_low_eur }
314
- end
315
-
316
- def charter_1_week_low_usd(boat)
317
- { charter_1_week_low_usd: boat.charter_1_week_low_usd }
318
- end
319
-
320
- def charter_1_week_low_rub(boat)
321
- { charter_1_week_low_rub: boat.charter_1_week_low_rub }
322
- end
323
-
324
- def charter_1_week_low_eur(boat)
325
- { charter_1_week_low_eur: boat.charter_1_week_low_eur }
326
- end
327
-
328
- def charter_1_month_low_usd(boat)
329
- { charter_1_month_low_usd: boat.charter_1_month_low_usd }
269
+ {
270
+ prices: {
271
+ list: prices,
272
+ business: @opts[:business]
273
+ }
274
+ }
330
275
  end
331
276
 
332
- def charter_1_month_low_rub(boat)
333
- { charter_1_month_low_rub: boat.charter_1_month_low_rub }
334
- end
277
+ # --[low]-----------------------------------------------------------------------------------------------------------
335
278
 
336
- def charter_1_month_low_eur(boat)
337
- { charter_1_month_low_eur: boat.charter_1_month_low_eur }
338
- end
279
+ # def charter_1_hour_low_usd(boat)
280
+ # { charter_1_hour_low_usd: boat.charter_1_hour_low_usd }
281
+ # end
282
+ #
283
+ # def charter_1_hour_low_rub(boat)
284
+ # { charter_1_hour_low_rub: boat.charter_1_hour_low_rub }
285
+ # end
286
+ #
287
+ # def charter_1_hour_low_eur(boat)
288
+ # { charter_1_hour_low_eur: boat.charter_1_hour_low_eur }
289
+ # end
290
+ #
291
+ # def charter_1_day_low_usd(boat)
292
+ # { charter_1_day_low_usd: boat.charter_1_day_low_usd }
293
+ # end
294
+ #
295
+ # def charter_1_day_low_rub(boat)
296
+ # { charter_1_day_low_rub: boat.charter_1_day_low_rub }
297
+ # end
298
+ #
299
+ # def charter_1_day_low_eur(boat)
300
+ # { charter_1_day_low_eur: boat.charter_1_day_low_eur }
301
+ # end
302
+ #
303
+ # def charter_1_week_low_usd(boat)
304
+ # { charter_1_week_low_usd: boat.charter_1_week_low_usd }
305
+ # end
306
+ #
307
+ # def charter_1_week_low_rub(boat)
308
+ # { charter_1_week_low_rub: boat.charter_1_week_low_rub }
309
+ # end
310
+ #
311
+ # def charter_1_week_low_eur(boat)
312
+ # { charter_1_week_low_eur: boat.charter_1_week_low_eur }
313
+ # end
314
+ #
315
+ # def charter_1_month_low_usd(boat)
316
+ # { charter_1_month_low_usd: boat.charter_1_month_low_usd }
317
+ # end
318
+ #
319
+ # def charter_1_month_low_rub(boat)
320
+ # { charter_1_month_low_rub: boat.charter_1_month_low_rub }
321
+ # end
322
+ #
323
+ # def charter_1_month_low_eur(boat)
324
+ # { charter_1_month_low_eur: boat.charter_1_month_low_eur }
325
+ # end
339
326
 
340
327
  # --[high]-----------------------------------------------------------------------------------------------------------
341
328
 
342
- def charter_1_hour_high_usd(boat)
343
- { charter_1_hour_high_usd: boat.charter_1_hour_high_usd }
344
- end
345
-
346
- def charter_1_hour_high_rub(boat)
347
- { charter_1_hour_high_rub: boat.charter_1_hour_high_rub }
348
- end
349
-
350
- def charter_1_hour_high_eur(boat)
351
- { charter_1_hour_high_eur: boat.charter_1_hour_high_eur }
352
- end
353
-
354
- def charter_1_day_high_usd(boat)
355
- { charter_1_day_high_usd: boat.charter_1_day_high_usd }
356
- end
357
-
358
- def charter_1_day_high_rub(boat)
359
- { charter_1_day_high_rub: boat.charter_1_day_high_rub }
360
- end
361
-
362
- def charter_1_day_high_eur(boat)
363
- { charter_1_day_high_eur: boat.charter_1_day_high_eur }
364
- end
365
-
366
- def charter_1_week_high_usd(boat)
367
- { charter_1_week_high_usd: boat.charter_1_week_high_usd }
368
- end
369
-
370
- def charter_1_week_high_rub(boat)
371
- { charter_1_week_high_rub: boat.charter_1_week_high_rub }
372
- end
373
-
374
- def charter_1_week_high_eur(boat)
375
- { charter_1_week_high_eur: boat.charter_1_week_high_eur }
376
- end
377
-
378
- def charter_1_month_high_usd(boat)
379
- { charter_1_month_high_usd: boat.charter_1_month_high_usd }
380
- end
381
-
382
- def charter_1_month_high_rub(boat)
383
- { charter_1_month_high_rub: boat.charter_1_month_high_rub }
384
- end
385
-
386
- def charter_1_month_high_eur(boat)
387
- { charter_1_month_high_eur: boat.charter_1_month_high_eur }
388
- end
329
+ # def charter_1_hour_high_usd(boat)
330
+ # { charter_1_hour_high_usd: boat.charter_1_hour_high_usd }
331
+ # end
332
+ #
333
+ # def charter_1_hour_high_rub(boat)
334
+ # { charter_1_hour_high_rub: boat.charter_1_hour_high_rub }
335
+ # end
336
+ #
337
+ # def charter_1_hour_high_eur(boat)
338
+ # { charter_1_hour_high_eur: boat.charter_1_hour_high_eur }
339
+ # end
340
+ #
341
+ # def charter_1_day_high_usd(boat)
342
+ # { charter_1_day_high_usd: boat.charter_1_day_high_usd }
343
+ # end
344
+ #
345
+ # def charter_1_day_high_rub(boat)
346
+ # { charter_1_day_high_rub: boat.charter_1_day_high_rub }
347
+ # end
348
+ #
349
+ # def charter_1_day_high_eur(boat)
350
+ # { charter_1_day_high_eur: boat.charter_1_day_high_eur }
351
+ # end
352
+ #
353
+ # def charter_1_week_high_usd(boat)
354
+ # { charter_1_week_high_usd: boat.charter_1_week_high_usd }
355
+ # end
356
+ #
357
+ # def charter_1_week_high_rub(boat)
358
+ # { charter_1_week_high_rub: boat.charter_1_week_high_rub }
359
+ # end
360
+ #
361
+ # def charter_1_week_high_eur(boat)
362
+ # { charter_1_week_high_eur: boat.charter_1_week_high_eur }
363
+ # end
364
+ #
365
+ # def charter_1_month_high_usd(boat)
366
+ # { charter_1_month_high_usd: boat.charter_1_month_high_usd }
367
+ # end
368
+ #
369
+ # def charter_1_month_high_rub(boat)
370
+ # { charter_1_month_high_rub: boat.charter_1_month_high_rub }
371
+ # end
372
+ #
373
+ # def charter_1_month_high_eur(boat)
374
+ # { charter_1_month_high_eur: boat.charter_1_month_high_eur }
375
+ # end
389
376
 
390
377
  # --[sale]----------------------------------------------------------------------------------------------------------
391
378
 
392
- def sale_price_usd(boat)
393
- { sale_price_usd: boat.sale_price_usd }
394
- end
395
-
396
- def sale_price_rub(boat)
397
- { sale_price_rub: boat.sale_price_rub }
398
- end
399
-
400
- def sale_price_eur(boat)
401
- { sale_price_eur: boat.sale_price_eur }
402
- end
379
+ # def sale_price_usd(boat)
380
+ # { sale_price_usd: boat.sale_price_usd }
381
+ # end
382
+ #
383
+ # def sale_price_rub(boat)
384
+ # { sale_price_rub: boat.sale_price_rub }
385
+ # end
386
+ #
387
+ # def sale_price_eur(boat)
388
+ # { sale_price_eur: boat.sale_price_eur }
389
+ # end
403
390
 
404
391
  # --[discount]------------------------------------------------------------------------------------------------------
405
392
 
406
- def charter_1_day_high_discount(boat)
407
- { charter_1_day_high_discount: boat.charter_1_day_high_discount }
408
- end
409
-
410
- def charter_1_day_low_discount(boat)
411
- { charter_1_day_low_discount: boat.charter_1_day_low_discount }
412
- end
413
-
414
- def charter_1_hour_high_discount(boat)
415
- { charter_1_hour_high_discount: boat.charter_1_hour_high_discount }
416
- end
417
-
418
- def charter_1_hour_low_discount(boat)
419
- { charter_1_hour_low_discount: boat.charter_1_hour_low_discount }
420
- end
421
-
422
- def charter_1_month_high_discount(boat)
423
- { charter_1_month_high_discount: boat.charter_1_month_high_discount }
424
- end
425
-
426
- def charter_1_month_low_discount(boat)
427
- { charter_1_month_low_discount: boat.charter_1_month_low_discount }
428
- end
429
-
430
- def charter_1_week_high_discount(boat)
431
- { charter_1_week_high_discount: boat.charter_1_week_high_discount }
432
- end
433
-
434
- def charter_1_week_low_discount(boat)
435
- { charter_1_week_low_discount: boat.charter_1_week_low_discount }
436
- end
393
+ # def charter_1_day_high_discount(boat)
394
+ # { charter_1_day_high_discount: boat.charter_1_day_high_discount }
395
+ # end
396
+ #
397
+ # def charter_1_day_low_discount(boat)
398
+ # { charter_1_day_low_discount: boat.charter_1_day_low_discount }
399
+ # end
400
+ #
401
+ # def charter_1_hour_high_discount(boat)
402
+ # { charter_1_hour_high_discount: boat.charter_1_hour_high_discount }
403
+ # end
404
+ #
405
+ # def charter_1_hour_low_discount(boat)
406
+ # { charter_1_hour_low_discount: boat.charter_1_hour_low_discount }
407
+ # end
408
+ #
409
+ # def charter_1_month_high_discount(boat)
410
+ # { charter_1_month_high_discount: boat.charter_1_month_high_discount }
411
+ # end
412
+ #
413
+ # def charter_1_month_low_discount(boat)
414
+ # { charter_1_month_low_discount: boat.charter_1_month_low_discount }
415
+ # end
416
+ #
417
+ # def charter_1_week_high_discount(boat)
418
+ # { charter_1_week_high_discount: boat.charter_1_week_high_discount }
419
+ # end
420
+ #
421
+ # def charter_1_week_low_discount(boat)
422
+ # { charter_1_week_low_discount: boat.charter_1_week_low_discount }
423
+ # end
437
424
 
438
- def sale_price_discount(boat)
439
- { sale_price_discount: boat.sale_price_discount }
440
- end
425
+ # def sale_price_discount(boat)
426
+ # { sale_price_discount: boat.sale_price_discount }
427
+ # end
441
428
 
442
429
  def state(boat)
443
430
  { state: boat.state }
@@ -4,7 +4,7 @@ module Configs
4
4
  # список ценовых (продажа/аренда) атрибутов Лодки
5
5
  def self.attributes(price_attributes = ::Dictionaries::BoatCharterAttribute::ALL)
6
6
  attributes = []
7
- ::Dicts::Currency.all.each do |currency|
7
+ ::Dicts::Currency::ALL.each do |currency|
8
8
  price_attributes.map do |attr|
9
9
  field = Currency.attribute_name currency.index, attr
10
10
  next unless field
@@ -12,13 +12,12 @@ module Configs
12
12
  guests_total
13
13
  guest_cabins
14
14
  crew_total
15
- boat_length_metrics
15
+ boat_length
16
16
  built_year
17
17
  boat_model
18
18
  boat_type
19
19
  location_address
20
- price
21
- per_season
20
+ prices
22
21
  state
23
22
  visits_total
24
23
  visits_today
@@ -12,7 +12,7 @@ module Configs
12
12
  :my_price,
13
13
  :my_price_currency,
14
14
  :address,
15
- :period,
15
+ :period_formatted,
16
16
  :duration,
17
17
  :guests,
18
18
  :kids,
@@ -19,6 +19,7 @@ module Lease
19
19
  :latitude,
20
20
  :longitude,
21
21
  :period,
22
+ :period_formatted,
22
23
  :duration,
23
24
  :from,
24
25
  :to,
@@ -112,6 +113,17 @@ module Lease
112
113
  { period: '%s - %s' % [from(inquiry)[:from], to(inquiry)[:to]] }
113
114
  end
114
115
 
116
+ def period_formatted(inquiry)
117
+ frm = format_date(inquiry.from, @opts[:locale], false, true)
118
+ tto = format_date(inquiry.to, @opts[:locale], false, true)
119
+
120
+ { period: {
121
+ from: frm,
122
+ to: tto
123
+ }
124
+ }
125
+ end
126
+
115
127
  def duration(inquiry)
116
128
  distance = (inquiry.to - inquiry.from).to_i / 24 / 60 / 60
117
129
  distance = distance.zero? ? 1 : distance
@@ -0,0 +1,5 @@
1
+ en:
2
+ dicts:
3
+ length:
4
+ ft: ft
5
+ meters: m
@@ -0,0 +1,5 @@
1
+ ru:
2
+ dicts:
3
+ length:
4
+ ft: фут
5
+ meters: м
@@ -9,13 +9,17 @@ class Dict
9
9
  end
10
10
 
11
11
  def self.all
12
- constants.map { |const| const_get const }
12
+ constants.select { |const| (const_get const).class != Array }.map { |const| const_get const } # пока я не добавил константы типа ALL, работала эта строка: constants.map { |const| const_get const }
13
13
  end
14
14
 
15
15
  def self.find(id)
16
16
  all.select { |const| const.id == id.to_i }.first
17
17
  end
18
18
 
19
+ def self.find_by_index(index)
20
+ all.select { |const| const.index == index }.first
21
+ end
22
+
19
23
  def self.where(ids)
20
24
  all.select { |const| ids.include?(const.id) }
21
25
  end
@@ -1,5 +1,5 @@
1
1
  module C80Shared
2
2
  class Engine < ::Rails::Engine
3
- config.i18n.load_path += Dir[config.root.join('config', 'locales', '*','*.{yml}').to_s]
3
+ config.i18n.load_path += Dir[config.root.join('config', 'locales', '**','*.{yml}').to_s]
4
4
  end
5
5
  end
@@ -1,3 +1,3 @@
1
1
  module C80Shared
2
- VERSION = "0.1.28"
2
+ VERSION = "0.1.29"
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.28
4
+ version: 0.1.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - C80609A
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-16 00:00:00.000000000 Z
11
+ date: 2019-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -49,8 +49,13 @@ files:
49
49
  - ".rubocop.yml"
50
50
  - Gemfile
51
51
  - README.md
52
+ - app/dicts/boat_type.rb
53
+ - app/dicts/business.rb
54
+ - app/dicts/charter_season.rb
55
+ - app/dicts/charter_uom.rb
52
56
  - app/dicts/currency.rb
53
57
  - app/dicts/email_token_subj.rb
58
+ - app/dicts/length.rb
54
59
  - app/dicts/locale.rb
55
60
  - app/dicts/rent_skip_type.rb
56
61
  - app/helpers/custom/currency_helper.rb
@@ -58,6 +63,8 @@ files:
58
63
  - app/helpers/custom/price_helper.rb
59
64
  - app/helpers/custom/select_helper.rb
60
65
  - app/helpers/site/time_helper.rb
66
+ - app/serializers/boat_price_serializer.rb
67
+ - app/serializers/boat_sale_price_serializer.rb
61
68
  - app/serializers/boat_serializer.rb
62
69
  - app/serializers/boat_visit_day_serializer.rb
63
70
  - app/serializers/configs/boats/boat_prices.rb
@@ -78,6 +85,8 @@ files:
78
85
  - c80_shared.gemspec
79
86
  - config/locales/boat/en.yml
80
87
  - config/locales/boat/ru.yml
88
+ - config/locales/dicts/length/en.yml
89
+ - config/locales/dicts/length/ru.yml
81
90
  - config/locales/rent_skip_type/en.yml
82
91
  - config/locales/rent_skip_type/ru.yml
83
92
  - lib/c80_shared.rb