示例#1
0
 def setUp(self):
     super(EntitiesApiTestCase, self).setUp()
     self.coll = Collection()
     self.coll.title = "Test Collection"
     session.add(self.coll)
     session.flush()
     permission = Permission()
     permission.role_id = Role.SYSTEM_USER
     permission.read = True
     permission.write = True
     permission.resource_id = self.coll.id
     permission.resource_type = Permission.COLLECTION
     session.add(permission)
     self.schema_uri = 'https://schema.occrp.org/generic/organization.json#'
     self.entity = {'id': 'foo', 'name': 'Foobar'}
     self.config.entities.save(self.schema_uri,
                               self.entity,
                               collection_id=self.coll.id)
     cs = CollectionSubject(self.coll, self.entity['id'])
     session.add(cs)
     entity = {'id': 'test', 'name': 'Testing'}
     self.config.entities.save(self.schema_uri,
                               entity,
                               collection_id=self.coll.id)
     cs = CollectionSubject(self.coll, entity['id'])
     session.add(cs)
     session.commit()
 def setUp(self):
     super(EntitiesApiTestCase, self).setUp()
     self.coll = Collection()
     self.coll.title = "Test Collection"
     session.add(self.coll)
     session.flush()
     permission = Permission()
     permission.role_id = Role.SYSTEM_USER
     permission.read = True
     permission.write = True
     permission.resource_id = self.coll.id
     permission.resource_type = Permission.COLLECTION
     session.add(permission)
     self.schema_uri = 'https://schema.occrp.org/generic/organization.json#'
     self.entity = {'id': 'foo', 'name': 'Foobar'}
     self.config.entities.save(self.schema_uri, self.entity,
                               collection_id=self.coll.id)
     cs = CollectionSubject(self.coll, self.entity['id'])
     session.add(cs)
     entity = {'id': 'test', 'name': 'Testing'}
     self.config.entities.save(self.schema_uri, entity,
                               collection_id=self.coll.id)
     cs = CollectionSubject(self.coll, entity['id'])
     session.add(cs)
     session.commit()
 def setUp(self):
     super(PermissionsApiTestCase, self).setUp()
     self.coll = Collection()
     self.coll.title = "Test Collection"
     session.add(self.coll)
     session.flush()
     permission = Permission()
     permission.role_id = Role.SYSTEM_USER
     permission.read = True
     permission.write = True
     permission.resource_id = self.coll.id
     permission.resource_type = Permission.COLLECTION
     session.add(permission)
     session.flush()
     session.commit()
 def setUp(self):
     super(PermissionsApiTestCase, self).setUp()
     self.coll = Collection()
     self.coll.title = "Test Collection"
     session.add(self.coll)
     session.flush()
     permission = Permission()
     permission.role_id = Role.SYSTEM_USER
     permission.read = True
     permission.write = True
     permission.resource_id = self.coll.id
     permission.resource_type = Permission.COLLECTION
     session.add(permission)
     session.flush()
     session.commit()
示例#5
0
 def setUp(self):
     super(SourcesApiTestCase, self).setUp()
     self.source = Source()
     self.source.slug = "test"
     self.source.title = "Test Collection"
     self.source.url = "http://test.com/"
     session.add(self.source)
     session.flush()
     permission = Permission()
     permission.role_id = Role.SYSTEM_USER
     permission.read = True
     permission.write = True
     permission.resource_id = self.source.id
     permission.resource_type = Permission.SOURCE
     session.add(permission)
     session.commit()
 def setUp(self):
     super(SourcesApiTestCase, self).setUp()
     self.source = Source()
     self.source.slug = "test"
     self.source.title = "Test Collection"
     self.source.url = "http://test.com/"
     session.add(self.source)
     session.flush()
     permission = Permission()
     permission.role_id = Role.SYSTEM_USER
     permission.read = True
     permission.write = True
     permission.resource_id = self.source.id
     permission.resource_type = Permission.SOURCE
     session.add(permission)
     session.commit()
示例#7
0
def create():
    authz.require(authz.logged_in())
    data = request_data()
    validate(data, collections_schema)
    collection = Collection()
    collection.title = data.get('title')
    session.add(collection)
    update_subjects(collection, data)
    session.flush()
    permission = Permission()
    permission.resource_id = collection.id
    permission.resource_type = Permission.COLLECTION
    permission.read = True
    permission.write = True
    permission.role_id = request.auth_user
    session.add(permission)
    session.commit()
    return jsonify({'status': 'ok', 'data': collection}, status=201)