aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorXinhui2016-11-08 16:00:39 +0100
committerXinhui2016-11-08 16:00:39 +0100
commitf07d997e80a59d12c98798da015bae36b3af66d2 (patch)
tree2112b8299f92f2ec7aa76922e406726b7f5305c8 /lib
parent9418590690f14907b87fe22376281bd1bf3cb5a3 (diff)
downloadchouette-core-f07d997e80a59d12c98798da015bae36b3af66d2.tar.bz2
MyWorkBenchScopes
Refs #1787
Diffstat (limited to 'lib')
-rw-r--r--lib/stif/my_workbench_scopes.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/stif/my_workbench_scopes.rb b/lib/stif/my_workbench_scopes.rb
new file mode 100644
index 000000000..ed3432ad3
--- /dev/null
+++ b/lib/stif/my_workbench_scopes.rb
@@ -0,0 +1,22 @@
+class Stif::MyWorkbenchScopes
+ attr_accessor :organisation
+
+ def initialize(workbench)
+ @workbench = workbench
+ end
+
+ def line_scope
+ scope = Chouette::Line
+ ids = self.parse_functional_scope
+ ids ? scope.where(objectid: ids) : scope.all
+ end
+
+ def parse_functional_scope
+ return false unless @workbench.organisation.sso_attributes
+ begin
+ line_ids = JSON.parse @workbench.organisation.sso_attributes['functional_scope']
+ rescue Exception => e
+ Rails.logger.error "MyWorkbenchScopes : #{e}"
+ end
+ end
+end