Skip to content

Commit

Permalink
moved the calendar_url to the props
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Oct 22, 2022
1 parent fc4040a commit 6292a21
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion data/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def main():

logging.info("-- 34 Infer more props")
structure.infer_addresses(data)
structure.extract_calendar_url(data)

# TODO: Does it make sense to introduce a type 'sub_building' here?

Expand All @@ -83,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)

Expand Down
3 changes: 2 additions & 1 deletion data/processors/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,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]

Expand Down
8 changes: 8 additions & 0 deletions data/processors/sections.py
Original file line number Diff line number Diff line change
@@ -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".
Expand Down
8 changes: 0 additions & 8 deletions data/processors/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,3 @@ def _get_type(_id, _data):

for _id, _data in data.items():
_data["type_common_name"] = _get_type(_id, _data)


def extract_calendar_url(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["calendar_url"] = url
16 changes: 8 additions & 8 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +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"
calendar_url: 'https://campus.tum.de/tumonline/tvKalender.wSicht?cOrg=19691&cRes=12559&cReadonly=J'
ranking_factors:
rank_combined: 900
rank_type: 100
Expand Down Expand Up @@ -1007,6 +1007,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:
Expand Down Expand Up @@ -1529,13 +1536,6 @@ components:
type: array
items:
$ref: '#/components/schemas/ImageInfo'
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
ranking_factors:
$ref: '#/components/schemas/RankingFactors'
required:
Expand Down
4 changes: 2 additions & 2 deletions webclient/src/views/view/view-view.inc
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
<div class="column col-auto col-ml-auto">
<a
class="btn btn-link btn-action btn-sm"
v-if="view_data.calendar_url"
v-bind:href="view_data.calendar_url"
v-if="view_data.props?.calendar_url"
v-bind:href="view_data.props.calendar_url"
target="_blank"
title="${{ _.view_view.header.calendar }}$"
>
Expand Down

0 comments on commit 6292a21

Please sign in to comment.