Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
unprocessed_submissions_link.short_description = ''
unprocessed_submissions_link.allow_tags = True
def edit_link(self, obj):
return '<a href="%s">%s</a>' % (
reverse('wagtailadmin_pages:edit', args=(obj.pk,)),
_('Edit this form page'))
edit_link.short_description = ''
edit_link.allow_tags = True
class SubmissionStatusFilter(SimpleListFilter):
title = _('status')
parameter_name = 'status'
unprocessed_status = ','.join((SessionFormSubmission.COMPLETE,
SessionFormSubmission.REVIEWED))
def lookups(self, request, model_admin):
yield (self.unprocessed_status, _('Complete or reviewed'))
for status, verbose_status in SessionFormSubmission.STATUSES:
if status != SessionFormSubmission.INCOMPLETE:
yield status, verbose_status
def queryset(self, request, queryset):
status = self.value()
if not status:
return queryset
if ',' in status:
return queryset.filter(status__in=status.split(','))
return queryset.filter(status=status)
'&status=%s' % SubmissionStatusFilter.unprocessed_status)
unprocessed_submissions_link.short_description = ''
unprocessed_submissions_link.allow_tags = True
def edit_link(self, obj):
return '<a href="%s">%s</a>' % (
reverse('wagtailadmin_pages:edit', args=(obj.pk,)),
_('Edit this form page'))
edit_link.short_description = ''
edit_link.allow_tags = True
class SubmissionStatusFilter(SimpleListFilter):
title = _('status')
parameter_name = 'status'
unprocessed_status = ','.join((SessionFormSubmission.COMPLETE,
SessionFormSubmission.REVIEWED))
def lookups(self, request, model_admin):
yield (self.unprocessed_status, _('Complete or reviewed'))
for status, verbose_status in SessionFormSubmission.STATUSES:
if status != SessionFormSubmission.INCOMPLETE:
yield status, verbose_status
def queryset(self, request, queryset):
status = self.value()
if not status:
return queryset
if ',' in status:
return queryset.filter(status__in=status.split(','))
return queryset.filter(status=status)
key.replace('_', ' ').title(),
value
))
content = '\n-------------------- \n'.join(content)
# Build email message parameters
message_args = {
'body': content,
'to': addresses,
}
if self.subject:
message_args['subject'] = self.subject
else:
message_args['subject'] = self.title
genemail = GeneralSettings.for_site(request.site).from_email_address
if genemail:
message_args['from_email'] = genemail
if self.reply_address:
# Render reply-to field using form submission as context.
context = Context(self.data_to_dict(processed_data, request))
template_reply_to = Template(self.reply_address)
message_args['reply_to'] = template_reply_to.render(context).split(',')
# Send email
message = EmailMessage(**message_args)
message.send()
all_children = self.get_index_children()
# Filter by classifier terms if applicable
if len(request.GET) > 0 and self.index_classifiers.exists():
# Look up comma separated ClassifierTerm slugs i.e. `/?c=term1-slug,term2-slug`
terms = []
get_c = request.GET.get('c', None)
if get_c:
terms = get_c.split(',')
# Else look up individual querystrings i.e. `/?classifier-slug=term1-slug`
else:
for classifier in self.index_classifiers.all().only('slug'):
get_term = request.GET.get(classifier.slug, None)
if get_term:
terms.append(get_term)
if len(terms) > 0:
selected_terms = ClassifierTerm.objects.filter(slug__in=terms)
context['selected_terms'] = selected_terms
if len(selected_terms) > 0:
try:
for term in selected_terms:
all_children = all_children.filter(classifier_terms=term)
except AttributeError:
logger.warning(
"Tried to filter by ClassifierTerm, but <%s.%s ('%s')>.get_index_children() did not return a queryset or is not a queryset of CoderedPage models.", # noqa
self._meta.app_label,
self.__class__.__name__,
self.title
)
paginator = Paginator(all_children, self.index_num_per_page)
pagenum = request.GET.get('p', 1)
try:
paged_children = paginator.page(pagenum)
map_zoom_level = blocks.IntegerBlock(
required=False,
default=14,
label=_('Map zoom level'),
help_text=_(
"Requires API key to use zoom. 1: World, 5: Landmass/continent, 10: City, 15: Streets, 20: Buildings" # noqa
)
)
class Meta:
template = 'coderedcms/blocks/google_map.html'
icon = 'fa-map'
label = _('Google Map')
class EmbedVideoBlock(BaseBlock):
"""
Emedded media using stock wagtail functionality.
"""
url = EmbedBlock(
required=True,
label=_('URL'),
help_text=_('Link to a YouTube/Vimeo video, tweet, facebook post, etc.')
)
class Meta:
template = 'coderedcms/blocks/embed_video_block.html'
icon = 'media'
label = _('Embed Media')
class H1Block(BaseBlock):
label = _('Card')
class CarouselBlock(BaseBlock):
"""
Enables choosing a Carousel snippet.
"""
carousel = SnippetChooserBlock('coderedcms.Carousel')
class Meta:
icon = 'image'
label = _('Carousel')
template = 'coderedcms/blocks/carousel_block.html'
class ImageGalleryBlock(BaseBlock):
"""
Show a collection of images with interactive previews that expand to
full size images in a modal.
"""
collection = CollectionChooserBlock(
required=True,
label=_('Image Collection'),
)
class Meta:
template = 'coderedcms/blocks/image_gallery_block.html'
icon = 'image'
label = _('Image Gallery')
class ModalBlock(ButtonMixin, BaseLayoutBlock):
class NavDocumentLinkBlock(NavBaseLinkBlock):
"""
Document link.
"""
document = DocumentChooserBlock(
label=_('Document'),
)
class Meta:
template = 'coderedcms/blocks/document_link_block.html'
label = _('Document Link')
class NavSubLinkBlock(BaseBlock):
"""
Streamblock for rendering nested sub-links.
"""
sub_links = blocks.StreamBlock(
[
('page_link', NavPageLinkBlock()),
('external_link', NavExternalLinkBlock()),
('document_link', NavDocumentLinkBlock()),
],
required=False,
label=_('Sub-links'),
)
class NavExternalLinkWithSubLinkBlock(NavSubLinkBlock, NavExternalLinkBlock):
"""
class H2Block(BaseBlock):
"""
An <h2> heading.
"""
text = blocks.CharBlock(
max_length=255,
label=_('Text'),
)
class Meta:
template = 'coderedcms/blocks/h2_block.html'
icon = 'fa-header'
label = _('Heading 2')
class H3Block(BaseBlock):
"""
An </h2><h3> heading.
"""
text = blocks.CharBlock(
max_length=255,
label=_('Text'),
)
class Meta:
template = 'coderedcms/blocks/h3_block.html'
icon = 'fa-header'
label = _('Heading 3')
class TableBlock(BaseBlock):
table = WagtailTableBlock()</h3>
rows=4,
label=_('Description'),
)
price = blocks.CharBlock(
required=True,
label=_('Price'),
help_text=_('Any text here. Include currency sign if desired.'),
)
class Meta:
template = 'coderedcms/blocks/pricelistitem_block.html'
icon = 'fa-usd'
label = _('Price List Item')
class PriceListBlock(BaseBlock):
"""
A price list, such as a menu for a restaurant.
"""
heading = blocks.CharBlock(
required=False,
max_length=255,
label=_('Heading'),
)
items = blocks.StreamBlock(
[
('item', PriceListItemBlock()),
],
label=_('Items'),
)
class Meta:
required=False,
max_length=255,
label=_('Condition Trigger ID'),
help_text=_(
'The "Custom ID" of another field that that will trigger this field to be shown/hidden.') # noqa
)
condition_trigger_value = blocks.CharBlock(
required=False,
max_length=255,
label=_('Condition Trigger Value'),
help_text=_(
'The value of the field in "Condition Trigger ID" that will trigger this field to be shown.') # noqa
)
class FormBlockMixin(BaseBlock):
class Meta:
abstract = True
advsettings_class = CoderedFormAdvSettings
class CoderedStreamFormFieldBlock(form_blocks.OptionalFormFieldBlock, FormBlockMixin):
pass
class CoderedStreamFormCharFieldBlock(form_blocks.CharFieldBlock, FormBlockMixin):
class Meta:
label = _("Text or Email input")
icon = "fa-window-minimize"