Skip to content

Commit

Permalink
Deal with more parts of the event location not being populated
Browse files Browse the repository at this point in the history
Fixes #159.
  • Loading branch information
vkrause committed Mar 14, 2024
1 parent 4458ca6 commit 1272af9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions osmcal/templatetags/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def schema_block(evt):
else:
data["eventStatus"] = "https://schema.org/EventScheduled"

if evt.location:
addr = None
if evt.location_address:
addr = {
"@type": "PostalAddress",
"addressLocality": ", ".join(
Expand Down Expand Up @@ -55,12 +56,15 @@ def schema_block(evt):
)
)

if addr or evt.location or evt.location_name:
data["location"] = {
"@type": "Place",
"latitude": evt.location.y,
"longitude": evt.location.x,
"address": addr,
}
if evt.location:
data["location"]["latitude"] = evt.location.y
data["location"]["longitude"] = evt.location.x
if addr:
data["location"]["address"] = addr
if evt.location_name:
data["location"]["name"] = evt.location_name

Expand Down

0 comments on commit 1272af9

Please sign in to comment.