|
@@ -11,9 +11,6 @@ from wagtail.wagtailadmin.edit_handlers import (
|
|
InlinePanel,
|
|
InlinePanel,
|
|
StreamFieldPanel)
|
|
StreamFieldPanel)
|
|
from wagtail.wagtailcore.models import Orderable, Page
|
|
from wagtail.wagtailcore.models import Orderable, Page
|
|
-from wagtail.wagtailimages.edit_handlers import (
|
|
|
|
- ImageChooserPanel,
|
|
|
|
- )
|
|
|
|
from wagtail.wagtailcore.fields import StreamField
|
|
from wagtail.wagtailcore.fields import StreamField
|
|
from wagtail.wagtailsearch import index
|
|
from wagtail.wagtailsearch import index
|
|
|
|
|
|
@@ -58,7 +55,7 @@ class OperatingHours(models.Model):
|
|
"Closed?",
|
|
"Closed?",
|
|
blank=True,
|
|
blank=True,
|
|
help_text='Tick if location is closed on this day'
|
|
help_text='Tick if location is closed on this day'
|
|
- )
|
|
|
|
|
|
+ )
|
|
|
|
|
|
panels = [
|
|
panels = [
|
|
FieldPanel('day'),
|
|
FieldPanel('day'),
|
|
@@ -71,10 +68,18 @@ class OperatingHours(models.Model):
|
|
abstract = True
|
|
abstract = True
|
|
|
|
|
|
def __str__(self):
|
|
def __str__(self):
|
|
|
|
+ if self.opening_time:
|
|
|
|
+ opening = self.opening_time.strftime('%H:%M')
|
|
|
|
+ else:
|
|
|
|
+ opening = '--'
|
|
|
|
+ if self.closing_time:
|
|
|
|
+ closed = self.opening_time.strftime('%H:%M')
|
|
|
|
+ else:
|
|
|
|
+ closed = '--'
|
|
return '{}: {} - {} {}'.format(
|
|
return '{}: {} - {} {}'.format(
|
|
self.day,
|
|
self.day,
|
|
- self.opening_time.strftime('%H:%M'),
|
|
|
|
- self.closing_time.strftime('%H:%M'),
|
|
|
|
|
|
+ opening,
|
|
|
|
+ closed,
|
|
settings.TIME_ZONE
|
|
settings.TIME_ZONE
|
|
)
|
|
)
|
|
|
|
|
|
@@ -103,21 +108,11 @@ class LocationsIndexPage(BasePageFieldsMixin, Page):
|
|
return context
|
|
return context
|
|
|
|
|
|
|
|
|
|
-class LocationPage(Page):
|
|
|
|
|
|
+class LocationPage(BasePageFieldsMixin, Page):
|
|
"""
|
|
"""
|
|
Detail for a specific bakery location.
|
|
Detail for a specific bakery location.
|
|
"""
|
|
"""
|
|
- introduction = models.TextField(
|
|
|
|
- help_text='Text to describe the index page',
|
|
|
|
- blank=True)
|
|
|
|
address = models.TextField()
|
|
address = models.TextField()
|
|
- image = models.ForeignKey(
|
|
|
|
- 'wagtailimages.Image',
|
|
|
|
- null=True,
|
|
|
|
- blank=True,
|
|
|
|
- on_delete=models.SET_NULL,
|
|
|
|
- related_name='+'
|
|
|
|
- )
|
|
|
|
lat_long = models.CharField(
|
|
lat_long = models.CharField(
|
|
max_length=36,
|
|
max_length=36,
|
|
help_text="Comma separated lat/long. (Ex. 64.144367, -21.939182) \
|
|
help_text="Comma separated lat/long. (Ex. 64.144367, -21.939182) \
|
|
@@ -144,12 +139,10 @@ class LocationPage(Page):
|
|
]
|
|
]
|
|
|
|
|
|
# Editor panels configuration
|
|
# Editor panels configuration
|
|
- content_panels = Page.content_panels + [
|
|
|
|
- FieldPanel('introduction', classname="full"),
|
|
|
|
|
|
+ content_panels = BasePageFieldsMixin.content_panels + [
|
|
StreamFieldPanel('body'),
|
|
StreamFieldPanel('body'),
|
|
FieldPanel('address', classname="full"),
|
|
FieldPanel('address', classname="full"),
|
|
FieldPanel('lat_long'),
|
|
FieldPanel('lat_long'),
|
|
- ImageChooserPanel('image'),
|
|
|
|
InlinePanel('hours_of_operation', label="Hours of Operation"),
|
|
InlinePanel('hours_of_operation', label="Hours of Operation"),
|
|
]
|
|
]
|
|
|
|
|