class ExtraStreamBlock(BaseStreamBlock): """ Este bloque extiende a BaseStreamBlock, para hacer lo mismo que BaseStreamBlock pero meter cosas nuevas """ doscolumnas_block = TwoColumnBlock() threecolumn_block = ThreeColumnBlock() carousel_block = CarouselBlock() headband_block = HeadBandBlock() header = HeaderBlock() """
class HomePage(Page): body = StreamField([ ('header', HeaderBlock()), ('list', ListBlock()), ('image_text_overlay', ImageTextOverlayBlock()), ('cropped_images_with_text', CroppedImagesWithTextBlock()), ('list_with_images', ListWithImagesBlock()), ('thumbnail_gallery', ThumbnailGalleryBlock()), ('chart', ChartBlock()), ('map', MapBlock()), ('image_slider', ImageSliderBlock()), ], blank=True) content_panels = Page.content_panels + [ StreamFieldPanel("body", classname="Full"), ]
class GeneralContentBlocks(blocks.StreamBlock): """ Allowed Blocks """ image_block = ImageChooserBlock(required=False) #headers = HeaderBlock(required=False) rich_field_text = blocks.RichTextBlock(required=False) #image_slider = ImageSliderBlock() svg_image = custom_blocks.CustomSVGImageBlock(template = "CustomBlock/custom_image_svg_block.html") header_block= HeaderBlock(), list_block = ListBlock() image_text_overlay = ImageTextOverlayBlock() cropped_images_with_text= CroppedImagesWithTextBlock() list_with_images = ListWithImagesBlock() thumbnail_gallery = ThumbnailGalleryBlock() chart = ChartBlock() map_block = MapBlock() image_slider = ImageSliderBlock() project_listing = ProjectListing()
class HomePage(TranslatablePage): """Die Willkommensseite""" jumbotronTitle = models.CharField(max_length=30, blank=False, null=True) jumbotronSubtitle = models.CharField(max_length=200, blank=False, null=True) jumbotronImage = models.ForeignKey("wagtailimages.Image", null=True, blank=True, on_delete=models.SET_NULL, related_name="+") announcements = StreamField([ ('announcement', Announcement()), ], blank=True) body = StreamField([ ('header', HeaderBlock()), ('paragraph', blocks.RichTextBlock(features=[ 'bold', 'italic', 'link', 'document-link', 'code', 'blockquote' ])), ('list', ListBlock()), ('image_text_overlay', ImageTextOverlayBlock()), ('cropped_images_with_text', CroppedImagesWithTextBlock()), ('list_with_images', ListWithImagesBlock()), ('thumbnail_gallery', ThumbnailGalleryBlock()), ('image_slider', ImageSliderBlock()), ('misc_card', Cards4xn()), ], blank=True) content_panels = Page.content_panels + [ FieldPanel("jumbotronTitle"), FieldPanel("jumbotronSubtitle"), ImageChooserPanel("jumbotronImage"), StreamFieldPanel("announcements", classname="Full"), StreamFieldPanel("body", classname="Full"), ] max_count = 1
class BlogPage(TranslatablePage): """Einzelner Blogpost""" # title wird geerbt blogTeaser = models.CharField(max_length=50, null=True, blank=False) blogImage = models.ForeignKey( "wagtailimages.Image", null=True, blank=True, on_delete=models.SET_NULL, related_name="+", help_text= "this image will also be displayed in the listing page and over there " "gets cropped to ~540x320 ") body = StreamField([ ('header', HeaderBlock()), ('paragraph', blocks.RichTextBlock(features=[ 'bold', 'italic', 'link', 'document-link', 'code', 'blockquote' ])), ('list', ListBlock()), ('image_text_overlay', ImageTextOverlayBlock()), ('cropped_images_with_text', CroppedImagesWithTextBlock()), ('list_with_images', ListWithImagesBlock()), ('thumbnail_gallery', ThumbnailGalleryBlock()), ('chart', ChartBlock()), ('map', MapBlock()), ('image_slider', ImageSliderBlock()), ], blank=True) content_panels = Page.content_panels + [ FieldPanel("blogTeaser"), ImageChooserPanel("blogImage"), StreamFieldPanel("body", classname="Full"), ] class Meta: verbose_name = "Blogpost" verbose_name_plural = "Blogposts"
class FlexPage(TranslatablePage): """flexible content page with streamfields""" image = models.ForeignKey("wagtailimages.Image", null=True, blank=True, on_delete=models.SET_NULL, related_name="+", help_text="Shown in jumbotron") body = StreamField([ ('header', HeaderBlock()), ('paragraph', blocks.RichTextBlock(features=[ 'bold', 'italic', 'link', 'document-link', 'code', 'blockquote' ])), ('list', ListBlock()), ('image_text_overlay', ImageTextOverlayBlock()), ('cropped_images_with_text', CroppedImagesWithTextBlock()), ('list_with_images', ListWithImagesBlock()), ('thumbnail_gallery', ThumbnailGalleryBlock()), ('chart', ChartBlock()), ('map', MapBlock()), ('image_slider', ImageSliderBlock()), ('person_vcards', PersonVCards()), ('misc_cards', Cards4xn()), ('partner_vcards', PartnerVCards()), ], blank=True) content_panels = Page.content_panels + [ ImageChooserPanel("image"), StreamFieldPanel("body", classname="Full"), ] class Meta: verbose_name = "FlexPage" verbose_name_plural = "FlexPages"
class HomePage(MetadataPageMixin, Page): body = StreamField( [ ("header", HeaderBlock()), ("list", ListBlock()), ("image_text_overlay", ImageTextOverlayBlock()), ("cropped_images_with_text", CroppedImagesWithTextBlock()), ("list_with_images", ListWithImagesBlock()), ("thumbnail_gallery", ThumbnailGalleryBlock()), ("chart", ChartBlock()), ("map", MapBlock()), ("image_slider", ImageSliderBlock()), ("form", WagtailFormBlock()), ("Parallax", ParallaxBlock()), ("Code", MyCodeBlock()), ], blank=True, ) author_twitter_handle = models.CharField(max_length=15) content_panels = Page.content_panels + [ StreamFieldPanel("body", classname="Full"), FieldPanel("author_twitter_handle"), ]
class Activity(ClusterableModel): class Meta: managed = True verbose_name = 'Lesson' verbose_name_plural = 'Lessons' # This was originally called activity. It is now Lessons, because EDU asked for it changed. # They like to change their minds a lot, so I have not converted the entire app over to be named lesson, simply reskinned the app. # verbose_name = 'Activity' # verbose_name_plural = 'Activities' createDate = models.DateTimeField(auto_now_add=True) modifiedDate = models.DateTimeField(auto_now=True) live = models.BooleanField(verbose_name='Publish', default=False, editable=True) slug = models.SlugField( null=True, blank=True, ) title = models.CharField(max_length=50) # teachers_guide = models.URLField() overview_copy = RichTextField(null=True, blank=True) student_copy = RichTextField(null=True, blank=True) teachers_desc = StreamField([ ('title', blocks.TitleBlock()), ('copy', wagtail_blocks.RichTextBlock()), ('image', ImageChooserBlock()), ('asset', SnippetChooserBlock('assets.Asset')), ('activity', SnippetChooserBlock('activity.Activity')), ('document', DocumentChooserBlock()), ('embed', EmbedBlock()), ('external', blocks.Link()), ('google_doc', blocks.GoogleDocEmbed()), ('codap', blocks.CODAPEmbed()), ('raw_html', wagtail_blocks.RawHTMLBlock()), ('header', HeaderBlock()), ('list', ListBlock()), ('image_text_overlay', ImageTextOverlayBlock()), ('cropped_images_with_text', CroppedImagesWithTextBlock()), ('list_with_images', ListWithImagesBlock()), ('thumbnail_gallery', ThumbnailGalleryBlock()), ('chart', ChartBlock()), ('map', MapBlock()), ], null=True, blank=True) students_desc = StreamField([ ('title', blocks.TitleBlock()), ('copy', wagtail_blocks.RichTextBlock()), ('image', ImageChooserBlock()), ('asset', SnippetChooserBlock('assets.Asset')), ('activity', SnippetChooserBlock('activity.Activity')), ('document', DocumentChooserBlock()), ('embed', EmbedBlock()), ('external', blocks.Link()), ('google_doc', blocks.GoogleDocEmbed()), ('codap', blocks.CODAPEmbed()), ('raw_html', wagtail_blocks.RawHTMLBlock()), ('header', HeaderBlock()), ('list', ListBlock()), ('image_text_overlay', ImageTextOverlayBlock()), ('cropped_images_with_text', CroppedImagesWithTextBlock()), ('list_with_images', ListWithImagesBlock()), ('thumbnail_gallery', ThumbnailGalleryBlock()), ('chart', ChartBlock()), ('map', MapBlock()), ], null=True, blank=True) program = models.ForeignKey('taxonomy.Program', null=True, blank=True, on_delete=models.SET_NULL) time_estimate = models.ForeignKey('taxonomy.TimeEstimate', null=True, blank=True, on_delete=models.SET_NULL) audience = models.ForeignKey('taxonomy.Audience', null=True, blank=True, on_delete=models.SET_NULL) topic = models.ForeignKey('taxonomy.Topic', null=True, blank=True, on_delete=models.SET_NULL) activity_type = models.ForeignKey('taxonomy.ActivityType', null=True, blank=False, on_delete=models.CASCADE) @property def tags(self): tags = [n.tag for n in self.tag_relationship.all()] return tags @property def learning_spaces(self): learning_spaces = [ n.learning_space for n in self.learningspace_relationship.all() ] return learning_spaces # tag = models.ManyToManyField( # 'taxonomy.Tag', # blank=True # ) def __str__(self): return self.title panels = [ FieldPanel("live"), FieldPanel("slug"), FieldPanel("title"), # FieldPanel("teachers_guide"), FieldPanel("overview_copy"), StreamFieldPanel('teachers_desc'), StreamFieldPanel('students_desc'), SnippetChooserPanel('program'), FieldPanel('activity_type'), InlinePanel('audience_relationship', label="Audience"), InlinePanel('learningspace_relationship', label="Learning Space"), InlinePanel('standards_relationship', label="Standards Alignment"), InlinePanel('topic_relationship', label="Topics"), InlinePanel('tag_relationship', label="Tags"), ] api_fields = [ APIField("live"), APIField('title'), APIField('overview_copy'), APIField('teachers_desc'), APIField('students_desc'), APIField('program', serializer=ProgramSerializer()), APIField('activity_type'), APIField('audience_relationship'), APIField('learningspace_relationship'), APIField('standards_relationship'), APIField('topic_relationship'), APIField('tag_relationship'), ]
class Module(ClusterableModel): template = 'modules/module_page.html' createDate = models.DateTimeField(auto_now_add=True) modifiedDate = models.DateTimeField(auto_now=True) # SETH slug = models.SlugField( null=True, blank=True, ) live = models.BooleanField(verbose_name='Publish', default=False, editable=True) hero_image = models.ForeignKey('wagtailimages.Image', null=True, blank=True, on_delete=models.SET_NULL, related_name='+') title = models.CharField(max_length=100) subtitle = models.CharField( max_length=300, null=True, blank=True, ) intro_copy = RichTextField(verbose_name="Header Intro", null=True, blank=True) overview_copy = RichTextField(verbose_name="Overview Tab Copy", null=True, blank=True) student_intro = RichTextField(verbose_name="Student Page Intro", null=True, blank=True) teachers_guide = models.URLField(null=True, blank=True) module_download = models.URLField(null=True, blank=True) learning_outcomes = RichTextField( null=True, blank=True, verbose_name="Learning Outcomes (displays on Detail tab)") teachers_desc = StreamField( [ ('title', blocks.TitleBlock()), ('copy', wagtail_blocks.RichTextBlock()), ('image', ImageChooserBlock()), ('asset', SnippetChooserBlock('assets.Asset')), ('activity', SnippetChooserBlock('activity.Activity')), ('document', DocumentChooserBlock()), ('embed', EmbedBlock()), ('youtube', blocks.YouTubeBlock()), ('google_doc', blocks.GoogleDocEmbed()), ('codap', blocks.CODAPEmbed()), ('header', HeaderBlock()), ('list', ListBlock()), ('image_text_overlay', ImageTextOverlayBlock()), ('cropped_images_with_text', CroppedImagesWithTextBlock()), ('list_with_images', ListWithImagesBlock()), ('thumbnail_gallery', ThumbnailGalleryBlock()), ('chart', ChartBlock()), ('map', MapBlock()), ], null=True, blank=True, verbose_name="Lessons Tab Content", ) students_desc = StreamField( [ ('title', blocks.TitleBlock()), ('copy', wagtail_blocks.RichTextBlock()), ('image', ImageChooserBlock()), ('asset', SnippetChooserBlock('assets.Asset')), ('activity', SnippetChooserBlock('activity.Activity')), ('document', DocumentChooserBlock()), ('embed', EmbedBlock()), ('youtube', blocks.YouTubeBlock()), ('google_doc', blocks.GoogleDocEmbed()), ('codap', blocks.CODAPEmbed()), ('header', HeaderBlock()), ('list', ListBlock()), ('image_text_overlay', ImageTextOverlayBlock()), ('cropped_images_with_text', CroppedImagesWithTextBlock()), ('list_with_images', ListWithImagesBlock()), ('thumbnail_gallery', ThumbnailGalleryBlock()), ('chart', ChartBlock()), ('map', MapBlock()), ], null=True, blank=True, verbose_name="Resources for Students", ) time_estimate = models.ForeignKey('taxonomy.TimeEstimate', null=True, blank=True, on_delete=models.SET_NULL) program = models.ForeignKey('taxonomy.Program', null=True, blank=True, on_delete=models.SET_NULL) @property def standards_alignment(self): standards_alignment = [ n.standard for n in self.standards_relationship.all() ] return standards_alignment @property def audience(self): audience = [n.audience for n in self.audience_relationship.all()] return audience @property def learning_spaces(self): learning_spaces = [ n.learning_space for n in self.learningspace_relationship.all() ] return learning_spaces @property def tags(self): tags = [n.tag for n in self.tag_relationship.all()] return tags @property def topics(self): topics = [n.topic for n in self.topic_relationship.all()] return topics panels = [ MultiFieldPanel( [ FieldPanel('live'), FieldPanel('slug'), # SETH FieldPanel('title'), FieldPanel('subtitle'), FieldPanel('intro_copy'), ImageChooserPanel('hero_image'), ], heading="Header Section"), MultiFieldPanel([ FieldPanel('overview_copy'), FieldPanel('student_intro'), FieldPanel('learning_outcomes'), FieldPanel('teachers_guide'), FieldPanel('module_download'), ], heading="Intro Content"), MultiFieldPanel([ StreamFieldPanel('teachers_desc'), StreamFieldPanel('students_desc'), ], heading="Lessons"), MultiFieldPanel([ SnippetChooserPanel('program'), SnippetChooserPanel('time_estimate'), InlinePanel('audience_relationship', label="Audience"), InlinePanel('learningspace_relationship', label="Learning Space"), InlinePanel('standards_relationship', label="Standards Alignment"), InlinePanel('topic_relationship', label="Topics"), InlinePanel('tag_relationship', label="Tags"), ], heading="Module Metadata") ] api_fields = [ APIField("live"), APIField('title'), APIField('subtitle'), APIField('hero_image'), APIField('intro_copy'), APIField('student_intro'), APIField('learning_outcomes'), APIField('teachers_guide'), APIField('teachers_desc'), APIField('students_desc'), APIField('program', serializer=ProgramSerializer()), APIField('time_estimate', serializer=TimeEstimateSerializer()), APIField('audience_relationship'), APIField('learningspace_relationship'), APIField('standards_relationship'), APIField('topic_relationship'), APIField('tag_relationship'), ] def __str__(self): return self.title def is_educator(self, **kwargs): return self.audience_relationship.filter(audience=6)
class ContentPage(Page): class Meta: managed = True verbose_name = 'Content' verbose_name_plural = 'Content Pages' image = models.ForeignKey('wagtailimages.Image', null=True, blank=True, on_delete=models.SET_NULL, related_name='+', help_text='Homepage image') image_alt = models.CharField(max_length=100, null=True, blank=True, help_text='Alt tag for image') hero_text = models.CharField( max_length=100, null=True, blank=True, help_text='Marketing-speak about GRMI EDU (100 Characters Max)') program = models.ForeignKey( 'taxonomy.Program', null=True, blank=True, on_delete=models.SET_NULL, ) featured_title = models.CharField( max_length=100, null=True, blank=True, verbose_name='Introduction Title', help_text='Title for intro copy (optional)') featured_copy = RichTextField( features=[ 'bold', 'italic', 'link', 'ol', 'ul', 'document-link', 'image' ], null=True, blank=True, verbose_name='Introductory Content Copy', help_text='Copy describing the program & the featured curricula') body = StreamField([ ('title', blocks.TitleBlock()), ('copy', wagtail_blocks.RichTextBlock()), ('image', ImageChooserBlock()), ('asset', SnippetChooserBlock('assets.Asset')), ('activity', SnippetChooserBlock('activity.Activity')), ('document', DocumentChooserBlock()), ('embed', EmbedBlock()), ('header', HeaderBlock()), ('list', ListBlock()), ('image_text_overlay', ImageTextOverlayBlock()), ('cropped_images_with_text', CroppedImagesWithTextBlock()), ('list_with_images', ListWithImagesBlock()), ('thumbnail_gallery', ThumbnailGalleryBlock()), ('chart', ChartBlock()), ('map', MapBlock()), ], null=True, blank=True) content_panels = Page.content_panels + [ MultiFieldPanel([ ImageChooserPanel('image'), FieldPanel('image_alt'), FieldPanel('hero_text', classname="full"), ], heading="Hero section"), MultiFieldPanel([ FieldPanel('featured_title'), FieldPanel('featured_copy'), ], heading="Introduction Section", classname='wagtailuiplus__panel--collapsed'), MultiFieldPanel([ StreamFieldPanel('body'), SnippetChooserPanel('program'), ], heading="Body") ] # Export fields over the API api_fields = [ APIField('image'), APIField('image_alt'), APIField('hero_text'), APIField('featured_title'), APIField('featured_copy'), APIField('program'), APIField('body'), ] def serve(self, request): modules = Module.objects.all() self.modules = modules return super().serve(request)