예제 #1
0
def load_list_of_workspaces(request):
    workspaces_owned = []
    if permissions.can_create_workspace(request.user):
        workspaces_owned = Workspace.objects.filter(owner=request.user.userprofile)

    workspaces = [{'id': workspace.id, 'name': workspace.name} for workspace in workspaces_owned]
    return HttpResponse(json.dumps(workspaces), content_type='application/json')
예제 #2
0
def load_list_of_workspaces(request):
    workspaces_owned = []
    if permissions.can_create_workspace(request.user):
        workspaces_owned = Workspace.objects.filter(owner=request.user.userprofile)

    workspaces = [{'id': workspace.id, 'name': workspace.name, 'blockly_enabled': workspace.blockly_enabled, 'python_enabled': workspace.python_enabled}
                  for workspace in workspaces_owned]
    return HttpResponse(json.dumps(workspaces), content_type='application/json')
예제 #3
0
def load_list_of_workspaces(request):
    workspaces_owned = []
    if permissions.can_create_workspace(request.user):
        workspaces_owned = Workspace.objects.filter(owner=request.user.userprofile)

    workspaces = [
        {
            "id": workspace.id,
            "name": workspace.name,
            "blockly_enabled": workspace.blockly_enabled,
            "python_enabled": workspace.python_enabled,
        }
        for workspace in workspaces_owned
    ]

    return HttpResponse(json.dumps(workspaces), content_type="application/json")
예제 #4
0
def save_workspace(request, workspaceID=None):
    name = request.POST.get('name')
    contents = request.POST.get('contents')
    python_contents = request.POST.get('python_contents')

    workspace = None
    if workspaceID:
        workspace = Workspace.objects.get(id=workspaceID)
    elif permissions.can_create_workspace(request.user):
        workspace = Workspace(owner=request.user.userprofile)

    if workspace and permissions.can_save_workspace(request.user, workspace):
        workspace.name = name
        workspace.contents = contents
        workspace.python_contents = python_contents
        workspace.save()

    return load_list_of_workspaces(request)
예제 #5
0
def save_workspace(request, workspaceID=None):
    name = request.POST.get('name')
    contents = request.POST.get('contents')
    python_contents = request.POST.get('python_contents')

    workspace = None
    if workspaceID:
        workspace = Workspace.objects.get(id=workspaceID)
    elif permissions.can_create_workspace(request.user):
        workspace = Workspace(owner=request.user.userprofile)

    if workspace and permissions.can_save_workspace(request.user, workspace):
        workspace.name = name
        workspace.contents = contents
        workspace.python_contents = python_contents
        workspace.save()

    return load_list_of_workspaces(request)
예제 #6
0
def save_workspace(request, workspaceID=None):
    name = request.POST.get("name")
    contents = request.POST.get("contents")
    python_contents = request.POST.get("python_contents")
    blockly_enabled = json.loads(request.POST.get("blockly_enabled"))
    python_enabled = json.loads(request.POST.get("python_enabled"))

    workspace = None
    if workspaceID:
        workspace = Workspace.objects.get(id=workspaceID)
    elif permissions.can_create_workspace(request.user):
        workspace = Workspace(owner=request.user.userprofile)

    if workspace and permissions.can_save_workspace(request.user, workspace):
        workspace.name = name
        workspace.contents = contents
        workspace.python_contents = python_contents
        workspace.blockly_enabled = blockly_enabled
        workspace.python_enabled = python_enabled
        workspace.save()

    return load_list_of_workspaces(request)
예제 #7
0
def save_workspace(request, workspaceID=None):
    name = request.POST.get("name")
    contents = request.POST.get("contents")
    python_contents = request.POST.get("python_contents")
    blockly_enabled = json.loads(request.POST.get("blockly_enabled"))
    python_enabled = json.loads(request.POST.get("python_enabled"))

    workspace = None
    if workspaceID:
        workspace = Workspace.objects.get(id=workspaceID)
    elif permissions.can_create_workspace(request.user):
        workspace = Workspace(owner=request.user.userprofile)

    if workspace and permissions.can_save_workspace(request.user, workspace):
        workspace.name = name
        workspace.contents = contents
        workspace.python_contents = python_contents
        workspace.blockly_enabled = blockly_enabled
        workspace.python_enabled = python_enabled
        workspace.save()

    return load_list_of_workspaces(request)