def delete(self, relation_id, when=None): if when is None: when = datetime.now(utc) relation = Relation.load_by_relation_id(self.env, relation_id) source = relation.source destination = relation.destination relation_type = relation.type with self.env.db_transaction: cloned_relation = relation.clone() relation.delete() other_end = self.link_ends_map[relation_type] if other_end: reverted_relation = Relation(self.env, keys=dict( source=destination, destination=source, type=other_end, )) reverted_relation.delete() for listener in self.changing_listeners: listener.deleting_relation(cloned_relation, when) from bhrelations.notification import RelationNotifyEmail RelationNotifyEmail(self.env).notify(cloned_relation, deleted=when)
def remove_relations(self, req, rellist): relsys = RelationsSystem(self.env) for relid in rellist: relation = Relation.load_by_relation_id(self.env, relid) resource = ResourceIdSerializer.get_resource_by_id( relation.destination) if 'TICKET_MODIFY' in req.perm(resource): relsys.delete(relid) else: add_warning(req, _('Not enough permissions to remove relation "%s"' % relid))
def remove_relations(self, req, rellist): relsys = RelationsSystem(self.env) for relid in rellist: relation = Relation.load_by_relation_id(self.env, relid) resource = \ ResourceIdSerializer.get_resource_by_id(relation.destination) if 'TICKET_MODIFY' in req.perm(resource): relsys.delete(relid) else: add_warning(req, _('Insufficient permissions to remove ' 'relation "%(relation)s"', relation=relid))
def delete(self, relation_id, when=None): if when is None: when = datetime.now(utc) relation = Relation.load_by_relation_id(self.env, relation_id) source = relation.source destination = relation.destination relation_type = relation.type with self.env.db_transaction: cloned_relation = relation.clone() relation.delete() other_end = self.link_ends_map[relation_type] if other_end: reverted_relation = Relation(self.env, keys=dict( source=destination, destination=source, type=other_end, )) reverted_relation.delete() for listener in self.changing_listeners: listener.deleting_relation(cloned_relation, when) from bhrelations.notification import RelationNotifyEmail RelationNotifyEmail(self.env).notify(cloned_relation, deleted=when)