def createWorkSpace (workSpaceName, user): 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 creation workspace = WorkSpace(name=workSpaceName, creator=user) workspace.save() #Adding user reference to workspace in the many to many relationship user_workspace = UserWorkSpace(user=user, workspace=workspace, active=active) user_workspace.save() #Tab creation tab_ids = createTab ('MyTab', user, workspace) # Returning created Ids ids = {} ids['workspace'] = {} ids['workspace']['id'] = workspace.id ids['workspace']['name'] = workspace.name ids['workspace']['tab'] = tab_ids return ids
def add_user_to_workspace(self, workspace, user): #Checking if user is already linked to workspace if (len(workspace.users.filter(id=user.id)) == 0): user_workspace = UserWorkSpace(user=user, workspace=workspace, active=False) user_workspace.save()
def createEmptyWorkSpace(workSpaceName, user): 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 creation workspace = WorkSpace(name=workSpaceName, creator=user) workspace.save() #Adding user reference to workspace in the many to many relationship user_workspace = UserWorkSpace(user=user, workspace=workspace, active=active) user_workspace.save() #Tab creation createTab('MyTab', user, workspace) return workspace
def buildWorkspaceFromTemplate(template, user): if isinstance(template, unicode): # Work around: ValueError: Unicode strings with encoding declaration # are not supported. template = template.encode('utf-8') xml = etree.fromstring(template) name = NAME_XPATH(xml)[0].text # Workspace creation workspace = WorkSpace(name=name, creator=user) 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, xml) return (workspace, user_workspace)
# GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with Morfeo EzWeb Platform. If not, see <http://www.gnu.org/licenses/>. # # Info about members and contributors of the MORFEO project # is available at # # http://morfeo-project.org # #...............................licence...........................................# from workspace.models import UserWorkSpace, WorkSpace from django.contrib.auth.models import User mapping_file = open('mapping.txt', 'r') mapping_text = mapping_file.read() mapping_file.close() mapping = eval(mapping_text) for (workspace_id, user_id, active) in mapping: user = User.objects.get(id=user_id) workspace = WorkSpace.objects.get(id=workspace_id) user_workspace = UserWorkSpace(user=user, workspace=workspace, active=active) user_workspace.save()
# You should have received a copy of the GNU Affero General Public License # along with Morfeo EzWeb Platform. If not, see <http://www.gnu.org/licenses/>. # # Info about members and contributors of the MORFEO project # is available at # # http://morfeo-project.org # #...............................licence...........................................# from workspace.models import UserWorkSpace, WorkSpace from django.contrib.auth.models import User mapping_file = open('mapping.txt', 'r') mapping_text = mapping_file.read() mapping_file.close() mapping = eval(mapping_text) for (workspace_id, user_id, active) in mapping: user = User.objects.get(id=user_id) workspace = WorkSpace.objects.get(id=workspace_id) user_workspace = UserWorkSpace(user=user, workspace=workspace, active=active) user_workspace.save()