def buildWorkspaceFromTemplate(template, user, allow_renaming=False, new_name=None, new_title=None, searchable=True, public=False): if not isinstance(template, TemplateParser): template = TemplateParser(template) if template.get_resource_type() != 'mashup': raise TypeError('Unsupported resource type: %s' % template.get_resource_type()) if (new_name is None or new_name.strip() == '') and (new_title is None or new_title.strip() == ''): processed_info = template.get_resource_processed_info(process_urls=False) new_name = processed_info['name'] new_title = processed_info['title'] elif new_title is None or new_title.strip() == '': new_title = new_name elif new_name is None or new_name.strip() == '': new_name = URLify(new_title) # Workspace creation workspace = Workspace(title=new_title, name=new_name, creator=user, searchable=searchable, public=public) if allow_renaming: save_alternative(Workspace, 'name', workspace) else: workspace.save() # Adding user reference to workspace in the many to many relationship user_workspace = UserWorkspace(user=user, workspace=workspace) user_workspace.save() fillWorkspaceUsingTemplate(workspace, template) return (workspace, user_workspace)
def buildWorkspaceFromTemplate(template, user, allow_renaming=False, new_name=None): if not isinstance(template, TemplateParser): template = TemplateParser(template) if template.get_resource_type() != 'mashup': raise Exception() if new_name is not None: name = new_name else: name = template.get_resource_name() # Workspace creation workspace = Workspace(name=name, creator=user) if allow_renaming: save_alternative(Workspace, 'name', workspace) else: workspace.save() # Adding user reference to workspace in the many to many relationship user_workspace = UserWorkspace(user=user, workspace=workspace, active=False) user_workspace.save() fillWorkspaceUsingTemplate(workspace, template) return (workspace, user_workspace)
def buildWorkspaceFromTemplate(template, user, allow_renaming=False, new_name=None): if not isinstance(template, TemplateParser): template = TemplateParser(template) if template.get_resource_type() != 'mashup': raise TypeError('Unsupported resource type: %s' % template.get_resource_type()) if new_name is not None: name = new_name else: name = template.get_resource_processed_info( process_urls=False)['title'] # Workspace creation workspace = Workspace(name=name, creator=user) if allow_renaming: save_alternative(Workspace, 'name', workspace) else: workspace.save() # Adding user reference to workspace in the many to many relationship user_workspace = UserWorkspace(user=user, workspace=workspace, active=False) user_workspace.save() fillWorkspaceUsingTemplate(workspace, template) return (workspace, user_workspace)
def buildWorkspaceFromTemplate(template, user, allow_renaming=False, new_name=None): if not isinstance(template, TemplateParser): template = TemplateParser(template) if template.get_resource_type() != 'mashup': raise TypeError('Unsupported resource type: %s' % template.get_resource_type()) if new_name is not None: name = new_name else: name = template.get_resource_processed_info(process_urls=False)['title'] # Workspace creation workspace = Workspace(name=name, creator=user) if allow_renaming: save_alternative(Workspace, 'name', workspace) else: workspace.save() # Adding user reference to workspace in the many to many relationship user_workspace = UserWorkspace(user=user, workspace=workspace, active=False) user_workspace.save() fillWorkspaceUsingTemplate(workspace, template) return (workspace, user_workspace)
def createEmptyWorkspace(workspaceName, user, allow_renaming=False): workspace = Workspace(name=workspaceName, creator=user, wiringStatus=get_wiring_skeleton()) if allow_renaming is True: save_alternative(Workspace, 'name', workspace) else: workspace.save() UserWorkspace.objects.create(user=user, workspace=workspace) # Tab creation createTab(_('Tab'), workspace) return workspace
def createEmptyWorkspace(title, user, allow_renaming=False, name=None): if name is None or name == '': name = URLify(title) workspace = Workspace(title=title, name=name, creator=user, wiringStatus=get_wiring_skeleton()) if allow_renaming is True: save_alternative(Workspace, 'name', workspace) else: workspace.save() UserWorkspace.objects.create(user=user, workspace=workspace) # Tab creation createTab(_('Tab'), workspace) return workspace
def createEmptyWorkspace(workspaceName, user, allow_renaming=False): active = False workspaces = UserWorkspace.objects.filter(user__id=user.id, active=True) if workspaces.count() == 0: # there isn't yet an active workspace active = True workspace = Workspace(name=workspaceName, creator=user, wiringStatus=get_wiring_skeleton()) if allow_renaming is True: save_alternative(Workspace, 'name', workspace) else: workspace.save() UserWorkspace.objects.create(user=user, workspace=workspace, active=active) # Tab creation createTab(_('Tab'), workspace) return workspace
def createEmptyWorkspace(workspaceName, user, allow_renaming=False): workspace = Workspace(name=workspaceName, creator=user, wiringStatus=get_wiring_skeleton()) if allow_renaming is True: save_alternative(Workspace, 'name', workspace) else: workspace.full_clean(validate_unique=False) workspace.save() UserWorkspace.objects.create(user=user, workspace=workspace) # Tab creation createTab(_('Tab'), workspace) return workspace