def _check_related_permissions(self, obj): """Check permissions before deleting related Evidence or Document""" if not permissions.is_allowed_delete( obj.type, obj.id, obj.context_id) \ and not permissions.has_conditions("delete", obj.type): raise wzg_exceptions.Forbidden() if not permissions.is_allowed_delete_for(obj): raise wzg_exceptions.Forbidden()
def contribute_to_program_view(sender, obj=None, context=None): if obj.context_id is not None and \ rbac_permissions.is_allowed_read('Role', None, 1) and \ rbac_permissions.is_allowed_read('UserRole', None, obj.context_id) and \ rbac_permissions.is_allowed_create('UserRole', None, obj.context_id) and \ rbac_permissions.is_allowed_update('UserRole', None, obj.context_id) and \ rbac_permissions.is_allowed_delete('UserRole', None, obj.context_id): return 'permissions/programs/_role_assignments.haml' return None
def contribute_to_program_view(sender, obj=None, context=None): if obj.context_id != None and \ permissions.is_allowed_read('Role', 1) and \ permissions.is_allowed_read('UserRole', obj.context_id) and \ permissions.is_allowed_create('UserRole', obj.context_id) and \ permissions.is_allowed_update('UserRole', obj.context_id) and \ permissions.is_allowed_delete('UserRole', obj.context_id): return 'permissions/programs/_role_assignments.haml' return None
def delete(self, id): obj = self.get_object(id) if obj is None: return self.not_found_response() header_error = self.validate_headers_for_put_or_delete(obj) if header_error: return header_error if not permissions.is_allowed_delete(self.model.__name__, obj.context_id): raise Forbidden() db.session.delete(obj) log_event(db.session, obj) db.session.commit() get_indexer().delete_record(id, self.model.__name__) return self.json_success_response(self.object_for_json(obj), self.modified_at(obj))
def delete(self, id): obj = self.get_object(id) if obj is None: return self.not_found_response() header_error = self.validate_headers_for_put_or_delete(obj) if header_error: return header_error if not permissions.is_allowed_delete(self.model.__name__, obj.context_id): raise Forbidden() db.session.delete(obj) db.session.commit() get_indexer().delete_record(self.url_for(id=id)) return self.json_success_response(self.object_for_json(obj), self.modified_at(obj))