diff options
| author | Xinhui | 2016-11-08 16:00:39 +0100 |
|---|---|---|
| committer | Xinhui | 2016-11-08 16:00:39 +0100 |
| commit | f07d997e80a59d12c98798da015bae36b3af66d2 (patch) | |
| tree | 2112b8299f92f2ec7aa76922e406726b7f5305c8 /lib | |
| parent | 9418590690f14907b87fe22376281bd1bf3cb5a3 (diff) | |
| download | chouette-core-f07d997e80a59d12c98798da015bae36b3af66d2.tar.bz2 | |
MyWorkBenchScopes
Refs #1787
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/stif/my_workbench_scopes.rb | 22 |
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 |
