kopia lustrzana https://github.com/wagtail/bakerydemo
Basic template for locations app
rodzic
3533a04154
commit
588e31a083
|
@ -63,11 +63,18 @@ class LocationOperatingHours(Orderable, OperatingHours):
|
|||
|
||||
class LocationsIndexPage(Page):
|
||||
'''
|
||||
Home page for locations
|
||||
Index page for locations
|
||||
'''
|
||||
|
||||
subpage_types = ['LocationPage']
|
||||
|
||||
def get_context(self, request):
|
||||
context = super(LocationsIndexPage, self).get_context(request)
|
||||
context['locations'] = LocationPage.objects.descendant_of(
|
||||
self).live().order_by(
|
||||
'-first_published_at')
|
||||
return context
|
||||
|
||||
|
||||
class LocationPage(Page):
|
||||
'''
|
||||
|
@ -91,13 +98,11 @@ class LocationPage(Page):
|
|||
)
|
||||
|
||||
# Search index configuration
|
||||
|
||||
search_fields = Page.search_fields + [
|
||||
index.SearchField('address'),
|
||||
]
|
||||
|
||||
# Editor panels configuration
|
||||
|
||||
content_panels = Page.content_panels + [
|
||||
FieldPanel('address', classname="full"),
|
||||
FieldPanel('lat_long'),
|
||||
|
@ -108,6 +113,10 @@ class LocationPage(Page):
|
|||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
def opening_hours(self):
|
||||
hours = self.hours_of_operation.all()
|
||||
return hours
|
||||
|
||||
parent_page_types = [
|
||||
'LocationsIndexPage'
|
||||
]
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
{% extends "base.html" %}
|
||||
{% load wagtailimages_tags %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{{ page.title }}</h1>
|
||||
<figure>
|
||||
{% image self.image fill-600x600 %}
|
||||
</figure>
|
||||
<p>{{ page.address }}</p>
|
||||
<p>{{ page.lat_long }}</p>
|
||||
|
||||
{% for hours in page.opening_hours %}
|
||||
<li>{{ hours }}</li>
|
||||
{% endfor %}
|
||||
{% endblock content %}
|
|
@ -0,0 +1,10 @@
|
|||
{% extends "base.html" %}
|
||||
{% load wagtailimages_tags %}
|
||||
|
||||
{% block content %}
|
||||
{{ page.title }}
|
||||
|
||||
{% for location in locations %}
|
||||
<div><a href="{{ location.slug }}">{{ location.title }}</a></div>
|
||||
{% endfor %}
|
||||
{% endblock content %}
|
Ładowanie…
Reference in New Issue