Example #1
0
 def test_public_project_entity_read__draft_status(self):
     project, permission = _project_and_permission()
     entity = Entity(project=project, status=authz.PUBLISHED_THRESHOLD-1)
     db.session.add(entity)
     db.session.commit()
     with self.app.test_request_context():
         flask.session['id'] = 1
         self.app.preprocess_request()
         self.assertFalse(authz.entity_read(entity))
Example #2
0
 def test_private_project_entity_read__publish_status_reader(self):
     project, permission = _project_and_permission(private=True,
         reader=True)
     entity = Entity(project=project, status=authz.PUBLISHED_THRESHOLD)
     db.session.add(entity)
     db.session.commit()
     with self.app.test_request_context():
         flask.session['id'] = 1
         self.app.preprocess_request()
         self.assertTrue(authz.entity_read(entity))
Example #3
0
def graph(id):
    entity = object_or_404(Entity.by_id(id))
    authz.require(authz.entity_read(entity))
    entity_properties = request.args.getlist('entity_property')
    extractor = GraphExtractor(root_id=entity.id,
                               entity_properties=entity_properties)
    validate_cache(keys=extractor.to_hash())
    if extractor.format == 'gexf':
        return Response(extractor.to_gexf(),
                        mimetype='text/xml')
    return jsonify(extractor)
Example #4
0
def view(id):
    entity = object_or_404(Entity.by_id(id))
    authz.require(authz.entity_read(entity))
    return jsonify(entity)