예제 #1
0
파일: views.py 프로젝트: yanyshen/P2Portal
    def post(self, request):
        user = request.user
        parentNode = self.CONTENT.get('parent')
        text = self.CONTENT.get('text')
        reType = self.CONTENT.get('type')
        description = self.CONTENT.get('description')
        for node in parentNode.node_set.all():
            if node.text == text:
                raise ErrorResponse(status.HTTP_400_BAD_REQUEST, 'Duplicated name under ' + parentNode.text)

        site, parentRelativePath = parentNode.get_site_and_path()
        nodeRelativePath = os.path.join(parentRelativePath, text)
        nodeFolder = os.path.join(parentNode.get_full_path(), text)
        
        if(reType == 'R'):
            if(User.has_perm(user, 'repo.add_repository', None)):
                p2_folder = p2.Folder(nodeFolder)
                p2_folder.addRepositoryFolder()
                repo = dbhandler.create_repository(text, nodeRelativePath, description, site, parentNode)
                node = repo.node
            else:
                raise PermissionDenied
        if(reType == 'C'):
            if(User.has_perm(user, 'repo.add_composite', None)):
                p2_folder = p2.Folder(nodeFolder)
                p2_folder.addCompositeFolder()
                com = dbhandler.create_composite(text, nodeRelativePath, site, parentNode)
                node = com.node
            else:
                raise PermissionDenied
        return node.as_node()
예제 #2
0
파일: setup.py 프로젝트: eBay/P2Portal
def create_composite(name, path, site):
    com = dbhandler.create_composite(name, path, site)
    return com.node
예제 #3
0
파일: setup.py 프로젝트: yanyshen/P2Portal
def create_composite(name, path, site):
    com = dbhandler.create_composite(name, path, site)
    return com.node