Example #1
0
def rpc_Folders_getRoot(request):
    """Get root folder. """
    try:
        folder = Folder.objects.get(owner=request.user, parent__isnull=True)
    except Folder.DoesNotExist:
        folder = Folder(owner=request.user, title="My folders")
        folder.save()

    return { 'ok': True, 'guid': folder.guid, 'title': folder.title }
Example #2
0
def rpc_Folders_addFolder(request, guid, title):
    """Add new folder with the given title to the parent. """
    try:
        parent = Folder.objects.get(guid=guid)
    except Folder.DoesNotExist:
        return { 'ok': False, 'reason': 'does-not-exist' }

    folder = Folder(owner=request.user, parent=parent, title=title)
    folder.save()

    return { 'ok': True, 'guid': folder.guid }
Example #3
0
    def test_add_folder(self):
        folder = Folder(owner=self.user1, title="test_folder1")
        folder.save()

        # login 
        logged_in = self.client.login(username='******', password='******')
        assert logged_in
    
        # check if new folder was saved and we can access it
        response = self.client.get('/bookshelf/folders')
        resp = json.loads(response.content)
        assert response.status_code == 200
        assert resp[0][1] == "test_folder1"
        folder.delete() #clean up
Example #4
0
    def test_add_folder(self):
        folder = Folder(owner=self.user1, title="test_folder1")
        folder.save()

        # login
        logged_in = self.client.login(username='******', password='******')
        assert logged_in

        # check if new folder was saved and we can access it
        response = self.client.get('/bookshelf/folders')
        resp = json.loads(response.content)
        assert response.status_code == 200
        assert resp[0][1] == "test_folder1"
        folder.delete()  #clean up
Example #5
0
def rpc_Folders_addRoot(request, title):
    """Add new root folder. """
    folder = Folder(owner=request.user, title=title)
    folder.save()
    return { 'ok': True, 'guid': folder.guid }