Coverage for girder/models/collection : 90%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
#!/usr/bin/env python # -*- coding: utf-8 -*-
############################################################################### # Copyright 2013 Kitware Inc. # # Licensed under the Apache License, Version 2.0 ( the "License" ); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ###############################################################################
""" Collections are the top level roots of the data hierarchy. They are used to group and organize data that is meant to be shared amongst users. """
'name': 10, 'description': 1 })
"""Helper to filter the collection model.""" collection, allow=('_id', 'name', 'description', 'public', 'created', 'updated', 'size'))
raise ValidationException( 'Collection name must not be empty.', 'name')
# Ensure unique name for the collection 'name': doc['name'] } q['_id'] = {'$ne': doc['_id']} raise ValidationException('A collection with that name already' 'exists.', 'name')
""" Delete a collection recursively.
:param collection: The collection document to delete. :type collection: dict """ # Delete all folders in the community recursively 'parentId': collection['_id'], 'parentCollection': 'collection' }, limit=0)
# Delete this collection
""" Search for collections with full text search. """
level=AccessType.READ, limit=limit, offset=offset):
""" Create a new collection.
:param name: The name of the collection. Must be unique. :type name: str :param description: Description for the collection. :type description: str :param public: Public read access flag. :type public: bool :param creator: The user who is creating this collection. :type creator: dict :returns: The collection document that was created. """
'name': name, 'description': description, 'creatorId': creator['_id'], 'created': now, 'updated': now, 'size': 0 }
collection, user=creator, level=AccessType.ADMIN)
# Validate and save the collection
# Create some default folders for the collection and give the creator # admin access to them collection, 'Private', parentType='collection', public=False, creator=creator) privateFolder, creator, AccessType.ADMIN, save=True)
collection, 'Public', parentType='user', public=True, creator=creator) publicFolder, creator, AccessType.ADMIN, save=True)
""" Updates a collection.
:param collection: The collection document to update :type collection: dict :returns: The collection document that was edited. """ collection['updated'] = datetime.datetime.now()
# Validate and save the collection return self.save(collection) |