當前位置: 首頁>>代碼示例>>Python>>正文


Python models.OsfStorageFolder類代碼示例

本文整理匯總了Python中addons.osfstorage.models.OsfStorageFolder的典型用法代碼示例。如果您正苦於以下問題:Python OsfStorageFolder類的具體用法?Python OsfStorageFolder怎麽用?Python OsfStorageFolder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了OsfStorageFolder類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_get_file_guids_for_live_folder_wo_guids

    def test_get_file_guids_for_live_folder_wo_guids(self):
        node = self.node_settings.owner
        folder = OsfStorageFolder(name='foofolder', node=node)
        folder.save()

        files = []
        for i in range(1, 4):
            files.append(folder.append_file('foo.{}'.format(i)))

        all_guids = OsfStorageFileNode.get_file_guids(
            '/' + folder._id, provider='osfstorage', node=node)
        assert [] == all_guids
開發者ID:adlius,項目名稱:osf.io,代碼行數:12,代碼來源:test_models.py

示例2: test_move_preprint_primary_file_within_preprint

    def test_move_preprint_primary_file_within_preprint(self):
        user = UserFactory()
        preprint = PreprintFactory(creator=user)
        preprint.save()
        folder = OsfStorageFolder(name='foofolder', target=preprint)
        folder.save()

        to_move = preprint.files.all()[0]
        assert_true(to_move.is_preprint_primary)

        moved = to_move.move_under(folder, name='Tuna')
        assert preprint.primary_file == to_move
        assert to_move.parent == folder
        assert folder.target == preprint
開發者ID:CenterForOpenScience,項目名稱:osf.io,代碼行數:14,代碼來源:test_models.py

示例3: test_get_file_guids_for_live_folder

    def test_get_file_guids_for_live_folder(self):
        node = self.node_settings.owner
        folder = OsfStorageFolder(name='foofolder', node=node)
        folder.save()

        files = []
        for i in range(1, 4):
            files.append(folder.append_file('foo.{}'.format(i)))
            files[-1].get_guid(create=True)

        guids = [file.get_guid()._id for file in files]
        assert len(guids) == len(files)

        all_guids = OsfStorageFileNode.get_file_guids(
            '/' + folder._id, provider='osfstorage', node=node)
        assert sorted(guids) == sorted(all_guids)
開發者ID:adlius,項目名稱:osf.io,代碼行數:16,代碼來源:test_models.py

示例4: osfstorage_get_lineage

def osfstorage_get_lineage(file_node, node_addon, **kwargs):
    #TODO Profile
    list(OsfStorageFolder.find(Q('node', 'eq', node_addon.owner)))

    lineage = []

    while file_node:
        lineage.append(file_node.serialize())
        file_node = file_node.parent

    return {'data': lineage}
開發者ID:adlius,項目名稱:osf.io,代碼行數:11,代碼來源:views.py

示例5: wrapped

    def wrapped(payload, *args, **kwargs):
        try:
            user = OSFUser.load(payload['user'])
            dest_node = AbstractNode.load(payload['destination']['node'])
            source = OsfStorageFileNode.get(payload['source'], kwargs['node'])
            dest_parent = OsfStorageFolder.get(payload['destination']['parent'], dest_node)

            kwargs.update({
                'user': user,
                'source': source,
                'destination': dest_parent,
                'name': payload['destination']['name'],
            })
        except KeyError:
            raise HTTPError(httplib.BAD_REQUEST)

        return func(*args, **kwargs)
開發者ID:geeksnglitter,項目名稱:osf.io,代碼行數:17,代碼來源:decorators.py

示例6: post

    def post(self, request, *args, **kwargs):
        serializer = self.serializer_class(data=request.data, context=self.get_serializer_context())
        if serializer.is_valid():
            source = serializer.validated_data.pop('source')
            destination = serializer.validated_data.pop('destination')
            name = destination.get('name')
            dest_target = self.get_target(target_id=destination.get('target'))
            try:
                source = OsfStorageFileNode.get(source, self.get_object())
            except OsfStorageFileNode.DoesNotExist:
                raise NotFound

            try:
                dest_parent = OsfStorageFolder.get(destination.get('parent'), dest_target)
            except OsfStorageFolder.DoesNotExist:
                raise NotFound
            serializer.save(source=source, destination=dest_parent, name=name)
            return Response(serializer.data, status=status.HTTP_201_CREATED)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
開發者ID:erinspace,項目名稱:osf.io,代碼行數:19,代碼來源:views.py

示例7: wrapped

    def wrapped(payload, *args, **kwargs):
        try:
            user = OSFUser.load(payload['user'])
            # Waterbutler is sending back ['node'] under the destination payload - WB should change to target
            target = payload['destination'].get('target') or payload['destination'].get('node')
            dest_target = Guid.load(target).referent
            source = OsfStorageFileNode.get(payload['source'], kwargs['target'])
            dest_parent = OsfStorageFolder.get(payload['destination']['parent'], dest_target)

            kwargs.update({
                'user': user,
                'source': source,
                'destination': dest_parent,
                'name': payload['destination']['name'],
            })
        except KeyError:
            raise HTTPError(httplib.BAD_REQUEST)

        return func(*args, **kwargs)
開發者ID:CenterForOpenScience,項目名稱:osf.io,代碼行數:19,代碼來源:decorators.py

示例8: test_get_file_guids_for_trashed_folder_recursive_wo_guids

    def test_get_file_guids_for_trashed_folder_recursive_wo_guids(self):
        node = self.node_settings.owner
        folder = OsfStorageFolder(name='foofolder', target=node)
        folder.save()

        files = []
        for i in range(1, 4):
            files.append(folder.append_file('foo.{}'.format(i)))

        subfolder = folder.append_folder('subfoo')
        for i in range(1, 4):
            files.append(subfolder.append_file('subfoo.{}'.format(i)))

        folder.delete()

        all_guids = OsfStorageFileNode.get_file_guids(
            '/' + folder._id, provider='osfstorage', target=node)
        assert [] == all_guids
開發者ID:erinspace,項目名稱:osf.io,代碼行數:18,代碼來源:test_models.py

示例9: create_file_node

def create_file_node(sender, instance, **kwargs):
    if instance.root_folder:
        return
    # Note: The "root" node will always be "named" empty string
    root_folder = OsfStorageFolder(name='', target=instance, is_root=True)
    root_folder.save()
開發者ID:CenterForOpenScience,項目名稱:osf.io,代碼行數:6,代碼來源:preprint.py


注:本文中的addons.osfstorage.models.OsfStorageFolder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。