From 9ffdd487495cde5accf6c67952a6c3c22aa7567f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Arranz?= Date: Mon, 30 May 2016 18:00:54 +0200 Subject: [PATCH] Remove context from the workspace info --- src/wirecloud/platform/context/utils.py | 10 ---------- src/wirecloud/platform/context/views.py | 10 +++++++--- .../platform/static/iphone/opManager/Workspace.js | 4 +++- .../platform/static/js/opManager/Workspace.js | 4 +++- src/wirecloud/platform/static/js/wirecloud/core.js | 7 +++++-- src/wirecloud/platform/workspace/utils.py | 5 +---- 6 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/wirecloud/platform/context/utils.py b/src/wirecloud/platform/context/utils.py index fadc6afac5..5411a5aa71 100644 --- a/src/wirecloud/platform/context/utils.py +++ b/src/wirecloud/platform/context/utils.py @@ -92,16 +92,6 @@ def get_workspace_context_current_values(workspace, user): return values -def get_workspace_context(workspace, user): - - context = copy.deepcopy(get_workspace_context_definitions()) - values = get_workspace_context_current_values(workspace, user) - for key in values: - context[key]['value'] = values[key] - - return context - - def get_constant_context_values(): res = {} diff --git a/src/wirecloud/platform/context/views.py b/src/wirecloud/platform/context/views.py index 0fcbd3d2e5..5eaa29d790 100644 --- a/src/wirecloud/platform/context/views.py +++ b/src/wirecloud/platform/context/views.py @@ -23,15 +23,19 @@ from wirecloud.commons.utils.encoding import LazyEncoder from wirecloud.commons.baseviews import Resource -from wirecloud.platform.context.utils import get_platform_context +from wirecloud.platform.context.utils import get_platform_context, get_workspace_context_definitions class PlatformContextCollection(Resource): def read(self, request): - context = get_platform_context(request.user) + context = { + 'platform': get_platform_context(request.user), + 'workspace': get_workspace_context_definitions() + } + if 'theme' in request.GET: - context['theme']['value'] = request.GET['theme'] + context['platform']['theme']['value'] = request.GET['theme'] return HttpResponse(json.dumps(context, cls=LazyEncoder, sort_keys=True), content_type='application/json; charset=UTF-8') diff --git a/src/wirecloud/platform/static/iphone/opManager/Workspace.js b/src/wirecloud/platform/static/iphone/opManager/Workspace.js index bd85a7b190..e969d9ba46 100644 --- a/src/wirecloud/platform/static/iphone/opManager/Workspace.js +++ b/src/wirecloud/platform/static/iphone/opManager/Workspace.js @@ -164,7 +164,9 @@ function Workspace(workspaceState, resources) { //set the visible tab. It will be displayed as current tab afterwards this.visibleTab = this.tabInstances[this.visibleTabIndex]; - this.contextManager = new Wirecloud.ContextManager(this, this.workspaceState.context); + this.contextManager = new Wirecloud.ContextManager(this, Wirecloud.constants.WORKSPACE_CONTEXT); + this.contextManager.modify({name: this.workspaceState.name, owner: this.workspaceState.owner}); + this.wiring = new Wirecloud.Wiring(this); iwidgets = this.getIWidgets(); for (i = 0; i < iwidgets.length; i += 1) { diff --git a/src/wirecloud/platform/static/js/opManager/Workspace.js b/src/wirecloud/platform/static/js/opManager/Workspace.js index a0c908d889..bb993d0dd9 100644 --- a/src/wirecloud/platform/static/js/opManager/Workspace.js +++ b/src/wirecloud/platform/static/js/opManager/Workspace.js @@ -115,7 +115,9 @@ function Workspace(workspaceState, resources) { } } - this.contextManager = new Wirecloud.ContextManager(this, this.workspaceState.context); + this.contextManager = new Wirecloud.ContextManager(this, Wirecloud.constants.WORKSPACE_CONTEXT); + this.contextManager.modify({name: this.workspaceState.name, owner: this.workspaceState.owner}); + this.wiring = new Wirecloud.Wiring(this); iwidgets = this.getIWidgets(); for (i = 0; i < iwidgets.length; i += 1) { diff --git a/src/wirecloud/platform/static/js/wirecloud/core.js b/src/wirecloud/platform/static/js/wirecloud/core.js index 2953739afc..1752b7505e 100644 --- a/src/wirecloud/platform/static/js/wirecloud/core.js +++ b/src/wirecloud/platform/static/js/wirecloud/core.js @@ -189,10 +189,13 @@ parameters: {theme: Wirecloud.constants.CURRENT_THEME}, requestHeaders: {'Accept': 'application/json'}, onSuccess: function (response) { - var url; + var url, context_info; options.monitor.nextSubtask(gettext('Processing initial context data')); - Wirecloud.contextManager = new Wirecloud.ContextManager(Wirecloud, JSON.parse(response.responseText)); + + context_info = JSON.parse(response.responseText); + Wirecloud.constants.WORKSPACE_CONTEXT = context_info.workspace; + Wirecloud.contextManager = new Wirecloud.ContextManager(Wirecloud, context_info.platform); Wirecloud.contextManager.modify({'mode': Wirecloud.constants.CURRENT_MODE}); // Init theme diff --git a/src/wirecloud/platform/workspace/utils.py b/src/wirecloud/platform/workspace/utils.py index 65162c0067..ea51450a4d 100644 --- a/src/wirecloud/platform/workspace/utils.py +++ b/src/wirecloud/platform/workspace/utils.py @@ -37,7 +37,7 @@ from wirecloud.commons.utils.db import save_alternative from wirecloud.commons.utils.encoding import LazyEncoder from wirecloud.commons.utils.html import clean_html -from wirecloud.platform.context.utils import get_workspace_context, get_context_values +from wirecloud.platform.context.utils import get_context_values from wirecloud.platform.iwidget.utils import parse_value_from_text from wirecloud.platform.preferences.views import get_workspace_preference_values, get_tab_preference_values from wirecloud.platform.models import IWidget, Tab, UserWorkspace, Workspace @@ -422,9 +422,6 @@ def process_forced_values(workspace, user, concept_values, preferences): def _get_global_workspace_data(workspaceDAO, user): data_ret = get_workspace_data(workspaceDAO, user) - # Context information - data_ret['context'] = get_workspace_context(workspaceDAO, user) - # Workspace preferences preferences = get_workspace_preference_values(workspaceDAO) data_ret['preferences'] = preferences