def owned(): """Get objects for which the user is owner.""" res = db.session.query( query_helpers.get_myobjects_query( types=[object_class.__name__], contact_id=exp["ids"][0], is_creator=is_creator(), ).alias().c.id) res = res.all() if res: return object_class.id.in_([obj.id for obj in res]) return sa.sql.false()
def search_get_owner_query(self, query, types=None, contact_id=None): """Prepare the search query based on the contact_id to return my objects. This method is used only for dashboard and returns objects the user is the owner. """ if not contact_id: return query union_query = query_helpers.get_myobjects_query( types=types, contact_id=contact_id, is_creator=is_creator()) return query.join( union_query, and_(union_query.c.id == MysqlRecordProperty.key, union_query.c.type == MysqlRecordProperty.type), )
def search_get_owner_query(query, types=None, contact_id=None): """Prepare the search query based on the contact_id to return my objects. This method is used only for dashboard and returns objects the user is the owner. """ if not contact_id: return query union_query = query_helpers.get_myobjects_query( types=types, contact_id=contact_id, is_creator=is_creator() ) return query.join( union_query, and_( union_query.c.id == MysqlRecordProperty.key, union_query.c.type == MysqlRecordProperty.type), )
def owned(ids): """Get objects for which the user is owner. Note: only the first id from the list of ids is used. Args: ids: the ids of owners. Returns: sqlalchemy.sql.elements.BinaryExpression if an object of `object_class` is owned by one of the given users. """ res = db.session.query( query_helpers.get_myobjects_query( types=[object_class.__name__], contact_id=ids[0], is_creator=is_creator(), ).alias().c.id) res = res.all() if res: return object_class.id.in_([obj.id for obj in res]) return sa.sql.false()
def owned(exp, object_class, target_class, query): """Get objects for which the user is owner. Note: only the first id from the list of ids is used. Args: ids: the ids of owners. Returns: sqlalchemy.sql.elements.BinaryExpression if an object of `object_class` is owned by one of the given users. """ res = db.session.query( query_helpers.get_myobjects_query( types=[object_class.__name__], contact_id=exp['ids'][0], is_creator=is_creator(), ).alias().c.id ) res = res.all() if res: return object_class.id.in_([obj.id for obj in res]) return sqlalchemy.sql.false()