diff --git a/bakerydemo/locations/models.py b/bakerydemo/locations/models.py index 8d5b8d931..fcecaaf6d 100644 --- a/bakerydemo/locations/models.py +++ b/bakerydemo/locations/models.py @@ -199,13 +199,24 @@ def is_open(self): return False # Makes additional context available to the template so that we can access - # the latitude, longitude and map API key to render the map + # the latitude and longitude to render the OpenStreetMap embed def get_context(self, request): context = super(LocationPage, self).get_context(request) context["lat"] = self.lat_long.split(",")[0] context["long"] = self.lat_long.split(",")[1] - context["google_map_api_key"] = settings.GOOGLE_MAP_API_KEY return context # Can only be placed under a LocationsIndexPage object parent_page_types = ["LocationsIndexPage"] + + @property + def lat(self): + if self.lat_long: + return self.lat_long.split(",")[0].strip() + return None + + @property + def long(self): + if self.lat_long: + return self.lat_long.split(",")[1].strip() + return None diff --git a/bakerydemo/static/css/main.css b/bakerydemo/static/css/main.css index 0f5fece64..dcfcb90ee 100644 --- a/bakerydemo/static/css/main.css +++ b/bakerydemo/static/css/main.css @@ -34,10 +34,9 @@ each detail view --dark-orange: #833701; --font--primary: 'Marcellus', serif; /* stylelint-disable */ - --font--secondary: - -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, Roboto, - 'Helvetica Neue', Arial, sans-serif, Apple Color Emoji, 'Segoe UI Emoji', - 'Segoe UI Symbol', 'Noto Color Emoji'; + --font--secondary: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, + Roboto, 'Helvetica Neue', Arial, sans-serif, Apple Color Emoji, + 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; /* stylelint-enable */ --font-sm: 1rem; --font-md: 1.125rem; @@ -933,6 +932,18 @@ footer { } } +/* Location index map */ +.location-index-map { + margin-bottom: 40px; +} + +.location-index-map__note { + font-size: var(--font-sm); + color: var(--dark); + margin-top: 10px; + font-style: italic; +} + /* Location detail page */ .location__meta-title { font-family: var(--font--primary); @@ -955,6 +966,21 @@ footer { display: block; } +.location-map { + margin-top: 10px; +} + +.location-map__link { + display: inline-block; + margin-top: 8px; + font-size: var(--font-sm); + color: var(--orange); +} + +.location-map__link:hover { + color: var(--dark-orange); +} + /* ---- Blog Index Page ---- */ .blog-tags { list-style: none; diff --git a/bakerydemo/templates/blog/blog_index_page.html b/bakerydemo/templates/blog/blog_index_page.html index d60ae8507..05ad1fca0 100644 --- a/bakerydemo/templates/blog/blog_index_page.html +++ b/bakerydemo/templates/blog/blog_index_page.html @@ -27,12 +27,14 @@

Blog

{% endif %} {% if page.get_child_tags %} - + {% endif %}
diff --git a/bakerydemo/templates/locations/location_page.html b/bakerydemo/templates/locations/location_page.html index e6aa27bb4..a05d833d4 100644 --- a/bakerydemo/templates/locations/location_page.html +++ b/bakerydemo/templates/locations/location_page.html @@ -46,6 +46,23 @@

Operating Status

Address

{{ page.address|linebreaks }}
+ {% if page.lat_long %} +

Map

+
+ + View on OpenStreetMap +
+ {% endif %} + {% if page.operating_hours %}

Opening hours

{% for hours in page.operating_hours %} diff --git a/bakerydemo/templates/locations/locations_index_page.html b/bakerydemo/templates/locations/locations_index_page.html index 57134dc43..6827fdfe0 100644 --- a/bakerydemo/templates/locations/locations_index_page.html +++ b/bakerydemo/templates/locations/locations_index_page.html @@ -6,6 +6,26 @@ {% include "base/include/header-index.html" %}
+ {% if locations %} + {% with locations.0 as first_location %} + {% if first_location.lat_long %} +
+ +

View all locations on the map by visiting each location page.

+
+ {% endif %} + {% endwith %} + {% endif %} +
{% for location in locations %} {% include "includes/card/picture-card.html" with page=location portrait=False %}