klastera 1.1.5 → 1.1.6
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 878d34d9ec3f16b43e8ae1a84c4b773086606477f2b86db4052fd92eea525337
|
4
|
+
data.tar.gz: 338c177eaa872b07fa293ae69ec2989956a27c6feb66353a691506d9d6f2050b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1600809f0477ef856f83546cb04a28bd9b3e39bb139df8544e8a4c9006d9542540e0590921dbfc06c9159f8bcdfae93e4ef92bdf1341f0f173c823b958f575ff
|
7
|
+
data.tar.gz: 6098336be0ed5ae4aeb3de2ef873809d9f3ff06e57cd3dfa8f1dd971c9eecf2fd7dc1bb7be214e2d905a9027a97eb7ba6fe520064a1c6b993a653192c4f5afa4
|
@@ -14,8 +14,6 @@ module Klastera::Concerns::User
|
|
14
14
|
validates :cluster_role, presence: true, if: proc{ self.organization.is_in_cluster_mode? }
|
15
15
|
validates :cluster_role, inclusion: { in: CLUSTER_ROLES , message: I18n.t('klastera.clusters.wrong_option') }, if: proc{ cluster_role.present? }
|
16
16
|
validate :at_least_one_role, if: proc{ self.use_cluster? && self.try(:need_cluster_assignation?) }
|
17
|
-
before_destroy do |record|
|
18
|
-
end
|
19
17
|
|
20
18
|
def use_cluster?; self.cluster_role.present?; end
|
21
19
|
|
@@ -35,6 +33,24 @@ module Klastera::Concerns::User
|
|
35
33
|
self.organization.is_in_cluster_mode? && ( self.is_a_cluster_admin? || self.is_a_cluster_root? )
|
36
34
|
end
|
37
35
|
|
36
|
+
# We will try to create a cluster_user record whether
|
37
|
+
# the organization is using force mode (if cluster_id isn't present,
|
38
|
+
# will raise a validation error) or cluster_id is present
|
39
|
+
# (on organizations with show/use mode).
|
40
|
+
def try_to_clusterify!(role,cluster_id)
|
41
|
+
if self.try(:organization).try(:is_in_cluster_mode?)
|
42
|
+
self.cluster_role = role
|
43
|
+
if self.try(:organization).try(:required_suborganization_mode?) || cluster_id.present?
|
44
|
+
self.cluster_users_attributes = {
|
45
|
+
DateTime.now.to_i => {
|
46
|
+
cluster_id: cluster_id,
|
47
|
+
_destroy: false
|
48
|
+
}
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
38
54
|
private
|
39
55
|
|
40
56
|
def at_least_one_role
|
@@ -13,7 +13,7 @@
|
|
13
13
|
>
|
14
14
|
<%= fa_icon 'info-circle', class: 'btn-link' %>
|
15
15
|
</span>
|
16
|
-
<%= f.select :use_cluster_as, Cluster::MODES.map{|cm|[t("klastera.#{cm}"),cm]}, { include_blank: true }, { class: 'form-control' } %>
|
16
|
+
<%= f.select :use_cluster_as, ::Cluster::MODES.map{|cm|[t("klastera.#{cm}"),cm]}, { include_blank: true }, { class: 'form-control' } %>
|
17
17
|
</div>
|
18
18
|
|
19
19
|
<script type="text/javascript">
|
data/lib/klastera/version.rb
CHANGED
data/lib/klastera.rb
CHANGED
@@ -29,7 +29,6 @@ module Klastera
|
|
29
29
|
scope_klass = scope_klass.where(organization_id: organization)
|
30
30
|
|
31
31
|
session_clusters(user,organization) do |clusters|
|
32
|
-
clusters = clusters.reject{|c|c.id.blank?}
|
33
32
|
if organization.required_suborganization_mode?
|
34
33
|
scope_klass = scope_klass.where("#{scope.table_name}.cluster_id IN (?)",clusters)
|
35
34
|
elsif organization.optional_mode? && user.is_a_cluster_user?
|
@@ -61,7 +60,10 @@ module Klastera
|
|
61
60
|
##
|
62
61
|
def session_clusters(user,organization)
|
63
62
|
clusters = organization.is_in_cluster_mode? ? ::ClusterUser.get_clusters_from(user,organization) : []
|
64
|
-
|
63
|
+
if block_given?
|
64
|
+
clusters = clusters.reject{|c|c.id.blank?}
|
65
|
+
yield(clusters)
|
66
|
+
end
|
65
67
|
clusters
|
66
68
|
end
|
67
69
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: klastera
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gino Barahona
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|