from dbpool import getConnection, getOne, getMany from auth import check_scope def get_wohnungen(token_info): check_scope(token_info, "wohnung/read") return getMany(""" SELECT w.id as id, w.objekt as objekt, w.shortname as shortname, w.flaeche as flaeche, o.shortname as objekt_shortname FROM wohnung w, objekt o WHERE o.id = w.objekt """, [], "Wohnung") def get_wohnung(id, token_info): check_scope(token_info, [ "wohnung/read", "objekt/read" ]) return getOne(""" SELECT w.id as id, w.objekt as objekt, w.shortname as shortname, w.flaeche as flaeche, o.shortname as objekt_shortname FROM wohnung w, objekt o WHERE o.id = w.objekt AND w.id = ? """, (id, ), "Wohnung") def get_wohnungen_by_objekt(id, token_info): check_scope(token_info, [ "wohnung/read", "objekt/read" ]) return getMany(""" SELECT w.id as id, w.objekt as objekt, w.shortname as shortname, w.flaeche as flaeche, o.shortname as objekt_shortname FROM wohnung w, objekt o WHERE o.id = w.objekt AND o.id = ? """, [ id ], "Wohnung")