acts_as_data_owner 0.0.4 → 0.0.5
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.
@@ -1,6 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
|
2
4
|
module ActsAsDataOwner
|
3
5
|
|
6
|
+
|
4
7
|
def acts_as_data_owner(*args)
|
5
8
|
|
6
9
|
options = args.extract_options!
|
@@ -22,13 +25,18 @@ module ActsAsDataOwner
|
|
22
25
|
before_update :set_updater
|
23
26
|
|
24
27
|
scope :current, lambda {
|
28
|
+
conditions = {}
|
25
29
|
#Filter by User Ids Who has access to Products
|
26
30
|
if !Person.current.is_admin?
|
27
|
-
|
28
|
-
conditions["#{self.table_name}.
|
29
|
-
|
30
|
-
|
31
|
+
|
32
|
+
conditions["#{self.table_name}.owner_id"] = ([Person.current.id] + Person.manage_people_ids).compact if fields.include?(:owner)
|
33
|
+
|
34
|
+
if fields.include?(:company)
|
35
|
+
company_ids = ([(Person.current.current_company ? Person.current.current_company.id : nil)] + Person.manage_company_ids).compact
|
36
|
+
conditions["#{self.table_name}.company_id"] = company_ids if company_ids.any?
|
37
|
+
end
|
31
38
|
end
|
39
|
+
where(conditions)
|
32
40
|
}
|
33
41
|
|
34
42
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_data_owner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-17 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|