tramway-event 1.9.1 → 1.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/tramway/event/event.rb +11 -5
- data/lib/tramway/event/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d9103eadd50c9621d5811222c3fe58531ab5c97f4d6644b52f79b932b5972db
|
4
|
+
data.tar.gz: 513815f3f055e85378c254b336a02452ee8e084fc209ee7db86d3f65c2380512
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73dd563cfbc42ed48f80d5ed5e574e59bae6e16588b02dcb9ba11ad8bf8d3978e70584fc7b210e997a29c2a161ded3b04e4d85410933042b7c1a0332df3933b8
|
7
|
+
data.tar.gz: b79e1c529152a683b1dc164671f6fdb8a46c85fd130b3059c3949c78fbadf1b38011de58561c7569ff0104f120e3401f988ed3ea6d592aef97c655fd4bf5cd26
|
@@ -8,11 +8,6 @@ class Tramway::Event::Event < ::Tramway::Event::ApplicationRecord
|
|
8
8
|
has_many :partnerships, class_name: 'Tramway::Partner::Partnership', as: :partner
|
9
9
|
has_many :organizations, as: :partners, through: :partnerships, class_name: 'Tramway::Partner::Organization'
|
10
10
|
|
11
|
-
::Tramway::Partner::Partnership.partnership_type.values.each do |partnership_type|
|
12
|
-
has_many partnership_type.pluralize.to_sym, (-> do
|
13
|
-
joins(:partnerships).where 'tramway_partner_partnerships.partnership_type = ? AND tramway_partner_partnerships.state = \'active\'', partnership_type
|
14
|
-
end), foreign_key: :organization_id, source: :organization, through: :partnerships, class_name: 'Tramway::Partner::Organization'
|
15
|
-
end
|
16
11
|
|
17
12
|
enumerize :status, default: :common, in: [ :common, :main ]
|
18
13
|
|
@@ -27,4 +22,15 @@ class Tramway::Event::Event < ::Tramway::Event::ApplicationRecord
|
|
27
22
|
return :are_being_right_now if request_collecting_begin_date&.past? && request_collecting_end_date&.future?
|
28
23
|
end
|
29
24
|
|
25
|
+
::Tramway::Partner::Partnership.partnership_type.values.each do |partnership_type|
|
26
|
+
define_method partnership_type.pluralize.to_sym do
|
27
|
+
query = <<-SQL
|
28
|
+
tramway_partner_partnerships.partnership_type = '#{partnership_type}'
|
29
|
+
AND tramway_partner_partnerships.partner_id = '#{id}'
|
30
|
+
AND tramway_partner_partnerships.state = 'active'
|
31
|
+
AND tramway_partner_partnerships.partner_type = 'Tramway::Event::Event'
|
32
|
+
SQL
|
33
|
+
Tramway::Partner::Organization.joins(:partnerships).where(query)
|
34
|
+
end
|
35
|
+
end
|
30
36
|
end
|