Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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:
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(
),
],
)
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
_("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
"""
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),
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
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
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()
"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"),
],