diff --git a/data/compile.py b/data/compile.py index 14f034811..2cc7c0ede 100644 --- a/data/compile.py +++ b/data/compile.py @@ -82,6 +82,7 @@ def main(): images.add_img(data) logging.info("-- 80 Generate info card") + sections.extract_calendar_urls(data) sections.compute_props(data) sections.localize_links(data) diff --git a/data/processors/export.py b/data/processors/export.py index ba3fab23e..60a2b3fdb 100644 --- a/data/processors/export.py +++ b/data/processors/export.py @@ -108,7 +108,8 @@ def export_for_api(data, path): if "roomfinder_data" in export_data[_id]: del export_data[_id]["roomfinder_data"] if "props" in export_data[_id]: - to_delete = [e for e in export_data[_id]["props"].keys() if e not in {"computed", "links", "comment"}] + prop_keys_to_keep = {"computed", "links", "comment", "calendar_url"} + to_delete = [e for e in export_data[_id]["props"].keys() if e not in prop_keys_to_keep] for k in to_delete: del export_data[_id]["props"][k] diff --git a/data/processors/sections.py b/data/processors/sections.py index 4ec1c1535..ad17709c6 100644 --- a/data/processors/sections.py +++ b/data/processors/sections.py @@ -1,6 +1,14 @@ from utils import TranslatableStr as _ +def extract_calendar_urls(data): + """Extracts the calendar from the tumonline data sets it to the proper value.""" + for k, entry in data.items(): + if entry.get("tumonline_data", {}).get("calendar", None): + url = f"https://campus.tum.de/tumonline/{entry['tumonline_data']['calendar']}" + entry["props"]["calendar_url"] = url + + def compute_props(data): """ Create the "computed" value in "props". diff --git a/openapi.yaml b/openapi.yaml index ba3cdb6ac..2af51ba05 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -442,6 +442,7 @@ paths: text: 'Boltzmannstr. 3, EG, 85748 Garching b. München' - name: Sitzplätze text: '522' + calendar_url: 'https://campus.tum.de/tumonline/tvKalender.wSicht?cOrg=19691&cRes=12559&cReadonly=J' ranking_factors: rank_combined: 900 rank_type: 100 @@ -1005,6 +1006,13 @@ components: It is used in the rare cases, where some aspect about the rooom/.. or its translation are misleading. An example of a room with a comment is MW1801. type: string + calendar_url: + items: + type: string + description: A link to the calendar of the room + example: + - 'https://campus.tum.de/tumonline/tvKalender.wSicht?cOrg=19691&cRes=12543&cReadonly=J' + - 'https://campus.tum.de/tumonline/tvKalender.wSicht?cOrg=19691&cRes=12559&cReadonly=J' required: - computed ComputedProp: diff --git a/webclient/src/views/view/i18n-view.yaml b/webclient/src/views/view/i18n-view.yaml index ee3f5941b..00326d0b6 100644 --- a/webclient/src/views/view/i18n-view.yaml +++ b/webclient/src/views/view/i18n-view.yaml @@ -10,6 +10,7 @@ view_view: share: { de: "Teilen", en: "Share" } share_link: { de: "Teilen mit ...", en: "Share with ..." } copied: { de: "Kopiert", en: "Copied" } + calendar: { de: "Kalender öffnen", en: "Open calendar" } feedback: de: "Problem melden oder Änderung vorschlagen" en: "Report issue or suggest changes" diff --git a/webclient/src/views/view/view-view.inc b/webclient/src/views/view/view-view.inc index cacbb096f..4766bdcdc 100644 --- a/webclient/src/views/view/view-view.inc +++ b/webclient/src/views/view/view-view.inc @@ -94,6 +94,29 @@ {{ view_data.type_common_name }}