hv-service/Wohnungen.py

42 lines
1.1 KiB
Python
Raw Permalink Normal View History

from dbpool import getConnection, getOne, getMany
2021-01-27 14:13:49 +01:00
from auth import check_scope
2021-01-16 19:47:34 +01:00
2021-01-27 14:13:49 +01:00
def get_wohnungen(token_info):
check_scope(token_info, "wohnung/read")
return getMany("""
2021-01-16 19:47:34 +01:00
SELECT w.id as id,
2021-01-18 20:24:57 +01:00
w.objekt as objekt,
w.shortname as shortname,
2021-01-16 19:47:34 +01:00
w.flaeche as flaeche,
2021-01-18 20:24:57 +01:00
o.shortname as objekt_shortname
2021-01-16 19:47:34 +01:00
FROM wohnung w, objekt o
WHERE o.id = w.objekt
2021-01-17 14:45:11 +01:00
""", [], "Wohnung")
2021-01-16 19:47:34 +01:00
2021-01-27 14:13:49 +01:00
def get_wohnung(id, token_info):
check_scope(token_info, [ "wohnung/read", "objekt/read" ])
return getOne("""
2021-01-16 19:47:34 +01:00
SELECT w.id as id,
2021-01-18 20:24:57 +01:00
w.objekt as objekt,
w.shortname as shortname,
2021-01-16 19:47:34 +01:00
w.flaeche as flaeche,
2021-01-18 20:24:57 +01:00
o.shortname as objekt_shortname
2021-01-16 19:47:34 +01:00
FROM wohnung w, objekt o
WHERE o.id = w.objekt AND
w.id = ?
""", (id, ), "Wohnung")
2021-01-18 18:37:19 +01:00
2021-01-27 14:13:49 +01:00
def get_wohnungen_by_objekt(id, token_info):
check_scope(token_info, [ "wohnung/read", "objekt/read" ])
2021-01-18 18:37:19 +01:00
return getMany("""
SELECT w.id as id,
2021-01-18 20:24:57 +01:00
w.objekt as objekt,
w.shortname as shortname,
2021-01-18 18:37:19 +01:00
w.flaeche as flaeche,
2021-01-18 20:24:57 +01:00
o.shortname as objekt_shortname
2021-01-18 18:37:19 +01:00
FROM wohnung w, objekt o
WHERE o.id = w.objekt AND
o.id = ?
""", [ id ], "Wohnung")