Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'related_links',
) + ContactFieldsMixin.api_fields
search_fields = Page.search_fields + (
index.SearchField('first_name'),
index.SearchField('last_name'),
index.SearchField('intro'),
index.SearchField('biography'),
)
class PersonPageRelatedLink(Orderable, AbstractRelatedLink):
page = ParentalKey('PersonPage', related_name='related_links')
PersonPage.content_panels = Page.content_panels + [
FieldPanel('first_name'),
FieldPanel('last_name'),
FieldPanel('intro', classname="full"),
FieldPanel('biography', classname="full"),
ImageChooserPanel('image'),
MultiFieldPanel(ContactFieldsMixin.panels, "Contact"),
InlinePanel(PersonPage, 'related_links', label="Related links"),
]
PersonPage.promote_panels = [
MultiFieldPanel(Page.promote_panels, "Common page configuration"),
ImageChooserPanel('feed_image'),
]
# Contact page
class ContactPage(Page, ContactFieldsMixin):
@python_2_unicode_compatible
class Advert(models.Model):
page = models.ForeignKey(
'wagtailcore.Page',
related_name='adverts',
null=True,
blank=True
)
url = models.URLField(null=True, blank=True)
text = models.CharField(max_length=255)
panels = [
PageChooserPanel('page'),
FieldPanel('url'),
FieldPanel('text'),
]
api_fields = ['page', 'url', 'text']
def __str__(self):
return self.text
register_snippet(Advert)
# Home Page
class HomePageCarouselItem(Orderable, CarouselItem):
page = ParentalKey('demo.HomePage', related_name='carousel_items')
message = 'Could not export event\n\nUnrecognised format: ' + request.GET['format']
return HttpResponse(message, content_type='text/plain')
else:
# Display event page as usual
return super(EventPage, self).serve(request)
EventPage.content_panels = [
FieldPanel('title', classname="full title"),
FieldPanel('date_from'),
FieldPanel('date_to'),
FieldPanel('time_from'),
FieldPanel('time_to'),
FieldPanel('location'),
FieldPanel('audience'),
FieldPanel('cost'),
FieldPanel('signup_link'),
InlinePanel(EventPage, 'carousel_items', label="Carousel items"),
FieldPanel('body', classname="full"),
InlinePanel(EventPage, 'speakers', label="Speakers"),
InlinePanel(EventPage, 'related_links', label="Related links"),
]
EventPage.promote_panels = Page.promote_panels + [
ImageChooserPanel('feed_image'),
]
class FormField(AbstractFormField):
page = ParentalKey('FormPage', related_name='form_fields')
class FormPage(AbstractEmailForm):
intro = RichTextField(blank=True)
analytics = models.CharField(max_length=60, default="", blank=True,
help_text="Optional web analytics property code")
contact_form = models.ForeignKey(
'home.ContactForm',
null=True, blank=True,
on_delete=models.SET_NULL,
related_name='+',
)
panels = Page.content_panels + [
FieldPanel('title_fr'),
FieldPanel('address'),
FieldPanel('phone'),
FieldPanel('email'),
FieldPanel('www'),
FieldPanel('map_url'),
FieldPanel('analytics'),
PageChooserPanel('contact_form', 'home.ContactForm'),
]
def phone_link(self):
return 'tel:%s' % self.phone.replace(' ', '')
def email_link(self):
return 'mailto:%s' % self.email
def www_domain(self):
return self.www.replace('http://', '').replace('https://', '')
def is_google_analytics(self):
return self.analytics.startswith('UA-')
def get_piwik_analytics(self):
# When formatted as "server|site_id", assume Piwik
if not '|' in self.analytics: return False
]
edit_handler = TabbedInterface([
ObjectList(general_panels, heading='General'),
ObjectList(content_panels, heading='Content'),
ObjectList(adhocracy_panel, heading='Adhocracy')
])
class FlashpollProjectPage(ProjectPage):
embedurl = models.URLField()
flashpoll_panel = [
FieldPanel('embedurl')
]
general_panels = [
FieldPanel('title', classname='title'),
FieldPanel('slug'),
ImageChooserPanel('image'),
FieldPanel('projecttype'),
FieldPanel('organisation')
]
content_panels = [
MultiFieldPanel(
[
FieldPanel('title_en'),
FieldPanel('teaser_en'),
]
)
)
promote_panels = [
MultiFieldPanel([
FieldPanel('seo_title'),
FieldPanel('slug'),
], "Common page configuration"),
MultiFieldPanel([
ImageChooserPanel('social_image'),
FieldPanel('search_description'),
], "Social networks"),
MultiFieldPanel([
FieldPanel('show_in_menus'),
], "Cross-page behavior"),
]
class Meta:
abstract = True
the next scheduled event date.
:rtype: datetime.date.
"""
date = self.date
if date is None:
date = Event.objects.get_next_occurence(self.event)
return date
BaseEventPage.content_panels = [
FieldPanel('title', classname='full title'),
EventChooserPanel('event'),
MultiFieldPanel([
FieldRowPanel([
FieldPanel('date', classname='col12'),
FieldPanel('start', classname='col6'),
FieldPanel('end', classname='col6'),
], classname='label-above'),
], _(u'Event Details'), classname='publishing'),
]
]
class FormField(AbstractFormField):
page = ParentalKey('FormPage', related_name='form_fields')
class FormPage(AbstractEmailForm):
intro = RichTextField(blank=True)
thank_you_text = RichTextField(blank=True)
FormPage.content_panels = [
FieldPanel('title', classname="full title"),
FieldPanel('intro', classname="full"),
InlinePanel('form_fields', label="Form fields"),
FieldPanel('thank_you_text', classname="full"),
MultiFieldPanel([
FieldPanel('to_address', classname="full"),
FieldPanel('from_address', classname="full"),
FieldPanel('subject', classname="full"),
], "Email")
]
class ArticleIndexPage(Page):
title_fr = models.CharField(max_length=255, default="")
trans_title = TranslatedField(
'title',
'title_fr',
)
intro_de = RichTextField(default='', blank=True)
intro_fr = RichTextField(default='', blank=True)
trans_intro = TranslatedField(
'intro_de',
'intro_fr',
)
content_panels = Page.content_panels + [
FieldPanel('intro_de'),
FieldPanel('title_fr'),
FieldPanel('intro_fr'),
]
def get_context(self, request):
context = super(ArticleIndexPage, self).get_context(request)
articles = ArticlePage.objects.child_of(self).live()
context['articles'] = articles
return context
subpage_types = ['home.ArticlePage', 'home.ArticleIndexPage']
class Meta:
verbose_name = "Rubrik"
class ArticlePage(Page):
title_fr = models.CharField(max_length=255, default="")
)
response['Content-Disposition'] = 'attachment; filename=' + self.slug + '.ics'
return response
else:
# Unrecognised format error
message = 'Could not export event\n\nUnrecognised format: ' + request.GET['format']
return HttpResponse(message, content_type='text/plain')
else:
# Display event page as usual
return super(EventPage, self).serve(request)
EventPage.content_panels = [
FieldPanel('title', classname="full title"),
FieldPanel('date_from'),
FieldPanel('date_to'),
FieldPanel('time_from'),
FieldPanel('time_to'),
FieldPanel('location'),
FieldPanel('audience'),
FieldPanel('cost'),
FieldPanel('signup_link'),
InlinePanel('carousel_items', label="Carousel items"),
FieldPanel('body', classname="full"),
InlinePanel('speakers', label="Speakers"),
InlinePanel('related_links', label="Related links"),
]
EventPage.promote_panels = Page.promote_panels + [
ImageChooserPanel('feed_image'),
]