Skip to content

Commit

Permalink
Merge branch 'master' of github.com:thomersch/openstreetmap-calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
thomersch committed Mar 28, 2024
2 parents 7aefc57 + 8667390 commit 6f8e317
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 38 deletions.
3 changes: 3 additions & 0 deletions osmcal/templates/osmcal/event_join.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{% extends "base.html" %}

{% block content %}
<div class="content-main-fullwidth">

<h1 class="event-single-title">Join <a href="{% url 'event' event.id %}">{{ event.name }}</a></h1>
On {% include "osmcal/date.txt" %}

<form action="{% url 'event-join' event.id %}" method="POST" class="event-single-join">
{% csrf_token %}
<button class="btn">Attend {{ event.name }}</button>
</form>
</div>
{% endblock %}
44 changes: 40 additions & 4 deletions osmcal/templatetags/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,54 @@ def schema_block(evt):
}
if evt.end:
data["endDate"] = evt.end_localized.isoformat()
if evt.description:
data["description"] = evt.description

if evt.cancelled:
data["eventStatus"] = "https://schema.org/EventCancelled"
else:
data["eventStatus"] = "https://schema.org/EventScheduled"

if evt.location:
addr = None
if evt.location_address:
addr = {
"@type": "PostalAddress",
"addressLocality": ", ".join(
filter(
lambda x: x is not None,
[
evt.location_address.get("village"),
evt.location_address.get("town"),
evt.location_address.get("city"),
],
)
),
}
if "country_code" in evt.location_address:
addr["addressCountry"] = evt.location_address.get("country_code").upper()
if "state" in evt.location_address:
addr["addressRegion"] = evt.location_address.get("state")
if "postcode" in evt.location_address:
addr["postalCode"] = evt.location_address.get("postcode")
if "road" in evt.location_address:
addr["streetAddress"] = ", ".join(
filter(
lambda x: x is not None,
[evt.location_address.get("house_number"), evt.location_address.get("road")],
)
)

if addr or evt.location or evt.location_name:
data["location"] = {
"latitude": evt.location.y,
"longitude": evt.location.x,
"address": evt.location_detailed_addr,
"@type": "Place",
}
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

if evt.link:
data["url"] = evt.link
Expand Down
63 changes: 30 additions & 33 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ django-background-tasks = "*"
[tool.poetry.group.dev.dependencies]
PyYaml = "~=6.0"
pylint = "*"
black = "~=23.3.0"
black = "~=24.3.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down

0 comments on commit 6f8e317

Please sign in to comment.