Skip to content

Commit

Permalink
Remove context from the workspace info
Browse files Browse the repository at this point in the history
  • Loading branch information
aarranz committed May 30, 2016
1 parent 4951bf4 commit 9ffdd48
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 21 deletions.
10 changes: 0 additions & 10 deletions src/wirecloud/platform/context/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}

Expand Down
10 changes: 7 additions & 3 deletions src/wirecloud/platform/context/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
4 changes: 3 additions & 1 deletion src/wirecloud/platform/static/iphone/opManager/Workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion src/wirecloud/platform/static/js/opManager/Workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 5 additions & 2 deletions src/wirecloud/platform/static/js/wirecloud/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions src/wirecloud/platform/workspace/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9ffdd48

Please sign in to comment.