Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
content_panels = CoderedWebPage.content_panels + [
FieldPanel('caption'),
MultiFieldPanel(
[
FieldPanel('author'),
FieldPanel('author_display'),
FieldPanel('date_display'),
],
_('Publication Info')
)
]
class CoderedArticleIndexPage(CoderedWebPage):
"""
Shows a list of article sub-pages.
"""
class Meta:
verbose_name = _('CodeRed Article Index Page')
abstract = True
template = 'coderedcms/pages/article_index_page.html'
index_show_subpages_default = True
index_order_by_default = '-date_display'
index_order_by_choices = (('-date_display', 'Display publish date, newest first'),) + \
CoderedWebPage.index_order_by_choices
show_images = models.BooleanField(
self.longitude = g.latlng[1]
except TypeError:
# Raised if google denied the request
pass
return super(CoderedLocationPage, self).save(*args, **kwargs)
def get_context(self, request, *args, **kwargs):
context = super().get_context(request)
context['google_api_key'] = GoogleApiSettings.for_site(
Site.objects.get(is_default_site=True)
).google_maps_api_key
return context
class CoderedLocationIndexPage(CoderedWebPage):
"""
Shows a map view of the children CoderedLocationPage.
"""
class Meta:
verbose_name = _('CodeRed Location Index Page')
abstract = True
template = 'coderedcms/pages/location_index_page.html'
index_show_subpages_default = True
center_latitude = models.FloatField(
null=True,
blank=True,
help_text=_('The default latitude you want the map set to.'),
default=0
def process_form_get(self, form, request):
return CoderedWebPage.serve(self, request)
preview = body[:200] + "..." if len(body) > 200 else body
return mark_safe(preview)
@property
def page_ptr(self):
"""
Overwrite of `page_ptr` to make it compatible with wagtailimportexport.
"""
return self.base_page_ptr
@page_ptr.setter
def page_ptr(self, value):
self.base_page_ptr = value
class CoderedArticlePage(CoderedWebPage):
"""
Article, suitable for news or blog content.
"""
class Meta:
verbose_name = _('CodeRed Article')
abstract = True
template = 'coderedcms/pages/article_page.html'
amp_template = 'coderedcms/pages/article_page.amp.html'
# Override body to provide simpler content
body = StreamField(CONTENT_STREAMBLOCKS, null=True, blank=True)
caption = models.CharField(
max_length=255,
blank=True,
return self.caption
if self.body_preview:
return self.body_preview
return ''
search_fields = (
CoderedWebPage.search_fields +
[
index.SearchField('caption', boost=2),
index.FilterField('author'),
index.FilterField('author_display'),
index.FilterField('date_display'),
]
)
content_panels = CoderedWebPage.content_panels + [
FieldPanel('caption'),
MultiFieldPanel(
[
FieldPanel('author'),
FieldPanel('author_display'),
FieldPanel('date_display'),
],
_('Publication Info')
)
]
class CoderedArticleIndexPage(CoderedWebPage):
"""
Shows a list of article sub-pages.
"""
"""
class Meta:
verbose_name = _('CodeRed Form Page')
abstract = True
template = 'coderedcms/pages/form_page.html'
landing_page_template = 'coderedcms/pages/form_page_landing.html'
base_form_class = WagtailAdminFormPageForm
form_builder = CoderedFormBuilder
body_content_panels = [
InlinePanel('form_fields', label="Form fields"),
] + \
CoderedWebPage.body_content_panels + \
CoderedFormMixin.body_content_panels + [
FormSubmissionsPanel(),
InlinePanel('confirmation_emails', label=_('Confirmation Emails'))
]
settings_panels = CoderedPage.settings_panels + CoderedFormMixin.settings_panels
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if not hasattr(self, 'landing_page_template'):
name, ext = os.path.splitext(self.template)
self.landing_page_template = name + '_landing' + ext
def get_form_fields(self):
"""
Form page expects `form_fields` to be declared.
class CoderedArticleIndexPage(CoderedWebPage):
"""
Shows a list of article sub-pages.
"""
class Meta:
verbose_name = _('CodeRed Article Index Page')
abstract = True
template = 'coderedcms/pages/article_index_page.html'
index_show_subpages_default = True
index_order_by_default = '-date_display'
index_order_by_choices = (('-date_display', 'Display publish date, newest first'),) + \
CoderedWebPage.index_order_by_choices
show_images = models.BooleanField(
default=True,
verbose_name=_('Show images'),
)
show_captions = models.BooleanField(
default=True,
)
show_meta = models.BooleanField(
default=True,
verbose_name=_('Show author and date info'),
)
show_preview_text = models.BooleanField(
default=True,
verbose_name=_('Show preview text'),
)
)
layout_panels = CoderedWebPage.layout_panels + [
MultiFieldPanel(
[
FieldPanel('show_images'),
FieldPanel('show_captions'),
FieldPanel('show_meta'),
FieldPanel('show_preview_text'),
],
heading=_('Child page display')
),
]
class CoderedEventPage(CoderedWebPage, BaseEvent):
class Meta:
verbose_name = _('CodeRed Event')
abstract = True
calendar_color = ColorField(
blank=True,
help_text=_('The color that the event will use when displayed on a calendar.'),
)
address = models.TextField(
blank=True,
verbose_name=_("Address")
)
content_panels = CoderedWebPage.content_panels + [
MultiFieldPanel(
[
FieldPanel('calendar_color'),
center_longitude = models.FloatField(
null=True,
blank=True,
help_text=_('The default longitude you want the map set to.'),
default=0
)
zoom = models.IntegerField(
default=8,
validators=[
MaxValueValidator(20),
MinValueValidator(1),
],
help_text=_("Requires API key to use zoom. 1: World, 5: Landmass/continent, 10: City, 15: Streets, 20: Buildings") # noqa
)
layout_panels = CoderedWebPage.layout_panels + [
MultiFieldPanel(
[
FieldPanel('center_latitude'),
FieldPanel('center_longitude'),
FieldPanel('zoom'),
],
heading=_('Map Display')
),
]
def geojson_data(self, viewport=None):
"""
function that will return all locations under this index as geoJSON compliant data.
It is filtered by a latitude/longitude viewport if given.
viewport is a string in the format of :