From 2ca92317d4dc06992e93b39202fbc3231c8cac4d Mon Sep 17 00:00:00 2001 From: Xinhui Date: Wed, 9 Nov 2016 11:47:02 +0100 Subject: Refactoring MyWorkbenchScopes with initial_scope Refs #1787 --- lib/stif/my_workbench_scopes.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/stif/my_workbench_scopes.rb b/lib/stif/my_workbench_scopes.rb index ed3432ad3..7e4500a7d 100644 --- a/lib/stif/my_workbench_scopes.rb +++ b/lib/stif/my_workbench_scopes.rb @@ -1,20 +1,19 @@ class Stif::MyWorkbenchScopes - attr_accessor :organisation + attr_accessor :workbench def initialize(workbench) @workbench = workbench end - def line_scope - scope = Chouette::Line - ids = self.parse_functional_scope - ids ? scope.where(objectid: ids) : scope.all + def line_scope(initial_scope) + ids = self.parse_functional_scope + ids ? initial_scope.where(objectid: ids) : initial_scope end def parse_functional_scope return false unless @workbench.organisation.sso_attributes begin - line_ids = JSON.parse @workbench.organisation.sso_attributes['functional_scope'] + JSON.parse @workbench.organisation.sso_attributes['functional_scope'] rescue Exception => e Rails.logger.error "MyWorkbenchScopes : #{e}" end -- cgit v1.2.3