class CreditCardReview(RoutablePageMixin, Page): ''' The review of a card. Includes both the summary and the full review. Inherits from Page because it generates a page on the site. ''' card = models.OneToOneField(CreditCard, related_name='review', on_delete=models.PROTECT) intro = StreamField([ ('heading', blocks.CharBlock(classname="full title")), ('paragraph', blocks.RichTextBlock()), ('image', ImageChooserBlock()), ('blockquote', blocks.BlockQuoteBlock()), ('table_block', TableBlock()), ], blank=True) body = StreamField([ ('heading', blocks.CharBlock(classname="full title")), ('paragraph', blocks.RichTextBlock()), ('image', ImageChooserBlock()), ('blockquote', blocks.BlockQuoteBlock()), ('table_block', TableBlock()), ]) pros = RichTextField(default='<ul><li></li></ul>') cons = RichTextField(default='<ul><li></li></ul>') tags = ClusterTaggableManager(through=CreditCardReviewTag, blank=True) content_panels = Page.content_panels + [ SnippetChooserPanel('card'), #FieldPanel('card', classname="full"), StreamFieldPanel('intro'), StreamFieldPanel('body'), FieldPanel('pros', classname="full"), FieldPanel('cons', classname="full"), FieldPanel('tags', classname="full"), ] @route(r'^card/$', name='conduit') def conduit(self, request): self.template = 'creditcards/credit_card_only.html' self.conduit = True return self.serve(request) @route(r'^$') #need default for revision view it seems def regular(self, request): return self.serve(request) @cached_property def conduit_url(self): subpage_url = self.reverse_subpage('conduit') if not self.url.endswith('/') and not subpage_url.startswith('/'): return self.url + '/' + subpage_url return self.url + subpage_url parent_page_types = ['creditcards.CreditCardIndex'] def disclosure(self): return disclosure_generator(self.card.processing_network)
class StoryPage(Page): date = models.DateField("Post date") intro = models.CharField(max_length=250) # intro = models.CharField(max_length=250, help_text="Listen up buddy This thing is non editable Yeah!") author = models.CharField(max_length=250,default="Anonymous") body = StreamField([ ('heading', blocks.CharBlock(classname="full title")), ('paragraph', blocks.RichTextBlock()), ('images', blocks.StructBlock( [ ('image', ImageChooserBlock()), ('caption', blocks.CharBlock(blank=True,required=False,null=True)), ], icon='image', )), ('gist', blocks.TextBlock(help_text="Go to gist.github.com to write code and copy the embed Link.")), ('Link', blocks.StructBlock( [ ('URL', blocks.URLBlock()), ('Text', blocks.CharBlock()), ], icon='site', )), ('Quote',blocks.StructBlock( [ ('quote',blocks.BlockQuoteBlock()), ('Author',blocks.TextBlock(max_length=50)), ], icon='quote' )), ('embed',EmbedBlock()), ]) tags = ClusterTaggableManager(through=StoryPageTag, blank=True) categories = ParentalManyToManyField('story.StoryCategory', blank=True) search_fields = Page.search_fields + [ index.SearchField('intro'), index.SearchField('body'), ] content_panels = Page.content_panels + [ MultiFieldPanel([ FieldPanel('date'), FieldPanel('author'), FieldPanel('tags'), FieldPanel('categories', widget=forms.CheckboxSelectMultiple), ], heading="Information About Story"), FieldPanel('intro'), StreamFieldPanel('body'), ]
class BlogPage(Page): def main_image(self): gallery_item = self.gallery_images.first() if gallery_item: return gallery_item.image else: return None date = models.DateField("Post date") intro = models.CharField(max_length=250) body = RichTextField(blank=True) tags = ClusterTaggableManager(through=BlogPageTag, blank=True) categories = ParentalManyToManyField('blog.BlogCategory', blank=True) page_content = StreamField([ ('h2_heading', blocks.CharBlock(classname="full title", icon="title")), ('paragraph', blocks.RichTextBlock()), ('blockquote', blocks.BlockQuoteBlock()), ('document', DocumentChooserBlock()), ('image', ImageChooserBlock(icon="image")), ('embed', EmbedBlock()), ('link', blocks.URLBlock()), ('codeblock', CodeBlock()), ], null=True, blank=True) # media = models.ForeignKey( # 'wagtailmedia.Media', # null=True, # blank=True, # on_delete=models.SET_NULL, # related_name='+' # ) video = models.ForeignKey('wagtail_embed_videos.EmbedVideo', verbose_name="Video", null=True, blank=True, on_delete=models.SET_NULL, related_name='+') search_fields = Page.search_fields + [ index.SearchField('intro'), index.SearchField('body'), ] content_panels = Page.content_panels + [ MultiFieldPanel([ FieldPanel('date'), FieldPanel('tags'), FieldPanel('categories', widget=forms.CheckboxSelectMultiple), ], heading="Blog information"), FieldPanel('intro'), FieldPanel('body', classname="full"), StreamFieldPanel('page_content'), # MediaChooserPanel('media'), # this breaks the WYSIWYG, so I'm not using it anymore EmbedVideoChooserPanel('video'), InlinePanel('gallery_images', label="Gallery images"), ]
class ContactPage(AbstractEmailForm): intro = RichTextField(blank=True) thank_you_text = RichTextField(blank=True) body = StreamField([ ('heading', blocks.CharBlock(classname="full title")), ('paragraph', blocks.RichTextBlock()), ('image', ImageChooserBlock()), ('blockquote', blocks.BlockQuoteBlock()), ('raw_html', blocks.RawHTMLBlock()), ], blank=True) content_panels = AbstractEmailForm.content_panels + [ FormSubmissionsPanel(), FieldPanel('intro', classname="full"), InlinePanel('contact_fields', label="Form fields"), StreamFieldPanel('body'), FieldPanel('thank_you_text', classname="full"), MultiFieldPanel([ FieldRowPanel([ FieldPanel('from_address', classname="col6"), FieldPanel('to_address', classname="col6"), ]), FieldPanel('subject'), ], "Email"), ] def get_form_fields(self): return self.contact_fields.all() def send_mail(self, form): # Overwrite the send_mail method from AbstractEmailForm # to use inquiry as email subject. addresses = [x.strip() for x in self.to_address.split(',')] content = [] subj = None send_from = self.from_address for field in form: if 'inquiry' in field.name: subj = field.value() elif 'email' in field.name.lower(): send_from = field.value() value = field.value() if isinstance(value, list): value = ', '.join(value) content.append('{}: {}'.format(field.label, value)) content = '\n'.join(content) if subj: send_mail(subj, content, addresses, send_from,) else: send_mail(self.subject, content, addresses, send_from,)
class HomePage(Page): intro = RichTextField(blank=True) body = StreamField([ ('text', blocks.RichTextBlock()), ('blockquote', blocks.BlockQuoteBlock()), ('image', ImageChooserBlock(template='wagtail_blocks/image.html')), ('document', DocumentChooserBlock()), ('embed', EmbedBlock(template='wagtail_blocks/embed.html')), ], blank=True) content_panels = Page.content_panels + [ FieldPanel('intro'), StreamFieldPanel('body'), ]
class ProjectPage(Page): heading = RichTextField() summary = models.TextField(blank=True) content = StreamField([("image", ImageChooserBlock()), ("embed", EmbedBlock()), ("blockquote", blocks.BlockQuoteBlock()), ("text", blocks.RichTextBlock())], default=None) concept = RichTextField(blank=True) tech = RichTextField(blank=True) legend = StreamField(LegendBlock(), default=None) content_panels = Page.content_panels + [ FieldPanel("heading"), InlinePanel("images", label="Cover and carousel images", min_num=1), FieldPanel("summary"), StreamFieldPanel("content"), FieldPanel("concept"), FieldPanel("tech"), MultiFieldPanel([InlinePanel("cta", min_num=None)], heading="Call to action/s"), StreamFieldPanel("legend") ]