How to use the wagtail.admin.edit_handlers.FieldPanel function in wagtail

To help you get started, we’ve selected a few wagtail examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github torchbox / wagtail-experiments / experiments / models.py View on Github external
class Experiment(ClusterableModel):
    STATUS_CHOICES = [
        ('draft', "Draft"),
        ('live', "Live"),
        ('completed', "Completed"),
    ]
    name = models.CharField(max_length=255)
    slug = models.SlugField(max_length=255)
    control_page = models.ForeignKey('wagtailcore.Page', related_name='+', on_delete=models.CASCADE)
    goal = models.ForeignKey('wagtailcore.Page', related_name='+', on_delete=models.SET_NULL, null=True, blank=True)
    status = models.CharField(max_length=10, choices=STATUS_CHOICES, default='draft')
    winning_variation = models.ForeignKey('wagtailcore.Page', related_name='+', on_delete=models.SET_NULL, null=True)

    panels = [
        FieldPanel('name'),
        FieldPanel('slug'),
        PageChooserPanel('control_page'),
        InlinePanel('alternatives', label="Alternatives"),
        PageChooserPanel('goal'),
        FieldPanel('status'),
    ]

    def __init__(self, *args, **kwargs):
        super(Experiment, self).__init__(*args, **kwargs)
        self._initial_status = self.status

    def activate_alternative_draft_content(self):
        # For any alternative pages that are unpublished, copy the latest draft revision
        # to the main table (with is_live=False) so that the revision shown as an alternative
        # is not an out-of-date one
        for alternative in self.alternatives.select_related('page'):
            if not alternative.page.live:
github praekeltfoundation / molo / molo / core / models.py View on Github external
MultiFieldPanel(
            [
                MultiFieldPanel(
                    [
                        StreamFieldPanel('social_media_links_on_footer_page'),
                    ],
                    heading="Social Media Footer Page", ),
            ],
            heading="Social Media Footer Page Links", ),
        MultiFieldPanel(
            [
                FieldPanel('facebook_sharing'),
                ImageChooserPanel('facebook_image'),
                FieldPanel('twitter_sharing'),
                ImageChooserPanel('twitter_image'),
                FieldPanel('whatsapp_sharing'),
                ImageChooserPanel('whatsapp_image'),
                FieldPanel('viber_sharing'),
                ImageChooserPanel('viber_image'),
                FieldPanel('telegram_sharing'),
                ImageChooserPanel('telegram_image'),
            ],
            heading="Social Media Article Sharing Buttons",
        ),
        MultiFieldPanel(
            [
                FieldPanel('enable_clickable_tags'),
                FieldPanel('enable_tag_navigation'),
            ],
            heading="Article Tag Settings"
        ),
        MultiFieldPanel(
github mozilla / foundation.mozilla.org / network-api / networkapi / buyersguide / pagemodels / products / general.py View on Github external
),
        ],
    )

    panels = insert_panels_after(
        panels,
        'How does it handle data sharing',
        [
            MultiFieldPanel(
                [
                    FieldPanel('delete_data'),
                    FieldPanel('delete_data_helptext'),
                    FieldPanel('parental_controls'),
                    FieldPanel('collects_biometrics'),
                    FieldPanel('collects_biometrics_helptext'),
                    FieldPanel('user_friendly_privacy_policy'),
                    FieldPanel('user_friendly_privacy_policy_helptext'),
                ],
                heading='How does it handle privacy',
                classname='collapsible'
            ),
        ],
    )

    def to_dict(self):
        model_dict = super().to_dict()
        model_dict['delete_data'] = tri_to_quad(self.delete_data)
        model_dict['product_type'] = 'general'
        return model_dict


# Register this model class so that BaseProduct can "cast" properly
github Frojd / Wagtail-Pipit / Company-Project / src / main / mixins.py View on Github external
_("SEO settings"),
        ),
        MultiFieldPanel(
            [
                FieldPanel("og_title"),
                FieldPanel("og_description"),
                ImageChooserPanel("og_image"),
                FieldPanel("twitter_title"),
                FieldPanel("twitter_description"),
                ImageChooserPanel("twitter_image"),
            ],
            _("Social settings"),
        ),
        MultiFieldPanel(
            [
                FieldPanel("robot_noindex"),
                FieldPanel("robot_nofollow"),
                FieldPanel("canonical_link"),
            ],
            _("Robot settings"),
        ),
    ]

    og_image_list = ["og_image"]

    @cached_property
    def seo_og_image(self):
        images = [getattr(self, x) for x in self.og_image_list]
        images = list(filter(None.__ne__, images))

        if not len(images):
            return None
github wagtail / wagtail-personalisation / src / wagtail_personalisation / rules.py View on Github external
"""
    icon = 'fa-calendar-check-o'

    mon = models.BooleanField(_("Monday"), default=False)
    tue = models.BooleanField(_("Tuesday"), default=False)
    wed = models.BooleanField(_("Wednesday"), default=False)
    thu = models.BooleanField(_("Thursday"), default=False)
    fri = models.BooleanField(_("Friday"), default=False)
    sat = models.BooleanField(_("Saturday"), default=False)
    sun = models.BooleanField(_("Sunday"), default=False)

    panels = [
        FieldPanel('mon'),
        FieldPanel('tue'),
        FieldPanel('wed'),
        FieldPanel('thu'),
        FieldPanel('fri'),
        FieldPanel('sat'),
        FieldPanel('sun'),
    ]

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

    def test_user(self, request=None):
        return [self.mon, self.tue, self.wed, self.thu,
                self.fri, self.sat, self.sun][timezone.now().date().weekday()]

    def description(self):
        days = (
            ('mon', self.mon), ('tue', self.tue), ('wed', self.wed),
github dbca-wa / oim-cms / core / models.py View on Github external
def get_template(self, request, *args, **kwargs):
        template_name = request.GET.get('template', self.template_filename)
        return '{}/{}'.format(self.__class__._meta.app_label, template_name)

    promote_panels = Page.promote_panels + [
        FieldPanel('date'),
        FieldPanel('tags')
    ]

    content_panels = Page.content_panels + [
        StreamFieldPanel('body'),
    ]

    settings_panels = Page.settings_panels + [
        FieldPanel('template_filename')
    ]

    search_fields = Page.search_fields + [
        index.SearchField('body'),
        index.FilterField('url_path'),
    ]

    def serve(self, request):
        if 'draft' in request.GET:
            return HttpResponseRedirect('/admin/pages/{}/view_draft/'.format(self.pk))
        response = super(Content, self).serve(request)
        if 'embed' in request.GET:
            with open(os.path.join(settings.MEDIA_ROOT, 'images', self.slug + '.html')) as output:
                output.write(response.content)
        return response
github praekeltfoundation / molo / molo / core / models.py View on Github external
featured_latest_promote_panels = [
        FieldPanel('featured_in_latest_start_date'),
        FieldPanel('featured_in_latest_end_date'),
    ]
    featured_section_promote_panels = [
        FieldPanel('featured_in_section_start_date'),
        FieldPanel('featured_in_section_end_date'),

    ]
    featured_homepage_promote_panels = [
        FieldPanel('featured_in_homepage_start_date'),
        FieldPanel('featured_in_homepage_end_date'),
    ]

    hero_article_panels = [
        FieldPanel('feature_as_hero_article'),
        FieldPanel('promote_date'),
        FieldPanel('demote_date'),
    ]

    metedata_promote_panels = [
        FieldPanel('metadata_tags'),
    ]

    base_form_class = ArticlePageForm

    def move(self, *args, **kwargs):
        current_site = self.get_site()
        destination_site = args[0].get_site()

        if not (current_site is destination_site):
            language = self.language
github jberghoef / wagtail-tag-manager / src / wagtail_tag_manager / models.py View on Github external
help_text=_(
            "The tag to be added or script to be executed."
            "Will assume the content is a script if no explicit tag has been added."
        )
    )

    objects = TagQuerySet.as_manager()

    panels = [
        FieldPanel("name", classname="full title"),
        FieldPanel("description", classname="full"),
        MultiFieldPanel(
            [
                FieldPanel("tag_type"),
                FieldRowPanel([FieldPanel("tag_loading"), FieldPanel("tag_location")]),
                FieldPanel("priority"),
                FieldPanel("auto_load"),
            ],
            heading=_("Meta"),
            classname="collapsible",
        ),
        FieldPanel("content", classname="full code"),
    ]

    class Meta:
        ordering = ["tag_loading", "-auto_load", "tag_location", "-priority"]

    def clean(self):
        if not re.match(r"\<.+\/?\>", self.content):
            self.content = f""

        self.content = BeautifulSoup(self.content, "html.parser").prettify()
github praekeltfoundation / molo / molo / profiles / models.py View on Github external
"The Education Level field will be captured "
                    "on done page."),
    )
    activate_education_level_required = models.BooleanField(
        default=False,
        editable=True,
        verbose_name=_("Education Level Required"),
    )

    panels = [
        MultiFieldPanel(
            [
                FieldPanel('show_mobile_number_field'),
                FieldPanel('mobile_number_required'),
                FieldPanel('country_code'),
                FieldPanel('prevent_phone_number_in_username'),
            ],
            heading="Mobile Number Settings", ),
        MultiFieldPanel(
            [
                FieldPanel('show_email_field'),
                FieldPanel('email_required'),
                FieldPanel('prevent_email_in_username'),
            ],
            heading="Email Settings", ),
        MultiFieldPanel(
            [
                FieldPanel("show_security_question_fields"),
                FieldPanel("security_questions_required"),
                FieldPanel("num_security_questions"),
                FieldPanel("password_recovery_retries"),
            ],