c80_shared 0.1.87 → 0.1.92
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/Gemfile.lock +1 -1
- data/Makefile +2 -0
- data/app/serializers/account_serializer.rb +20 -1
- data/app/serializers/accounts/account_central_agent_serializer.rb +25 -0
- data/app/serializers/lease/inquiry_serializer.rb +8 -3
- data/app/serializers/lease/request_info_serializer.rb +64 -0
- data/app/validators/boats/is_for_rent.rb +22 -0
- data/app/validators/boats/is_for_sell.rb +19 -0
- data/app/validators/currency_presence_validator.rb +17 -0
- data/app/validators/dimension_presence_validator.rb +17 -0
- data/app/validators/sale_inquiry_assign_validator.rb +8 -0
- data/app/validators/sale_inquiry_comment_validator.rb +9 -0
- data/app/validators/user_permission_validator.rb +7 -0
- data/lib/c80_shared/version.rb +1 -1
- metadata +13 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 01d83a8e917b7bd5fab8a1ba75303d1119b1a8ca3f98f3ddfe14f9feb8d6400e
|
|
4
|
+
data.tar.gz: 2a53970b7d9a05c6d00fa4bc404815671eabc9aa0dd589c102d4113f2bcb7708
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c73de67e9325198b76bae77fa96746f2d19b44bc2612295a3313ade64f14cbf9cf655fd68a30132f146b5bbd2202ae6fad0abfd2e7a9ee7fa4e2c006505cfb83
|
|
7
|
+
data.tar.gz: 304f26906bfc56ef3ba5ee05ac8064920f1eba6dc9d6fc76bf4fd4293c50749225a91555eedb544c242f1cfb3db062ecbcc4147e7244759b09af4a11f02c6a4a
|
data/Gemfile.lock
CHANGED
data/Makefile
ADDED
|
@@ -7,6 +7,7 @@ class AccountSerializer < AbstractSerializer
|
|
|
7
7
|
id
|
|
8
8
|
type_index
|
|
9
9
|
props
|
|
10
|
+
abilities
|
|
10
11
|
]
|
|
11
12
|
end
|
|
12
13
|
|
|
@@ -38,5 +39,23 @@ class AccountSerializer < AbstractSerializer
|
|
|
38
39
|
end
|
|
39
40
|
{ props: props }
|
|
40
41
|
end
|
|
42
|
+
|
|
43
|
+
# список возможностей с учётом запретов
|
|
44
|
+
def abilities(account)
|
|
45
|
+
account_class = ::Dictionaries::AccountType::CLASS_BY_TYPE[account.type_id]
|
|
46
|
+
default_abilities = ::Dicts::Accounts::Ability.all_for_account_class(account_class)
|
|
47
|
+
prohibited = account.user.permissions
|
|
48
|
+
|
|
49
|
+
# отнимаем запрещённые действия из дефолтных
|
|
50
|
+
not_prohibited = ->(ability) { prohibited.none? { |a| a.action.to_s == ability.index.to_s } }
|
|
51
|
+
abilities = default_abilities.map do |a|
|
|
52
|
+
{
|
|
53
|
+
action: a.index,
|
|
54
|
+
can: not_prohibited[a]
|
|
55
|
+
}
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
{ abilities: abilities }
|
|
59
|
+
end
|
|
41
60
|
end
|
|
42
|
-
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Accounts
|
|
2
|
+
class CentralAgentSerializer < AbstractSerializer
|
|
3
|
+
class << self
|
|
4
|
+
def available_attributes
|
|
5
|
+
%i[
|
|
6
|
+
email
|
|
7
|
+
phone
|
|
8
|
+
name
|
|
9
|
+
]
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def email(central_agent)
|
|
13
|
+
{ email: central_agent.account.user.email }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def phone(central_agent)
|
|
17
|
+
{ phone: central_agent.account.user.phone }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def name(central_agent)
|
|
21
|
+
{ name: central_agent.account.user.name }
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -24,7 +24,6 @@ module Lease
|
|
|
24
24
|
kids
|
|
25
25
|
latitude
|
|
26
26
|
longitude
|
|
27
|
-
manager_email
|
|
28
27
|
my_price
|
|
29
28
|
my_price_currency
|
|
30
29
|
name
|
|
@@ -32,6 +31,7 @@ module Lease
|
|
|
32
31
|
period
|
|
33
32
|
period_formatted
|
|
34
33
|
phone_number
|
|
34
|
+
responsible_managers
|
|
35
35
|
state
|
|
36
36
|
to
|
|
37
37
|
token
|
|
@@ -171,8 +171,13 @@ module Lease
|
|
|
171
171
|
}
|
|
172
172
|
end
|
|
173
173
|
|
|
174
|
-
def
|
|
175
|
-
|
|
174
|
+
def responsible_managers(inquiry)
|
|
175
|
+
res = inquiry.responsible_managers.includes(:user).map do |acc|
|
|
176
|
+
{ id: acc.user.id,
|
|
177
|
+
email: acc.user.email
|
|
178
|
+
}
|
|
179
|
+
end
|
|
180
|
+
{ responsible_managers: res }
|
|
176
181
|
end
|
|
177
182
|
|
|
178
183
|
def hours_per_day(inquiry)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
module Lease
|
|
2
|
+
class RequestInfoSerializer < ::AbstractSerializer
|
|
3
|
+
class << self
|
|
4
|
+
def serialize(model, attributes:, opts: {})
|
|
5
|
+
super
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def available_attributes
|
|
9
|
+
%i[
|
|
10
|
+
id
|
|
11
|
+
uuid
|
|
12
|
+
operator
|
|
13
|
+
amount
|
|
14
|
+
currency
|
|
15
|
+
external_transaction_id
|
|
16
|
+
state
|
|
17
|
+
created_at
|
|
18
|
+
updated_at
|
|
19
|
+
]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def id(request_info)
|
|
23
|
+
{ id: request_info.id }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def uuid(request_info)
|
|
27
|
+
{ uuid: request_info.uuid }
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def operator(request_info)
|
|
31
|
+
{
|
|
32
|
+
operator: {
|
|
33
|
+
id: request_info.operator.id,
|
|
34
|
+
index: request_info.operator.type_index
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def amount(request_info)
|
|
40
|
+
{ amount: request_info.amount }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def currency(request_info)
|
|
44
|
+
{ currency: request_info.currency }
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def external_transaction_id(request_info)
|
|
48
|
+
{ external_transaction_id: request_info.external_transaction_id }
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def state(request_info)
|
|
52
|
+
{ state: request_info.state }
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def created_at(request_info)
|
|
56
|
+
{ created_at: request_info.created_at }
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def updated_at(request_info)
|
|
60
|
+
{ updated_at: request_info.updated_at }
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Boats
|
|
2
|
+
# определяем, указана ли хоть какая-нибудь цена аренды?
|
|
3
|
+
#
|
|
4
|
+
module IsForRent
|
|
5
|
+
module_function
|
|
6
|
+
|
|
7
|
+
# @param [Boat || Form] record
|
|
8
|
+
# @return [TrueClass || FalseClass]
|
|
9
|
+
#
|
|
10
|
+
def check?(record)
|
|
11
|
+
::Dictionaries::BoatCharterAttribute::ALL.map do |attr|
|
|
12
|
+
::Dicts::Currency::ALL.map do |currency|
|
|
13
|
+
field = Currency.attribute_name currency.index, attr
|
|
14
|
+
value = record.try field
|
|
15
|
+
# puts '%s = %s' % [field, value]
|
|
16
|
+
# noinspection RubySimplifyBooleanInspection
|
|
17
|
+
!!(value&.>0)
|
|
18
|
+
end
|
|
19
|
+
end.flatten.any?
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Boats
|
|
2
|
+
# определяем, указана ли хоть какая-нибудь цена продажи?
|
|
3
|
+
#
|
|
4
|
+
module IsForSell
|
|
5
|
+
module_function
|
|
6
|
+
|
|
7
|
+
# @param [Boat] record
|
|
8
|
+
# @return [TrueClass || FalseClass]
|
|
9
|
+
#
|
|
10
|
+
def check?(record)
|
|
11
|
+
::Dicts::Currency::ALL.map do |currency|
|
|
12
|
+
field = Currency.attribute_name currency.index, 'sale_price'
|
|
13
|
+
value = record.send field
|
|
14
|
+
# noinspection RubySimplifyBooleanInspection
|
|
15
|
+
!!(value&.>0)
|
|
16
|
+
end.any?
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class CurrencyPresenceValidator < ActiveModel::EachValidator
|
|
2
|
+
def validate_each(record, attribute, value)
|
|
3
|
+
unless record.currency
|
|
4
|
+
raise ArgumentError, 'record.currency does not exist'
|
|
5
|
+
end
|
|
6
|
+
available_currencies = I18n::t('static.currencies').map{|currency| currency[:id]}
|
|
7
|
+
record_currency = record.currency.upcase
|
|
8
|
+
if available_currencies.include? record_currency
|
|
9
|
+
attribute_currency = attribute.to_s.split('_')[-1].upcase
|
|
10
|
+
if record_currency == attribute_currency && record.attributes[attribute.to_s].nil?
|
|
11
|
+
record.errors[attribute] << "can't be blank!"
|
|
12
|
+
end
|
|
13
|
+
else
|
|
14
|
+
raise ArgumentError, 'Model record.currency does not exist in I18n::t(\'static.currencies\')'
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class DimensionPresenceValidator < ActiveModel::EachValidator
|
|
2
|
+
def validate_each(record, attribute, value)
|
|
3
|
+
unless record.dimension
|
|
4
|
+
raise ArgumentError, 'record.dimension does not exist'
|
|
5
|
+
end
|
|
6
|
+
available_dimensions = I18n::t('static.dimensions').map{|dimension| dimension[:id]}
|
|
7
|
+
record_dimension = record.dimension.downcase
|
|
8
|
+
if available_dimensions.include? record_dimension
|
|
9
|
+
attribute_dimension = attribute.to_s.split('_')[-1].downcase
|
|
10
|
+
if record_dimension == attribute_dimension && record.attributes[attribute.to_s].nil?
|
|
11
|
+
record.errors[attribute] << "can't be blank!"
|
|
12
|
+
end
|
|
13
|
+
else
|
|
14
|
+
raise ArgumentError, 'Model record.dimension does not exist in I18n::(\'static.dimensions\')'
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
class SaleInquiryAssignValidator < ActiveModel::Validator
|
|
2
|
+
def validate(record)
|
|
3
|
+
record.errors.add(:sale_inquiry, :blank) and return false if record.sale_inquiry.nil?
|
|
4
|
+
record.errors.add(:assignee, :blank) and return false if record.assignee.nil?
|
|
5
|
+
record.errors.add(:author, :blank) and return false if record.author.nil?
|
|
6
|
+
true
|
|
7
|
+
end
|
|
8
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
class SaleInquiryCommentValidator < ActiveModel::Validator
|
|
2
|
+
def validate(record)
|
|
3
|
+
record.errors.add(:sale_inquiry, :blank) and return false if record.sale_inquiry.nil?
|
|
4
|
+
record.errors.add(:author, :blank) and return false if record.author.nil?
|
|
5
|
+
record.errors.add(:text, :blank) and return false unless record.text.present?
|
|
6
|
+
record.errors.add(:text, :less_than_or_equal_to, count: 1024) and return false if record.text.size > 1024
|
|
7
|
+
true
|
|
8
|
+
end
|
|
9
|
+
end
|
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.92
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- C80609A
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-07-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -49,6 +49,7 @@ files:
|
|
|
49
49
|
- ".rubocop.yml"
|
|
50
50
|
- Gemfile
|
|
51
51
|
- Gemfile.lock
|
|
52
|
+
- Makefile
|
|
52
53
|
- README.md
|
|
53
54
|
- app/dicts/account_type.rb
|
|
54
55
|
- app/dicts/boat_condition.rb
|
|
@@ -90,6 +91,7 @@ files:
|
|
|
90
91
|
- app/repositories/accounts/client_account_repository.rb
|
|
91
92
|
- app/repositories/events/rejects_repository.rb
|
|
92
93
|
- app/serializers/account_serializer.rb
|
|
94
|
+
- app/serializers/accounts/account_central_agent_serializer.rb
|
|
93
95
|
- app/serializers/boat_location_serializer.rb
|
|
94
96
|
- app/serializers/boat_price_serializer.rb
|
|
95
97
|
- app/serializers/boat_sale_price_serializer.rb
|
|
@@ -103,6 +105,7 @@ files:
|
|
|
103
105
|
- app/serializers/lease/bid_serializer.rb
|
|
104
106
|
- app/serializers/lease/inquiry_serializer.rb
|
|
105
107
|
- app/serializers/lease/rebate_serializer.rb
|
|
108
|
+
- app/serializers/lease/request_info_serializer.rb
|
|
106
109
|
- app/serializers/lib/boats/dimensions.rb
|
|
107
110
|
- app/serializers/lib/boats/rent_price_per_season.rb
|
|
108
111
|
- app/serializers/lib/boats/sale_price.rb
|
|
@@ -117,6 +120,13 @@ files:
|
|
|
117
120
|
- app/services/sale/inquiry_asked_prices_save_service.rb
|
|
118
121
|
- app/services/users/find_or_generate_email_token_service.rb
|
|
119
122
|
- app/services/users/generate_email_token_service.rb
|
|
123
|
+
- app/validators/boats/is_for_rent.rb
|
|
124
|
+
- app/validators/boats/is_for_sell.rb
|
|
125
|
+
- app/validators/currency_presence_validator.rb
|
|
126
|
+
- app/validators/dimension_presence_validator.rb
|
|
127
|
+
- app/validators/sale_inquiry_assign_validator.rb
|
|
128
|
+
- app/validators/sale_inquiry_comment_validator.rb
|
|
129
|
+
- app/validators/user_permission_validator.rb
|
|
120
130
|
- bin/console
|
|
121
131
|
- bin/rails
|
|
122
132
|
- bin/setup
|
|
@@ -203,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
203
213
|
- !ruby/object:Gem::Version
|
|
204
214
|
version: '0'
|
|
205
215
|
requirements: []
|
|
206
|
-
rubygems_version: 3.0.
|
|
216
|
+
rubygems_version: 3.0.8
|
|
207
217
|
signing_key:
|
|
208
218
|
specification_version: 4
|
|
209
219
|
summary: Write a short summary, because RubyGems requires one.
|