Exemplo n.º 1
0
class BeerAvailability(AbstractBaseModel):
    beer = models.ForeignKey('Beer',
                             on_delete=models.CASCADE,
                             related_name='availabilities_type',
                             verbose_name='Beer')
    container = models.ForeignKey('BeerContainer',
                                  on_delete=models.CASCADE,
                                  related_name='beers_available',
                                  verbose_name='Container')

    panels = [
        FieldRowPanel([
            FieldPanel('beer', classname='col6'),
            FieldPanel('container', classname='col6')
        ]),
    ] + AbstractBaseModel.panels

    def __str__(self):
        return 'Beer %s available in %s' % (self.beer.name,
                                            self.container.name)

    def admin_list(self):
        return 'Available in %s - Volume %d cl.' % (self.container.name,
                                                    self.container.volume)

    class Meta:
        verbose_name = 'Beer Availability'
        verbose_name_plural = 'Beer Availabilities'
        unique_together = ('beer', 'container')
        app_label = 'beer'
Exemplo n.º 2
0
class BaseSnippet(index.Indexed, ClusterableModel):
    description = models.CharField(unique=True,
                                   max_length=255,
                                   verbose_name='Logical description')
    identifier = models.CharField(
        max_length=255,
        unique=True,
        verbose_name='Unique identifier to use in template')

    panels = [
        MultiFieldPanel([
            FieldRowPanel([
                FieldPanel('description', classname='col6'),
                FieldPanel('identifier', classname='col6'),
            ]),
        ],
                        heading='Displaying properties',
                        classname='collapsible'),
        InlinePanel('link_lists', label="Links")
    ]

    search_fields = [
        index.SearchField('description', partial_match=True),
        index.SearchField('identifier', partial_match=True)
    ]

    def __str__(self):
        return self.description
Exemplo n.º 3
0
class BeerContainer(AbstractBaseModel):
    name = models.CharField(max_length=255, verbose_name='Container name')
    volume = models.IntegerField(default=0, verbose_name='Volume in cl')
    svg_icon = models.ForeignKey('wagtaildocs.Document',
                                 null=True,
                                 blank=True,
                                 on_delete=models.SET_NULL,
                                 related_name='+')

    panels = [
        FieldRowPanel([
            FieldPanel('name', classname='col4'),
            FieldPanel('volume', classname='col4'),
            DocumentChooserPanel('svg_icon', classname='col4'),
        ]),
    ] + AbstractBaseModel.panels

    class Meta:
        ordering = [
            'sort_order',
            'name',
        ]
        verbose_name = 'Beer Container'
        verbose_name_plural = 'Beer Containers'
        app_label = 'beer'

    def __str__(self):
        return self.name

    def get_svg_icon_content(self):
        return get_svg_content(self.svg_icon)
Exemplo n.º 4
0
class ContactPage(AbstractEmailForm):

    template = "contact/contact_page.html"
    subpage_types = []
    parent_page_types = ['home.HomePage']
    contact_image = models.ForeignKey(
        "wagtailimages.Image",
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name="+",
    )

    # This is the default path.
    # If ignored, Wagtail adds _landing.html to your template name
    landing_page_template = "contact/contact_page_landing.html"

    intro = RichTextField(blank=True)
    thank_you_text = RichTextField(blank=True)

    content_panels = AbstractEmailForm.content_panels + [
        ImageChooserPanel("contact_image"),
        FieldPanel('intro'),
        InlinePanel('form_fields', label='Form Fields'),
        FieldPanel('thank_you_text'),
        
        MultiFieldPanel([
            FieldRowPanel([
                FieldPanel('from_address', classname="col6"),
                FieldPanel('to_address', classname="col6"),
            ]),
            FieldPanel("subject"),
        ], heading="Email Settings"),
    ]
Exemplo n.º 5
0
class SocialSettings(BaseSetting):
    fb_share = models.BooleanField('Facebook Share', default=True)
    twitter_share = models.BooleanField('Twitter Share', default=True)
    # google_share = models.BooleanField('Google Share', default=True)
    linkedin_share = models.BooleanField('LinkedIn Share', default=True)
    reddit_share = models.BooleanField('Reddit Share', default=True)
    email_share = models.BooleanField('Email Share', default=True)
    printit = models.BooleanField('Print It', default=True)
    pintrest_share = models.BooleanField('Pintrest Share(Images)', default=True)
    
    content_panels = Page.content_panels + [
        FieldRowPanel([
            FieldPanel('fb_share'),
            FieldPanel('twitter_share'),
            # FieldPanel('google_share'),
            FieldPanel('linkedin_share'),
            FieldPanel('reddit_share'),
            FieldPanel('email_share'),
            FieldPanel('printit'),
            FieldPanel('pintrest_share'),
        ])
    ]
    
    class Meta:
        verbose_name = 'Social Media Share Buttons'
Exemplo n.º 6
0
class FormPage(AbstractEmailForm):
    image = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )
    
    body = StreamField(BaseStreamBlock())
    thank_you_text = RichTextField(blank=True)

    # Note how we include the FormField object via an InlinePanel using the
    # related_name value
    content_panels = AbstractEmailForm.content_panels + [
        ImageChooserPanel('image'),
        StreamFieldPanel('body'),
        InlinePanel('form_fields', label="Form fields"),
        FieldPanel('thank_you_text', classname="full"),
        MultiFieldPanel([
            FieldRowPanel([
                FieldPanel('from_address', classname="col6"),
                FieldPanel('to_address', classname="col6"),
            ]),
            FieldPanel('subject'),
        ], "Email"),
    ]
Exemplo n.º 7
0
class TestimonialFormPage(AbstractEmailForm):
    template = 'testimonials/testimonials_page.html'

    intro = RichTextField(blank=True)
    testimonial_form_page_bg = models.ForeignKey("wagtailimages.Image",
                                                 null=True,
                                                 blank=False,
                                                 on_delete=models.SET_NULL,
                                                 related_name="+")
    thank_you_text = RichTextField(blank=True)
    testimonial_thank_you_page_background = models.ForeignKey(
        "wagtailimages.Image",
        null=True,
        blank=False,
        on_delete=models.SET_NULL,
        related_name="+")

    content_panels = AbstractEmailForm.content_panels + [
        FieldPanel('intro'),
        ImageChooserPanel('testimonial_form_page_bg'),
        InlinePanel('form_fields', label='Testimonial Form Fields'),
        FieldPanel('thank_you_text'),
        ImageChooserPanel('testimonial_thank_you_page_background'),
        MultiFieldPanel([
            FieldRowPanel([
                FieldPanel('from_address', classname="col6"),
                FieldPanel('to_address', classname="col6"),
            ]),
            FieldPanel("subject")
        ],
                        heading="Email Settings"),
    ]
Exemplo n.º 8
0
class TimeRule(AbstractBaseRule):
    """Time rule to segment users based on a start and end time.

    Matches when the time a request is made falls between the
    set start time and end time.

    """
    icon = 'fa-clock-o'

    start_time = models.TimeField(_("Starting time"))
    end_time = models.TimeField(_("Ending time"))

    panels = [
        FieldRowPanel([
            FieldPanel('start_time'),
            FieldPanel('end_time'),
        ]),
    ]

    class Meta:
        verbose_name = _('Time Rule')

    def test_user(self, request=None):
        return self.start_time <= timezone.now().time() <= self.end_time

    def description(self):
        return {
            'title':
            _('These users visit between'),
            'value':
            _('{} and {}').format(self.start_time.strftime("%H:%M"),
                                  self.end_time.strftime("%H:%M")),
        }
Exemplo n.º 9
0
class FormPage(AbstractEmailForm):
    image = models.ForeignKey('wagtailimages.Image',
                              null=True,
                              blank=True,
                              on_delete=models.SET_NULL,
                              related_name='+')
    body = StreamField(BaseStreamBlock())
    thank_you_text = RichTextField(blank=True)

    # Note how we include the FormField object via an InlinePanel using the
    # related_name value
    content_panels = AbstractEmailForm.content_panels + [
        ImageChooserPanel('image'),
        StreamFieldPanel('body'),
        InlinePanel('form_fields', label="Form fields"),
        FieldPanel('thank_you_text', classname="full"),
        MultiFieldPanel([
            FieldRowPanel([
                FieldPanel('from_address', classname="col6"),
                FieldPanel('to_address', classname="col6"),
            ]),
            FieldPanel('subject'),
        ], "Email"),
    ]

    def send_mail(self, form):
        addresses = [x.strip() for x in self.to_address.split(',')]
        content = []
        for field in form:
            value = field.value()
            if isinstance(value, list):
                value = ', '.join(value)
            content.append('{}: {}'.format(field.label, value))
        content = '\n'.join(content)
        send_mail(self.subject, content, addresses, self.from_address)
Exemplo n.º 10
0
class ContactPage(WagtailCaptchaEmailForm):

    template = "contact/contact_page.html"
    # This is the default path.
    # If ignored, Wagtail adds _landing.html to your template name
    landing_page_template = "contact/contact_page_landing.html"

    intro = RichTextField(blank=True)
    thank_you_text = RichTextField(blank=True)

    content_panels = AbstractEmailForm.content_panels + [
        FieldPanel('intro'),
        InlinePanel('custom_form_fields', label='Form Fields'),
        FieldPanel('thank_you_text', classname="full"),
        MultiFieldPanel([
            FieldRowPanel([
                FieldPanel('from_address', classname="col6"),
                FieldPanel('to_address', classname="col6"),
            ]),
            FieldPanel("subject"),
        ], "Email Notification Config"),
    ]

    def get_form_fields(self):
        return self.custom_form_fields.all()
Exemplo n.º 11
0
class InstrumentContainerPage(AbstractContainerPage):
    # Annoyingly, the template from the abstract class gets overridden
    # by wagtails Page mechanism.
    template = AbstractContainerPage.template

    parent_page_types = ['website.StartPage']
    subpage_types = ['instruments.InstrumentPage']

    is_creatable = False

    content_panels = [
        MultiFieldPanel([
            FieldRowPanel([
                FieldPanel('title'),
                FieldPanel('title_de'),
                FieldPanel('slug'),
            ], ),
        ],
                        heading=_('title')),
        StreamFieldPanel('introduction_en'),
        StreamFieldPanel('introduction_de'),
    ]

    class Meta:
        verbose_name = _('list of instruments')
Exemplo n.º 12
0
class FormPage(AbstractEmailForm):
    thank_you_text = RichTextField(blank=True)

    content_panels = AbstractEmailForm.content_panels + [
        InlinePanel('custom_form_fields', label="Form fields"),
        FieldPanel('thank_you_text', classname="full"),
        MultiFieldPanel([
            FieldRowPanel([
                FieldPanel('from_address', classname="col6"),
                FieldPanel('to_address', classname="col6"),
            ]),
            FieldPanel('subject'),
        ], "Email Notification Config"),
    ]

    def get_context(self, request, *args, **kwargs):
        context = super(FormPage, self).get_context(request, *args, **kwargs)
        context['blog_page'] = self.blog_page
        return context

    def get_form_fields(self):
        return self.custom_form_fields.all()

    @property
    def blog_page(self):
        return self.get_parent().specific
Exemplo n.º 13
0
class FormPage(AbstractEmailForm):
    template = "contact/form_page.html"
    intro = RichTextField(blank=True)
    thank_you_text = RichTextField(blank=True)

    hero_image = models.ForeignKey('wagtailimages.Image',
                                   null=True,
                                   blank=True,
                                   on_delete=models.SET_NULL,
                                   related_name='+')

    def get_context(self, request):
        homepage = HomePage.objects.parent_of(self).live().first()
        context = super().get_context(request)
        context['home'] = homepage
        return context

    content_panels = AbstractEmailForm.content_panels + [
        ImageChooserPanel('hero_image'),
        FieldPanel('intro', classname="full"),
        InlinePanel('form_fields', label="Form fields"),
        FieldPanel('thank_you_text', classname="full"),
        MultiFieldPanel([
            FieldRowPanel([
                FieldPanel('from_address', classname="col6"),
                FieldPanel('to_address', classname="col6"),
            ]),
            FieldPanel('subject'),
        ], "Email"),
    ]
Exemplo n.º 14
0
class Benefit(Content):
    start = models.DateField("Fecha de inicio", null=True, blank=True)
    end = models.DateField("Fecha de término", null=True, blank=True)

    class Meta:
        verbose_name = "Beneficio"
        verbose_name_plural = "Beneficios"
        ordering = ('-publish_at', )

    search_fields = Content.search_fields + []

    panels = Content.panels + [
        MultiFieldPanel([
            FieldRowPanel([
                FieldPanel('start', classname="col6"),
                FieldPanel('end', classname="col6"),
            ])
        ],
                        heading="Fecha del beneficio"),
    ] + Content.end_panels

    edit_handler = WithRequestObjectList(panels)

    api_fields = Content.api_fields + [APIField('start'), APIField('end')]

    def __str__(self):
        date = format_date(self.start, 'dd/MMM/YYYY', locale='es')
        return '%s. %s - %s' % (date, self.title, self.get_published_label())
Exemplo n.º 15
0
class FormPage(AbstractEmailForm):
    image = models.ForeignKey('wagtailimages.Image',
                              null=True,
                              blank=True,
                              on_delete=models.SET_NULL,
                              related_name='+')
    body = StreamField(BaseStreamBlock())
    thank_you_text = RichTextField(blank=True)

    # Note how we include the FormField object via an InlinePanel using the
    # related_name value
    content_panels = AbstractEmailForm.content_panels + [
        ImageChooserPanel('image'),
        StreamFieldPanel('body'),
        InlinePanel('form_fields', label="Form fields"),
        FieldPanel('thank_you_text', classname="full"),
        MultiFieldPanel([
            FieldRowPanel([
                FieldPanel('from_address', classname="col6"),
                FieldPanel('to_address', classname="col6"),
            ]),
            FieldPanel('subject'),
        ], "Email"),
    ]

    def get_form(self, *args, **kwargs):
        form = super().get_form(*args, **kwargs)
        for name, field in form.fields.items():
            if isinstance(field.widget, widgets.Textarea):
                field.widget.attrs.update({'cols': '5'})
            css_classes = field.widget.attrs.get('class', '').split()
            css_classes.append('form-control')
            field.widget.attrs.update({'class': ' '.join(css_classes)})
        return form
Exemplo n.º 16
0
class ContactPage(WagtailCaptchaEmailForm):

    template = "contact/contact_page.html"
    # This is the default path.
    # If ignored, Wagtail adds _landing.html to your template name
    landing_page_template = "contact/contact_page_landing.html"
    subpage_types = []
    parent_page_types = ['home.HomePage']

    intro = RichTextField(blank=True)
    thank_you_text = RichTextField(blank=True)

    content_panels = AbstractEmailForm.content_panels + [
        FieldPanel('intro'),
        InlinePanel('form_fields', label='Form Fields'),
        FieldPanel('thank_you_text'),
        MultiFieldPanel([
            FieldRowPanel([
                FieldPanel('from_address', classname="col6"),
                FieldPanel('to_address', classname="col6"),
            ]),
            FieldPanel("subject"),
        ],
                        heading="Email Settings"),
    ]
Exemplo n.º 17
0
class EventDate(Orderable):
    event_page = ParentalKey(EventPage,
                             on_delete=models.CASCADE,
                             related_name="dates")
    start = models.DateTimeField()
    end = models.DateTimeField(null=True, blank=True)
    label = models.CharField(
        blank=True,
        max_length=255,
        help_text=_('Optional label like "Part I" or "Meeting point"'),
    )

    panels = [
        FieldRowPanel([FieldPanel("start"),
                       FieldPanel("end")]),
        FieldPanel("label"),
    ]

    class Meta:
        verbose_name = _("Date")
        verbose_name_plural = _("Dates")

    def __str__(self):
        start = formats.date_format(self.start, "SHORT_DATETIME_FORMAT")
        if not self.label:
            return start
        return "%s | %s" % (start, self.label)
Exemplo n.º 18
0
class FormPage(AbstractEmailForm):
    intro = models.CharField(max_length=250, blank=True)
    body = RichTextField(blank=True)
    thank_you_text = RichTextField(blank=True)

    masthead = models.ForeignKey('wagtailimages.Image',
                                 null=True,
                                 blank=True,
                                 on_delete=models.SET_NULL,
                                 related_name='+')

    content_panels = AbstractEmailForm.content_panels + [
        FormSubmissionsPanel(),
        FieldPanel('intro'),
        FieldPanel('body', classname="full"),
        ImageChooserPanel('masthead'),
        InlinePanel('form_fields', label="Form fields"),
        FieldPanel('thank_you_text', classname="full"),
        MultiFieldPanel([
            FieldRowPanel([
                FieldPanel('from_address', classname="col6"),
                FieldPanel('to_address', classname="col6"),
            ]),
            FieldPanel('subject'),
        ], "Email"),
    ]
Exemplo n.º 19
0
class BlogPage(BodyMixin, BaseFieldsMixin, MetadataPageMixin, Page):
    parent_page_types = [
        'RootPage',
    ]

    tags = ClusterTaggableManager(through='PageTag', blank=True)
    date = models.DateTimeField(_('Date'), default=timezone.now)

    content_panels = Page.content_panels + [
        FieldRowPanel([
            MultiFieldPanel([
                StreamFieldPanel('body'),
            ], classname='col8'),
            MultiFieldPanel([
                FieldPanel('subtitle'),
                ImageChooserPanel('image'),
                FieldPanel('tags'),
                FieldPanel('date'),
            ],
                            classname='col4'),
        ]),
    ]

    search_fields = Page.search_fields + BodyMixin.search_fields

    class Meta:
        ordering = ['-date']
Exemplo n.º 20
0
class FormPage(WagtailCaptchaEmailForm, BasePage):
    template = 'patterns/pages/forms/form_page.html'
    landing_page_template = 'patterns/pages/forms/form_page_landing.html'

    subpage_types = []

    introduction = models.TextField(blank=True)
    thank_you_text = RichTextField(
        blank=True,
        help_text=
        "Text displayed to the user on successful submission of the form")
    action_text = models.CharField(
        max_length=32,
        blank=True,
        help_text="Form action text. Defaults to \"Submit\"")

    search_fields = BasePage.search_fields + [
        index.SearchField('introduction'),
    ]

    content_panels = BasePage.content_panels + [
        FieldPanel('introduction'),
        InlinePanel('form_fields', label="Form fields"),
        FieldPanel('action_text'),
        FieldPanel('thank_you_text'),
        MultiFieldPanel([
            FieldRowPanel([
                FieldPanel('from_address', classname="col6"),
                FieldPanel('to_address', classname="col6"),
            ]),
            FieldPanel('subject'),
        ], "Email"),
    ]
Exemplo n.º 21
0
class BlogWagtail(ModelAdmin):
    model = Blog
    menu_label = "Blogs"
    menu_icon = "doc-full"
    menu_order = 190
    add_to_settings_menu = False
    exclude_from_explorer = False
    list_display = ("title", "author", "category", "created_at")
    search_fields = ("title", "author")
    content = RichTextField()
    # edit_template_name = "wagtail/blog/blog_post_page.html"

    panels = [
        MultiFieldPanel(
            [
                FieldPanel("title", classname="title"),
                FieldPanel("author", classname="author"),
                FieldPanel("category", classname="category"),
                # RichTextFieldPanel('content', classname='content'),
                FieldPanel("content", classname="content"),
                FieldPanel("tags", classname="tags"),
                FieldPanel("slug", classname="slug"),
            ],
            heading="Blog content",
        ),
        FieldRowPanel(
            [
                FieldPanel("published", classname="published"),
                FieldPanel("published_at", classname="published_at"),
            ],
            heading="Publications",
        ),
        FieldPanel("metadata"),
        InlinePanel("comments", label="Comments"),
    ]
Exemplo n.º 22
0
class EmailForm(AbstractEmailForm):
    """
    Defines the behaviour for pages that hold information about emailing applicants

    Email Confirmation Panel should be included to allow admins to make changes.
    """
    class Meta:
        abstract = True

    confirmation_text_extra = models.TextField(
        blank=True,
        help_text=_(
            'Additional text for the application confirmation message.'))

    def send_mail(self, submission):
        # Make sure we don't send emails to users here. Messaging handles that
        pass

    email_confirmation_panels = [
        MultiFieldPanel(
            [
                FieldRowPanel([
                    FieldPanel('from_address', classname="col6"),
                    FieldPanel('to_address', classname="col6"),
                ]),
                FieldPanel('subject'),
                FieldPanel('confirmation_text_extra'),
            ],
            heading=_('Confirmation email'),
        )
    ]

    email_tab = ObjectList(email_confirmation_panels,
                           heading=_('Confirmation email'))
Exemplo n.º 23
0
class ContactPage(WagtailCaptchaEmailForm):
    hero_heading = models.CharField(max_length=100, blank=False, null=True)
    hero_image = models.ForeignKey("wagtailimages.Image",
                                   null=True,
                                   blank=False,
                                   on_delete=models.SET_NULL,
                                   related_name="+")
    intro = RichTextField(blank=True)
    paragraph = RichTextField(blank=True)
    thank_you_text = RichTextField(blank=True)

    content_panels = AbstractEmailForm.content_panels + [
        MultiFieldPanel([
            FieldPanel('hero_heading'),
            ImageChooserPanel('hero_image'),
        ],
                        heading="Hero"),
        FieldPanel('intro'),
        MultiFieldPanel([
            FieldPanel('paragraph'),
            InlinePanel('form_fields', label='Form Fields'),
        ],
                        heading="Contact Form",
                        classname="collapsible collapsed"),
        FieldPanel('thank_you_text'),
        MultiFieldPanel([
            FieldRowPanel([
                FieldPanel('from_address', classname="col6"),
                FieldPanel('to_address', classname="col6"),
            ]),
            FieldPanel("subject"),
        ],
                        heading="Email Settings"),
    ]
Exemplo n.º 24
0
class ContactPage(AbstractEmailForm):

    template = "contact/contact_page.html"
    intro = RichTextField(
        blank=True, features=['bold', 'italic', 'h2', 'h3', 'h4', "center"])
    subpage_types = []
    max_count = 1
    parent_page_types = ["home.HomePage"]
    thank_you_text = RichTextField(blank=True,
                                   features=[
                                       'bold', 'italic', 'h2', 'h3', 'h4',
                                       'center', 'image', 'link'
                                   ])

    content_panels = AbstractEmailForm.content_panels + [
        FieldPanel("intro"),
        InlinePanel("form_fields", label="Form Fields"),
        FieldPanel("thank_you_text"),
        MultiFieldPanel([
            FieldRowPanel([
                FieldPanel("from_address", classname="col6"),
                FieldPanel("to_address", classname="col6"),
            ]),
            FieldPanel("subject"),
        ],
                        heading="Email Setting"),
    ]
    def __init__(self, *args, **kwargs):
        Segment.panels = [
            MultiFieldPanel([
                FieldPanel('name', classname="title"),
                FieldRowPanel([
                    FieldPanel('status'),
                    FieldPanel('persistent'),
                ]),
                FieldPanel('match_any'),
                FieldPanel('type', widget=forms.RadioSelect),
                FieldPanel('count', classname='count_field'),
                FieldPanel('randomisation_percent', classname='percent_field'),
            ],
                            heading="Segment"),
            MultiFieldPanel([
                RulePanel(
                    "{}_related".format(rule_model._meta.db_table),
                    label='{}{}'.format(
                        rule_model._meta.verbose_name,
                        ' ({})'.format(_('Static compatible'))
                        if rule_model.static else ''),
                ) for rule_model in AbstractBaseRule.__subclasses__()
            ],
                            heading=_("Rules")),
        ]

        super(Segment, self).__init__(*args, **kwargs)
Exemplo n.º 26
0
class Homepage(FoundationMetadataPageMixin, Page):
    hero_headline = models.CharField(
        max_length=140,
        help_text='Hero story headline',
        blank=True,
    )

    hero_story_description = RichTextField(features=[
        'bold',
        'italic',
        'link',
    ])

    hero_image = models.ForeignKey('wagtailimages.Image',
                                   null=True,
                                   blank=True,
                                   on_delete=models.SET_NULL,
                                   related_name='hero_image')

    hero_button_text = models.CharField(max_length=50, blank=True)

    hero_button_url = models.URLField(blank=True)

    content_panels = Page.content_panels + [
        MultiFieldPanel([
            FieldPanel('hero_headline'),
            FieldPanel('hero_story_description'),
            FieldRowPanel([
                FieldPanel('hero_button_text'),
                FieldPanel('hero_button_url'),
            ]),
            ImageChooserPanel('hero_image'),
        ],
                        heading='hero',
                        classname='collapsible'),
        InlinePanel('featured_highlights', label='Highlights', max_num=5),
        InlinePanel('featured_news', label='News', max_num=4),
    ]

    subpage_types = [
        'PrimaryPage',
        'PeoplePage',
        'InitiativesPage',
        'Styleguide',
        'NewsPage',
        'ParticipatePage',
        'ParticipatePage2',
        'MiniSiteNameSpace',
        'RedirectingPage',
        'OpportunityPage',
        'BanneredCampaignPage',
    ]

    def get_context(self, request):
        # We need to expose MEDIA_URL so that the s3 images will show up properly
        # due to our custom image upload approach pre-wagtail
        context = super(Homepage, self).get_context(request)
        context['MEDIA_URL'] = settings.MEDIA_URL
        return context
Exemplo n.º 27
0
class Unit(StrictHierarchyPage):
    class Meta:
        verbose_name = 'Lernangebot'
        verbose_name_plural = 'Lernangebote'

    competences = models.ManyToManyField(Competence)

    teaser = models.TextField(default='')
    lead = models.TextField(default='')
    description = models.TextField(default='')

    objectives = RichTextField(features=DEFAULT_RICH_TEXT_FEATURES)
    content = RichTextField(features=DEFAULT_RICH_TEXT_FEATURES)
    teacher = RichTextField(features=DEFAULT_RICH_TEXT_FEATURES)
    requirements = RichTextField(features=DEFAULT_RICH_TEXT_FEATURES)

    type = models.CharField(max_length=100,
                            choices=(
                                ('webinar', 'Webinar'),
                                ('kurs', 'Kurs'),
                                ('hybrid', 'Hybrid'),
                                ('coaching', 'Coaching'),
                                ('tinder', 'Tinder'),
                                ('lernfilm', 'Lernfilm'),
                                ('webex', 'Webex'),
                                ('interaktiv', 'Interaktiv'),
                            ))
    count = models.CharField(max_length=255,
                             help_text='e.g. \'3 Veranstaltungen\'')
    duration = models.CharField(max_length=255, help_text='e.g. \'je 2 Tage\'')
    price = models.CharField(default='',
                             max_length=255,
                             help_text='e.g. \'CHF 150\'')

    content_panels = [
        FieldPanel('title', classname="full title"),
        FieldPanel('teaser'),
        FieldPanel('description'),
        FieldPanel('type'),
        FieldPanel('competences'),
        MultiFieldPanel([
            FieldRowPanel([
                FieldPanel('count'),
                FieldPanel('duration'),
            ],
                          classname="label-above"),
        ], 'Kadenz'),
        FieldPanel('price'),
    ]
    settings_panels = [FieldPanel('slug')]
    edit_handler = TabbedInterface([
        ObjectList(content_panels, heading='Content'),
        ObjectList(settings_panels, heading='Settings'),
    ])

    template = 'generic_page.html'

    parent_page_types = ['modules.Module']
    subpage_types = []
Exemplo n.º 28
0
class FieldRowPanelPage(WagtailPage):
    other_name = models.CharField(max_length=10)

    content_panels = [
        FieldRowPanel([
            FieldPanel('other_name'),
        ]),
    ]
Exemplo n.º 29
0
class FieldRowPanelSnippet(models.Model):
    other_name = models.CharField(max_length=10)

    panels = [
        FieldRowPanel([
            FieldPanel('other_name'),
        ]),
    ]
Exemplo n.º 30
0
class EventDate(Orderable):
    event_page = ParentalKey(EventPage,
                             on_delete=models.CASCADE,
                             related_name="dates")
    start = models.DateTimeField()
    end = models.DateTimeField(null=True, blank=True)
    label = models.CharField(
        blank=True,
        max_length=255,
        help_text=_('Optional label like "Part I" or "Meeting point"'),
    )
    location = models.CharField(
        max_length=255,
        blank=True,
        help_text=_(
            "A more specific location, overwrites the events default location."
        ),
    )
    description = models.CharField(
        max_length=1000,
        blank=True,
        help_text=_(
            "Optional date description. Visible on event detail page only."),
    )

    panels = [
        FieldRowPanel([FieldPanel("start"),
                       FieldPanel("end")]),
        FieldRowPanel([FieldPanel("label"),
                       FieldPanel("location")]),
        FieldPanel("description"),
    ]

    objects = EventDateQuerySet.as_manager()

    class Meta:
        verbose_name = _("Date")
        verbose_name_plural = _("Dates")
        ordering = ["start", "sort_order"]

    def __str__(self):
        start = formats.date_format(self.start, "SHORT_DATETIME_FORMAT")
        if not self.label:
            return "{}".format(start)
        return "{} | {}".format(start, self.label)