示例#1
0
def update(id):
    relation = object_or_404(Relation.by_id(id))
    authz.require(authz.relation_edit(relation))
    data = request_data({'author': request.account})
    relation = relations.save(data, relation=relation)
    db.session.commit()
    return jsonify(relation)
示例#2
0
def update(id):
    relation = object_or_404(Relation.by_id(id))
    authz.require(authz.relation_edit(relation))
    data = request_data({'author': request.account})
    relation = relations.save(data, relation=relation)
    db.session.commit()
    return jsonify(relation)
示例#3
0
 def test_entity_edit__uneditable(self):
     project, permission = _project_and_permission(editor=False)
     entity_source = \
         Entity(project=project, status=authz.PUBLISHED_THRESHOLD)
     entity_target = \
         Entity(project=project, status=authz.PUBLISHED_THRESHOLD)
     db.session.add(entity_source)
     db.session.add(entity_target)
     rel = Relation(source=entity_source, target=entity_target)
     db.session.add(rel)
     db.session.commit()
     with self.app.test_request_context():
         flask.session['id'] = 1
         self.app.preprocess_request()
         self.assertFalse(authz.relation_edit(rel))
示例#4
0
文件: test_authz.py 项目: 01-/grano
 def test_entity_edit__uneditable(self):
     project, permission = _project_and_permission(editor=False)
     entity_source = \
         Entity(project=project, status=authz.PUBLISHED_THRESHOLD)
     entity_target = \
         Entity(project=project, status=authz.PUBLISHED_THRESHOLD)
     db.session.add(entity_source)
     db.session.add(entity_target)
     rel = Relation(source=entity_source, target=entity_target)
     db.session.add(rel)
     db.session.commit()
     with self.app.test_request_context():
         flask.session['id'] = 1
         self.app.preprocess_request()
         self.assertFalse(authz.relation_edit(rel))
示例#5
0
def delete(id):
    relation = object_or_404(Relation.by_id(id))
    authz.require(authz.relation_edit(relation))
    relations.delete(relation)
    db.session.commit()
    raise Gone()
示例#6
0
def delete(id):
    relation = object_or_404(Relation.by_id(id))
    authz.require(authz.relation_edit(relation))
    relations.delete(relation)
    db.session.commit()
    raise Gone()