def make_page_with_category(self, category_name, parent):
        page = AbstractFilterPage(title='test', slug='test')
        parent.add_child(instance=page)

        category = CFGOVPageCategory.objects.create(name=category_name,
                                                    page=page)
        page.categories.add(category)
Ejemplo n.º 2
0
class BlogPage(AbstractFilterPage):
    content = StreamField([
        ('full_width_text', organisms.FullWidthText()),
        ('info_unit_group', organisms.InfoUnitGroup()),
        ('expandable', organisms.Expandable()),
        ('well', organisms.Well()),
        ('video_player', organisms.VideoPlayer()),
        ('email_signup', organisms.EmailSignUp()),
        ('feedback', v1_blocks.Feedback()),
    ])
    edit_handler = AbstractFilterPage.generate_edit_handler(
        content_panel=StreamFieldPanel('content'))
    template = 'blog/blog_page.html'

    objects = PageManager()
    search_fields = AbstractFilterPage.search_fields + [
        index.SearchField('content')
    ]

    def get_context(self, request, *args, **kwargs):
        context = super(BlogPage, self).get_context(request, *args, **kwargs)

        context['rss_feed'] = get_appropriate_rss_feed_url_for_page(
            self, request=request)

        return context
Ejemplo n.º 3
0
class LegacyBlogPage(AbstractFilterPage):
    content = StreamField([
        ('content',
         blocks.RawHTMLBlock(help_text='Content from WordPress unescaped.')),
        ('feedback', v1_blocks.Feedback()),
    ])
    objects = CFGOVPageManager()
    edit_handler = AbstractFilterPage.generate_edit_handler(
        content_panel=StreamFieldPanel('content'))
    template = 'blog/blog_page.html'
Ejemplo n.º 4
0
class BlogPage(AbstractFilterPage):
    content = StreamField([
        ('full_width_text', organisms.FullWidthText()),
        ('image_text_50_50_group', organisms.ImageText5050Group()),
        ('feedback', v1_blocks.Feedback()),
        ('email_signup', organisms.EmailSignUp()),
        ('expandable', organisms.Expandable()),
    ])
    edit_handler = AbstractFilterPage.generate_edit_handler(
        content_panel=StreamFieldPanel('content'))
    template = 'blog/blog_page.html'

    objects = PageManager()
Ejemplo n.º 5
0
class LegacyBlogPage(AbstractFilterPage):
    content = StreamField([
        ('content',
         blocks.RawHTMLBlock(help_text='Content from WordPress unescaped.')),
        ('feedback', v1_blocks.Feedback()),
        ('reusable_text',
         v1_blocks.ReusableTextChooserBlock('v1.ReusableText')),
    ])
    objects = CFGOVPageManager()
    edit_handler = AbstractFilterPage.generate_edit_handler(
        content_panel=StreamFieldPanel('content'))
    template = 'blog/blog_page.html'

    search_fields = AbstractFilterPage.search_fields + [
        index.SearchField('content')
    ]
Ejemplo n.º 6
0
class BlogPage(AbstractFilterPage):
    content = StreamField([
        ('full_width_text', organisms.FullWidthText()),
        ('info_unit_group', organisms.InfoUnitGroup()),
        ('expandable', organisms.Expandable()),
        ('well', organisms.Well()),
        ('email_signup', organisms.EmailSignUp()),
        ('feedback', v1_blocks.Feedback()),
    ])
    edit_handler = AbstractFilterPage.generate_edit_handler(
        content_panel=StreamFieldPanel('content'))
    template = 'blog/blog_page.html'

    objects = PageManager()
    search_fields = AbstractFilterPage.search_fields + [
        index.SearchField('content')
    ]
Ejemplo n.º 7
0
    def setUp(self):

        self.hostname = 'localhost'

        # add some authors to a CFGOV page and give it some tags

        self.author1 = 'Some Author'
        self.author2 = 'Another Person'
        self.author3 = 'A Third Author'
        self.page_with_authors = CFGOVPage(title='a cfgov page with authors')
        helpers.save_new_page(self.page_with_authors)

        self.page_with_authors.authors.add(self.author1)
        self.page_with_authors.authors.add(self.author2)
        self.page_with_authors.authors.add(self.author3)

        self.page_with_authors.tags.add('tag 1')
        self.page_with_authors.tags.add('tag 2')

        # set up parent pages for the different types of related
        # posts we can have

        self.blog_parent = CFGOVPage(slug='blog', title='blog parent')
        self.newsroom_parent = CFGOVPage(slug='newsroom', title='newsroom parent')
        self.events_parent = CFGOVPage(slug='events', title='events parent')
        self.archive_events_parent = CFGOVPage(slug='archive-past-events', title='archive past events parent')

        helpers.save_new_page(self.blog_parent)
        helpers.save_new_page(self.newsroom_parent)
        helpers.save_new_page(self.events_parent)
        helpers.save_new_page(self.archive_events_parent)

        # set up children of the parent pages and give them some tags
        # and some categories

        self.blog_child1 = AbstractFilterPage(title='blog child 1', date_published=dt.date(2016, 9, 1))
        self.blog_child1.tags.add('tag 1')
        self.blog_child1.categories.add(CFGOVPageCategory(name='info-for-consumers'))

        self.blog_child2 = AbstractFilterPage(title='blog child 2', date_published=dt.date(2016, 9, 2))
        self.blog_child2.tags.add('tag 2')
        self.blog_child2.categories.add(CFGOVPageCategory(name='policy_compliance'))

        self.newsroom_child1 = AbstractFilterPage(title='newsroom child 1', date_published=dt.date(2016, 9, 2))
        self.newsroom_child1.tags.add('tag 1')
        self.newsroom_child1.tags.add('tag 2')
        self.newsroom_child1.categories.add(CFGOVPageCategory(name='op-ed'))

        self.newsroom_child2 = AbstractFilterPage(title='newsroom child 2', date_published=dt.date(2016, 9, 3))
        self.newsroom_child2.tags.add('tag 2')
        self.newsroom_child2.categories.add(CFGOVPageCategory(name='some-other-category'))

        self.events_child1 = AbstractFilterPage(title='events child 1', date_published=dt.date(2016, 9, 7))
        self.events_child1.tags.add('tag 1')

        self.events_child2 = AbstractFilterPage(title='events child 2', date_published=dt.date(2016, 9, 5))
        self.events_child2.tags.add('tag 2')

        helpers.save_new_page(self.blog_child1, self.blog_parent)
        helpers.save_new_page(self.blog_child2, self.blog_parent)
        helpers.save_new_page(self.newsroom_child1, self.newsroom_parent)
        helpers.save_new_page(self.newsroom_child2, self.newsroom_parent)
        helpers.save_new_page(self.events_child1, self.events_parent)

        # mock a stream block that dictates how to retrieve the related posts
        # note that because of the way that the related_posts_category_lookup function
        # works i.e. by consulting a hard-coded object, the specific_categories
        # slot of the dict has to be something that it can actually find.

        self.block = mock.MagicMock()
        self.block.block_type = 'related_posts'
        self.block.value = dict({
            'limit': 3,
            'show_heading': True,
            'header_title': 'Further reading',
            'relate_posts': False,
            'relate_newsroom': False,
            'relate_events': False,
            'specific_categories': []
        })