def test_duplicate_slug(self):
        from wagtail.wagtailcore.models import Site
        # Create a test Site with a root page
        root = models.TestRootPage(title='title', depth=1, path='0001', slug_en='slug_en', slug_de='slug_de')
        root.save()

        site = Site(root_page=root)
        site.save()

        # Add children to the root
        child = root.add_child(
            instance=models.TestSlugPage1(title='child1', slug_de='child', slug_en='child-en', depth=2, path='00010001')
        )

        child2 = root.add_child(
            instance=models.TestSlugPage2(title='child2', slug_de='child-2', slug_en='child2-en', depth=2,
                                          path='00010002')
        )

        # Clean should work fine as the two slugs are different
        child2.clean()

        # Make the slug equal to test if the duplicate is detected
        child2.slug_de = 'child'

        self.assertRaises(ValidationError, child2.clean)
Beispiel #2
0
    def test_duplicate_slug(self):
        from wagtail.wagtailcore.models import Site
        # Create a test Site with a root page
        root = models.TestRootPage(title='title', depth=1, path='0001', slug_en='slug_en', slug_de='slug_de')
        root.save()

        site = Site(root_page=root)
        site.save()

        # Add children to the root
        child = root.add_child(
            instance=models.TestSlugPage1(title='child1', slug_de='child', slug_en='child-en', depth=2, path='00010001')
        )

        child2 = root.add_child(
            instance=models.TestSlugPage2(title='child2', slug_de='child-2', slug_en='child2-en', depth=2,
                                          path='00010002')
        )

        # Clean should work fine as the two slugs are different
        child2.clean()

        # Make the slug equal to test if the duplicate is detected
        child2.slug_de = 'child'

        self.assertRaises(ValidationError, child2.clean)
Beispiel #3
0
def root_page():
    """
    Get the global Wagtail root page (cleared of any subpages it might have)
    :return: Root page
    :rtype: wagtail.wagtailcore.models.Page
    """
    try:
        page = Page.objects.get(slug="root", depth=1)
    except Page.DoesNotExist:  # pragma: no cover
        page = Page.objects.create(
            title="Root",
            slug='root',
            content_type=ContentType.objects.get_for_model(Page),
            path='0001',
            depth=1,
            numchild=1,
            url_path='/',
        )

    for child in page.get_children():  # pragma: no cover
        child.delete()
    page.numchild = 0
    page.save(update_fields=("numchild", ))

    site = Site.objects.first()
    if not site:  # pragma: no cover
        site = Site()
    site.root_page = page
    site.is_default_site = True
    site.save()

    return page
Beispiel #4
0
    def test_set_url_path(self):
        from wagtail.wagtailcore.models import Site
        # Create a test Site with a root page
        root = models.TestRootPage(title='url paths', depth=1, path='0006', slug='url-path-slug')
        root.save()

        site = Site(root_page=root)
        site.save()

        # Add children to the root
        child = root.add_child(
            instance=models.TestSlugPage1(title='child', slug='child', depth=2, path='00060001')
        )
        child.save()

        # Add grandchildren to the root
        grandchild = child.add_child(
            instance=models.TestSlugPage1(title='grandchild', slug='grandchild', depth=2, path='000600010001')
        )
        grandchild.save()

        self.assertEqual(child.url_path_de, '/child/')
        self.assertEqual(child.url_path_en, '/child/')
        self.assertEqual(grandchild.url_path_de, '/child/grandchild/')
        self.assertEqual(grandchild.url_path_en, '/child/grandchild/')

        grandchild.slug_de = 'grandchild1'
        grandchild.save()

        self.assertEqual(grandchild.url_path_de, '/child/grandchild1/')
        self.assertEqual(grandchild.url_path_en, '/child/grandchild1/')

        grandchild.slug_en = 'grandchild1_en'
        grandchild.save()

        self.assertEqual(grandchild.url_path_de, '/child/grandchild1/')
        self.assertEqual(grandchild.url_path_en, '/child/grandchild1_en/')

        # Children url paths should update when parent changes
        child.slug_en = 'child_en'
        child.save()

        self.assertEqual(child.url_path_de, '/child/')
        self.assertEqual(child.url_path_en, '/child_en/')

        # We should retrieve grandchild with the below command:
        # grandchild_new = models.TestSlugPage1.objects.get(id=grandchild.id)
        # but it's exhibiting strange behaviour during tests. See:
        # https://github.com/infoportugal/wagtail-modeltranslation/issues/103#issuecomment-352006610
        grandchild_new = models.TestSlugPage1._default_manager.raw("""
            SELECT page_ptr_id, url_path_en, url_path_de FROM {}
            WHERE page_ptr_id=%s LIMIT 1
        """.format(models.TestSlugPage1._meta.db_table), [grandchild.page_ptr_id])[0]
        self.assertEqual(grandchild_new.url_path_en, '/child_en/grandchild1_en/')
        self.assertEqual(grandchild_new.url_path_de, '/child/grandchild1/')
    def test_relative_url(self):
        from wagtail.wagtailcore.models import Site
        # Create a test Site with a root page
        root = models.TestRootPage(title='title slugurl',
                                   depth=1,
                                   path='0004',
                                   slug_en='title_slugurl_en',
                                   slug_de='title_slugurl_de')
        root.save()
        site = Site(root_page=root)
        site.save()

        # Add children to the root
        child = root.add_child(
            instance=models.TestSlugPage1(title='child1 slugurl',
                                          slug_en='child-slugurl-en',
                                          slug_de='child-slugurl-de',
                                          depth=2,
                                          path='00040001'))
        child.save_revision().publish()

        url_1_de = child.relative_url(site)
        self.assertEqual(
            url_1_de, '/de/child-slugurl-de/',
            'When using the default language, slugurl produces the wrong url.')

        trans_real.activate('en')

        url_1_en = child.relative_url(site)
        self.assertEqual(
            url_1_en, '/en/child-slugurl-en/',
            'When using non-default language, slugurl produces the wrong url.')

        # Add children using non-default language
        child2 = root.add_child(
            instance=models.TestSlugPage2(title='child2 slugurl',
                                          title_de='child2 slugurl DE',
                                          slug_de='child2-slugurl-de',
                                          slug_en='child2-slugurl-en',
                                          depth=2,
                                          path='00040002'))
        child2.save_revision().publish()

        url_2_en = child2.relative_url(site)
        self.assertEqual(
            url_2_en, '/en/child2-slugurl-en/',
            'When using non-default language, slugurl produces the wrong url.')

        trans_real.activate('de')

        url_2_de = child2.relative_url(site)
        self.assertEqual(
            url_2_de, '/de/child2-slugurl-de/',
            'When using non-default language, slugurl produces the wrong url.')
Beispiel #6
0
def home_page():
    rp = root_page()
    rp.get_children().delete()
    hp = root_page().add_child(
        instance=FrontPage(title='Test Home', live=True))
    site = Site(hostname='localhost',
                is_default_site=True,
                port=80,
                site_name='Test site',
                root_page=hp)
    site.save()
    return hp
Beispiel #7
0
    def setUp(self):
        p = Page()
        p.title = 'Root Page'
        p.slug = 'root-page'
        p.depth = 0
        p.save()

        s = Site()
        s.root_page = p
        s.is_default_site = True
        s.hostname = 'localhost'
        s.port = 80
        s.save()
Beispiel #8
0
 def _import_pages (self, exported_page_data):
     # Delete any existing pages.
     for page in Page.objects.all():
         page.delete()
     with open(exported_page_data, 'r') as fh:
         page_data = cPickle.load(fh)
     for page_name, info in page_data.items():
         self.logger.debug('Creating page {}'.format(page_name))
         page = info['class'](**info['kwargs'])
         page.save()
         self._pages[page_name] = page
     # Add a Wagtail Site, or nothing will appear anywhere.
     home_page = HomePage.objects.all()[0]
     site = Site(hostname='localhost', root_page=home_page,
                 is_default_site=True)
     site.save()
Beispiel #9
0
 def _import_pages(self, exported_page_data):
     # Delete any existing pages.
     for page in Page.objects.all():
         page.delete()
     with open(exported_page_data, 'r') as fh:
         page_data = cPickle.load(fh)
     for page_name, info in page_data.items():
         self.logger.debug('Creating page {}'.format(page_name))
         page = info['class'](**info['kwargs'])
         page.save()
         self._pages[page_name] = page
     # Add a Wagtail Site, or nothing will appear anywhere.
     home_page = HomePage.objects.all()[0]
     site = Site(hostname='localhost',
                 root_page=home_page,
                 is_default_site=True)
     site.save()
Beispiel #10
0
def run():
    print('Running script \'scripts.initial_data\' ...')
    admin_user = None
    site_root = None
    events = None

    admin_user = User.objects.filter(username='******')
    if not admin_user:
        admin_user = User(username='******',
                          password=make_password(
                              os.environ.get('WAGTAIL_ADMIN_PW')),
                          is_superuser=True,
                          is_active=True,
                          is_staff=True)
        admin_user.save()
    else:
        admin_user = admin_user[0]

    # Creates a new site root `CFGov`
    site_root = HomePage.objects.filter(title='CFGOV')
    if not site_root:
        root = Page.objects.first()
        site_root = HomePage(title='CFGOV',
                             slug='home-page',
                             depth=2,
                             owner=admin_user)
        site_root.live = True
        root.add_child(instance=site_root)
        latest = site_root.save_revision(user=admin_user,
                                         submitted_for_moderation=False)
        latest.save()
    else:
        site_root = site_root[0]

    # Setting new site root
    if not Site.objects.filter(hostname='content.localhost').exists():
        site = Site.objects.first()
        site.port = 8000
        site.root_page_id = site_root.id
        site.save()
        content_site = Site(hostname='content.localhost',
                            port=8000,
                            root_page_id=site_root.id)
        content_site.save()

        # Clean Up
        old_site_root = Page.objects.filter(id=2)[0]
        if old_site_root:
            old_site_root.delete()

    # Events Browse Page required for event `import-data` command
    if not BrowseFilterablePage.objects.filter(title='Events').exists():
        events = BrowseFilterablePage(title='Events',
                                      slug='events',
                                      owner=admin_user)
        site_root.add_child(instance=events)
        revision = events.save_revision(
            user=admin_user,
            submitted_for_moderation=False,
        )
        revision.publish()

    # Archived Events Browse Filterable Page
    if not BrowseFilterablePage.objects.filter(title='Archive').exists():
        archived_events = BrowseFilterablePage(title='Archive',
                                               slug='archive',
                                               owner=admin_user)
        if not events:
            events = BrowseFilterablePage.objects.get(title='Events')

        events.add_child(instance=archived_events)
        revision = archived_events.save_revision(
            user=admin_user,
            submitted_for_moderation=False,
        )
        revision.publish()
def run():
    print 'Running script \'scripts.initial_test_data\' ...'

    admin_user = User.objects.filter(username='******')
    if not admin_user:
        admin_user = User(username='******',
                          password=make_password(os.environ.get('WAGTAIL_ADMIN_PW')),
                          is_superuser=True, is_active=True, is_staff=True)
        admin_user.save()
    else:
        admin_user = admin_user[0]


    # # Creates a new site root `CFGov`
    site_root = HomePage.objects.filter(title='CFGOV')
    if not site_root:
        root = Page.objects.first()
        site_root = HomePage(title='CFGOV', slug='home', depth=2, owner=admin_user)
        site_root.live = True
        root.add_child(instance=site_root)
        latest = site_root.save_revision(user=admin_user, submitted_for_moderation=False)
        latest.save()
    else:
        site_root = site_root[0]

    # Setting new site root
    site = Site.objects.first()
    if site.root_page_id != site_root.id:
        site.port = 8000
        site.root_page_id = site_root.id
        site.save()
        content_site = Site(hostname='content.localhost', port=8000, root_page_id=site_root.id)
        content_site.save()

    def publish_page(child=None, root=site_root):
        try:
            root.add_child(instance=child)
        except NodeAlreadySaved:
            pass
        revision = child.save_revision(
            user=admin_user,
            submitted_for_moderation=False,
        )
        revision.publish()

    # Create snippets
    contact = Contact.objects.filter(heading='Test User')
    if not contact:
        contact = Contact(heading='Test User')
    else:
        contact = contact[0]
    contact.contact_info = StreamValue(contact.contact_info.stream_block,
        [
            atomic.contact_email,
            atomic.contact_phone,
            atomic.contact_address
        ], True)
    contact.save()

    # Create each Page Type
    lap = LandingPage.objects.filter(title='Landing Page')
    if not lap:
        lap = LandingPage(title='Landing Page', slug='landing-page', owner=admin_user)
    else:
        lap = lap[0]
    lap.content = StreamValue(lap.content.stream_block,
        [
            atomic.image_text_25_75_group,
            atomic.image_text_50_50_group,
            atomic.half_width_link_blob_group,
            atomic.well
        ], True)
    lap.sidefoot = StreamValue(lap.sidefoot.stream_block,
        [
            atomic.related_links,
            atomic.sidebar_contact(contact.id)
        ], True)
    publish_page(lap)

    sp = SublandingPage.objects.filter(title='Sublanding Page')
    if not sp:
        sp = SublandingPage(title='Sublanding Page', slug='sublanding-page', owner=admin_user)
    else:
        sp = sp[0]
    sp.content = StreamValue(sp.content.stream_block,
        [
            atomic.main_contact_info(contact.id),
            atomic.reg_comment
        ], True)
    sp.sidefoot = StreamValue(sp.sidefoot.stream_block,
        [
            atomic.email_signup,
            atomic.rss_feed
        ], True)

    publish_page(sp)

    bp = BrowsePage.objects.filter(title='Browse Page')
    if not bp:
        bp = BrowsePage(title='Browse Page', slug='browse-page', owner=admin_user)
    else:
        bp = bp[0]
    bp.header = StreamValue(bp.header.stream_block,
        [
            atomic.featured_content
        ], True)
    bp.content = StreamValue(bp.content.stream_block,
        [
            atomic.expandable,
            atomic.expandable_group
        ], True)
    publish_page(bp)

    # Filterable Pages
    bfp = BrowseFilterablePage.objects.filter(title='Browse Filterable Page')
    if not bfp:
        bfp = BrowseFilterablePage(title='Browse Filterable Page', slug='browse-filterable-page', owner=admin_user)
    else:
        bfp = bfp[0]
    bfp.header = StreamValue(bfp.header.stream_block, [atomic.text_introduction], True)
    publish_page(bfp)

    sfp = SublandingFilterablePage.objects.filter(title='Sublanding Filterable Page')
    if not sfp:
        sfp = SublandingFilterablePage(title='Sublanding Filterable Page', slug='sublanding-filterable-page',
                                       owner=admin_user)
    else:
        sfp = sfp[0]
    sfp.header = StreamValue(sfp.header.stream_block, [atomic.hero], True)
    publish_page(sfp)

    eap = EventArchivePage.objects.filter(title='Event Archive Page')
    if not eap:
        eap = EventArchivePage(title='Event Archive Page', slug='event-archive-page', owner=admin_user)
    else:
        eap = eap[0]
    publish_page(eap)

    nlp = NewsroomLandingPage.objects.filter(title='Newsroom Landing Page')
    if not nlp:
        nlp = NewsroomLandingPage(title='Newsroom Landing Page', slug='newsroom-landing-page', owner=admin_user)
    else:
        nlp = nlp[0]
    publish_page(nlp)

    alp = ActivityLogPage.objects.filter(title='Activity Log Page')
    if not alp:
        alp = ActivityLogPage(title='Activity Log Page', slug='activity-log-page', owner=admin_user)
    else:
        alp = alp[0]
    publish_page(alp)

    # Filter Pages
    if not EventPage.objects.filter(title='Event Page'):
        ep = EventPage(title='Event Page', slug='event-page', owner=admin_user)
        publish_page(ep, bfp)

    ddp = DocumentDetailPage.objects.filter(title='Document Detail Page')
    if not ddp:
        ddp = DocumentDetailPage(title='Document Detail Page', slug='document-detail-page', owner=admin_user)
    else:
        ddp = ddp[0]
    ddp.sidefoot = StreamValue(ddp.sidefoot.stream_block, [atomic.related_metadata], True)
    publish_page(ddp, bfp)

    lp = LearnPage.objects.filter(title='Learn Page')
    if not lp:
        lp = LearnPage(title='Learn Page', slug='learn-page', owner=admin_user)
    else:
        lp = lp[0]
    lp.header = StreamValue(lp.header.stream_block, [atomic.item_introduction], True)
    lp.content = StreamValue(lp.content.stream_block,
        [
            atomic.full_width_text,
            atomic.call_to_action,
            atomic.table
        ], True)
    publish_page(lp, bfp)

    if not NewsroomPage.objects.filter(title='Newsroom Page'):
        np = NewsroomPage(title='Newsroom Page', slug='newsroom-page', owner=admin_user)
        publish_page(np, nlp)

    if not LegacyNewsroomPage.objects.filter(title='Legacy Newsroom Page'):
        lnp = LegacyNewsroomPage(title='Legacy Newsroom Page', slug='legacy-newsroom-page', owner=admin_user)
        publish_page(lnp, nlp)

    if not BlogPage.objects.filter(title='Blog Page'):
        bp = BlogPage(title='Blog Page', slug='blog-page', owner=admin_user)
        publish_page(bp, sfp)

    if not LegacyBlogPage.objects.filter(title='Legacy Blog Page'):
        lbp = LegacyBlogPage(title='Legacy Blog Page', slug='legacy-blog-page', owner=admin_user)
        publish_page(lbp, sfp)


    # Create and configure pages for testing page states
    draft = LandingPage.objects.filter(slug='draft-page')
    if not draft:
        draft = LandingPage(title='Draft Page', slug='draft-page', owner=admin_user, live=False, shared=False)
        site_root.add_child(instance=draft)
    else:
        draft = draft[0]
    draft.save_revision(user=admin_user)

    shared = LandingPage.objects.filter(slug='shared-page')
    if not shared:
        shared = LandingPage(title='Shared Page', slug='shared-page', owner=admin_user, live=False, shared=True)
        site_root.add_child(instance=shared)
    else:
        shared = shared[0]
    shared.save_revision(user=admin_user)

    shared_draft = LandingPage.objects.filter(slug='shared-draft-page')
    if not shared_draft:
        shared_draft = LandingPage(title='Shared Page', slug='shared-draft-page', owner=admin_user, live=False, shared=True)
        site_root.add_child(instance=shared_draft)
    else:
        shared_draft = shared_draft[0]
    shared_draft.save_revision(user=admin_user)
    shared_draft.title = 'Shared Draft Page'
    shared_draft.shared = False
    shared_draft.save()
    shared_draft.save_revision(user=admin_user)

    live = LandingPage.objects.filter(slug='live-page')
    if not live:
        live = LandingPage(title='Live Page', slug='live-page', owner=admin_user, live=True, shared=True)
    else:
        live = live[0]
    publish_page(live)

    livedraft = LandingPage.objects.filter(slug='live-draft-page')
    if not livedraft:
        livedraft = LandingPage(title='Live Draft Page', slug='live-draft-page', owner=admin_user, live=True, shared=True)
    else:
        livedraft = livedraft[0]
    publish_page(livedraft)
    livedraft.live = False
    livedraft.shared = False
    livedraft.title = 'Live Page'
    livedraft.save_revision(user=admin_user)
Beispiel #12
0
def station_post_saved(sender, instance, created, *args, **kwargs):
    """
    Create the basis for the website: set up settings and pages
    that are common.
    """
    if not created:
        return

    # root pages
    root_page = Page.objects.get(id=1)

    homepage = models.Publication(
        title = instance.name,
        slug = instance.slug,
        body = _(
            'If you see this page, then Aircox is running for the station '
            '{station.name}. You might want to change it to a better one. '
        ).format(station = instance),
    )
    root_page.add_child(instance=homepage)

    # Site
    default_site = Site.objects.filter(is_default_site = True).first()
    is_default_site = False
    if default_site and default_site.pk == 1:
        # default website generated by wagtail: disable is_default_site so
        # we can use it for us
        default_site.is_default_site = False
        default_site.save()
        is_default_site = True

    site = Site(
        # /doc/ when a Station is created, a wagtail Site is generated with
        #       default options. User must set the correct localhost afterwards
        hostname = instance.slug + ".local",
        port = 80,
        site_name = instance.name.capitalize(),
        root_page = homepage,
        is_default_site = is_default_site,
    )
    site.save()

    # settings
    website_settings = models.WebsiteSettings(
        site = site,
        station = instance,
        description = _("The website of the {name} radio").format(
            name = instance.name
        ),
        # Translators: tags set by default in <meta> description of the website
        tags = _('radio,{station.name}').format(station = instance)
    )

    # timetable
    timetable = models.TimetablePage(
        title = _('Timetable'),
    )
    homepage.add_child(instance = timetable)

    # list page (search, terms)
    list_page = models.DynamicListPage(
        # title is dynamic: no need to specify
        title = _('Search'),
    )
    homepage.add_child(instance = list_page)
    website_settings.list_page = list_page

    # programs' page: list of programs in a section
    programs = models.Publication(
        title = _('Programs'),
    )
    homepage.add_child(instance = programs)

    section = sections.Region(
        name = _('programs'),
        position = 'post_content',
        page = programs,
    )
    section.save();
    section.add_item(sections.SectionList(
        count = 15,
        title = _('Programs'),
        url_text = _('All programs'),
        model = ContentType.objects.get_for_model(models.ProgramPage),
        related = programs,
    ))

    website_settings.default_programs_page = programs
    website_settings.sync = True

    # logs (because it is a cool feature)
    logs = models.LogsPage(
        title = _('Previously on air'),
        station = instance,
    )
    homepage.add_child(instance = logs)

    # save
    site.save()
    website_settings.save()
Beispiel #13
0
def run():
    print 'Running script \'scripts.initial_test_data\' ...'

    admin_user = User.objects.filter(username='******')
    if not admin_user:
        admin_user = User(username='******',
                          password=make_password(
                              os.environ.get('WAGTAIL_ADMIN_PW')),
                          is_superuser=True,
                          is_active=True,
                          is_staff=True)
        admin_user.save()
    else:
        admin_user = admin_user[0]

    # # Creates a new site root `CFGov`
    site_root = HomePage.objects.filter(title='CFGOV')
    if not site_root:
        root = Page.objects.first()
        site_root = HomePage(title='CFGOV',
                             slug='home',
                             depth=2,
                             owner=admin_user)
        site_root.live = True
        root.add_child(instance=site_root)
        latest = site_root.save_revision(user=admin_user,
                                         submitted_for_moderation=False)
        latest.save()
    else:
        site_root = site_root[0]

    # Setting new site root
    site = Site.objects.first()
    if site.root_page_id != site_root.id:
        site.port = 8000
        site.root_page_id = site_root.id
        site.save()
        content_site = Site(hostname='content.localhost',
                            port=8000,
                            root_page_id=site_root.id)
        content_site.save()

    def publish_page(child=None, root=site_root):
        try:
            root.add_child(instance=child)
        except NodeAlreadySaved:
            pass
        revision = child.save_revision(
            user=admin_user,
            submitted_for_moderation=False,
        )
        revision.publish()

    # Create each Page Type
    contact = Contact.objects.filter(heading='Test User')
    if not contact:
        contact = Contact(heading='Test User')
    else:
        contact = contact[0]
    contact.contact_info = StreamValue(
        contact.contact_info.stream_block, [{
            "type": "email",
            "value": {
                "emails": [{
                    "url": "/",
                    "text": "*****@*****.**"
                }]
            }
        }, {
            "type": "phone",
            "value": {
                "phones": [{
                    "tty": "",
                    "number": "1234567890",
                    "vanity": ""
                }],
                "fax": True
            }
        }, {
            "type": "address",
            "value": {
                "city": "Washington",
                "title": "",
                "label": "Address",
                "state": "DC",
                "street": "123 abc street",
                "zip_code": "20012"
            }
        }], True)
    contact.save()

    lap = LandingPage.objects.filter(title='Landing Page')
    if not lap:
        lap = LandingPage(title='Landing Page',
                          slug='landing-page',
                          owner=admin_user)
    else:
        lap = lap[0]
    lap.content = StreamValue(lap.content.stream_block, [{
        "type": "image_text_25_75_group",
        "value": {
            "heading":
            "Image 25 75 Group",
            "image_texts": [{
                "body": "",
                "has_rule": False,
                "image": {
                    "alt": "",
                    "upload": 84
                },
                "heading": "",
                "links": [{
                    "url": "/",
                    "text": "test"
                }]
            }]
        }
    }, {
        "type": "image_text_50_50_group",
        "value": {
            "heading":
            "Image 50 50 Group",
            "image_texts": [{
                "body": "",
                "links": [{
                    "url": "/",
                    "text": "test"
                }],
                "image": {
                    "alt": "",
                    "upload": 84
                },
                "is_widescreen": False,
                "is_button": False,
                "heading": ""
            }]
        }
    }, {
        "type": "half_width_link_blob_group",
        "value": {
            "link_blobs": [{
                "body": "",
                "heading": "",
                "links": [{
                    "url": "/",
                    "text": "test"
                }]
            }],
            "heading":
            "Half Width Link Blob Group"
        }
    }], True)
    publish_page(lap)

    sp = SublandingPage.objects.filter(title='Sublanding Page')
    if not sp:
        sp = SublandingPage(title='Sublanding Page',
                            slug='sublanding-page',
                            owner=admin_user)
    else:
        sp = sp[0]
    sp.content = StreamValue(sp.content.stream_block, [{
        "type": "contact",
        "value": {
            "body": "",
            "header": "Contact",
            "contact": contact.id
        }
    }], True)
    sp.sidefoot = StreamValue(sp.sidefoot.stream_block, [{
        "type": "email_signup",
        "value": {
            "text":
            "",
            "gd_code":
            "",
            "heading":
            "Email Sign Up",
            "form_field": [{
                "info": "",
                "type": "",
                "required": False,
                "label": "Email Sign up",
                "btn_text": "",
                "placeholder": ""
            }]
        }
    }, {
        "type": "rss_feed",
        "value": "blog_feed"
    }], True)

    publish_page(sp)

    bp = BrowsePage.objects.filter(title='Browse Page')
    if not bp:
        bp = BrowsePage(title='Browse Page',
                        slug='browse-page',
                        owner=admin_user)
    else:
        bp = bp[0]
    bp.header = StreamValue(bp.header.stream_block, [{
        'type': 'featured_content',
        'value': {
            'body': "<p>this is a featured content body</p>"
        }
    }], True)
    bp.content = StreamValue(bp.content.stream_block, [{
        'type': 'expandable',
        'value': {
            'label': 'this is an expandable'
        }
    }], True)
    publish_page(bp)

    # Filterable Pages
    bfp = BrowseFilterablePage.objects.filter(title='Browse Filterable Page')
    if not bfp:
        bfp = BrowseFilterablePage(title='Browse Filterable Page',
                                   slug='browse-filterable-page',
                                   owner=admin_user)
    else:
        bfp = bfp[0]
    bfp.header = StreamValue(bfp.header.stream_block, [{
        'type': 'text_introduction',
        'value': {
            'intro': 'this is an intro'
        }
    }], True)
    publish_page(bfp)

    sfp = SublandingFilterablePage.objects.filter(
        title='Sublanding Filterable Page')
    if not sfp:
        sfp = SublandingFilterablePage(title='Sublanding Filterable Page',
                                       slug='sublanding-filterable-page',
                                       owner=admin_user)
    else:
        sfp = sfp[0]
    sfp.header = StreamValue(sfp.header.stream_block, [{
        'type': 'hero',
        'value': {
            'heading': "this is a hero heading"
        }
    }], True)
    publish_page(sfp)

    eap = EventArchivePage.objects.filter(title='Event Archive Page')
    if not eap:
        eap = EventArchivePage(title='Event Archive Page',
                               slug='event-archive-page',
                               owner=admin_user)
    else:
        eap = eap[0]
    publish_page(eap)

    nlp = NewsroomLandingPage.objects.filter(title='Newsroom Landing Page')
    if not nlp:
        nlp = NewsroomLandingPage(title='Newsroom Landing Page',
                                  slug='newsroom-landing-page',
                                  owner=admin_user)
    else:
        nlp = nlp[0]
    publish_page(nlp)

    # Filter Pages
    if not EventPage.objects.filter(title='Event Page'):
        ep = EventPage(title='Event Page', slug='event-page', owner=admin_user)
        publish_page(ep, bfp)

    ddp = DocumentDetailPage.objects.filter(title='Document Detail Page')
    if not ddp:
        ddp = DocumentDetailPage(title='Document Detail Page',
                                 slug='document-detail-page',
                                 owner=admin_user)
    else:
        ddp = ddp[0]
    ddp.sidefoot = StreamValue(ddp.sidefoot.stream_block, [{
        'type': 'related_metadata',
        'value': {
            'content': [{
                'type': 'text',
                'value': {
                    'heading': 'this is a related metadata heading'
                }
            }]
        }
    }], True)
    publish_page(ddp, bfp)

    lp = LearnPage.objects.filter(title='Learn Page')
    if not lp:
        lp = LearnPage(title='Learn Page', slug='learn-page', owner=admin_user)
    else:
        lp = lp[0]
    lp.content = StreamValue(lp.content.stream_block, [{
        'type':
        'full_width_text',
        'value': [{
            'type': 'quote',
            'value': {
                'body': 'this is a quote',
                'citation': 'a citation'
            }
        }]
    }, {
        'type': 'call_to_action',
        'value': {
            'paragraph_text': 'this is a call to action'
        }
    }], True)
    publish_page(lp, bfp)

    if not ActivityLogPage.objects.filter(title='Activity Log Page'):
        alp = ActivityLogPage(title='Activity Log Page',
                              slug='activity-log-page',
                              owner=admin_user)
        publish_page(alp)

    if not NewsroomPage.objects.filter(title='Newsroom Page'):
        np = NewsroomPage(title='Newsroom Page',
                          slug='newsroom-page',
                          owner=admin_user)
        publish_page(np, nlp)

    if not LegacyNewsroomPage.objects.filter(title='Legacy Newsroom Page'):
        lnp = LegacyNewsroomPage(title='Legacy Newsroom Page',
                                 slug='legacy-newsroom-page',
                                 owner=admin_user)
        publish_page(lnp, nlp)

    if not BlogPage.objects.filter(title='Blog Page'):
        bp = BlogPage(title='Blog Page', slug='blog-page', owner=admin_user)
        publish_page(bp, sfp)

    if not LegacyBlogPage.objects.filter(title='Legacy Blog Page'):
        lbp = LegacyBlogPage(title='Legacy Blog Page',
                             slug='legacy-blog-page',
                             owner=admin_user)
        publish_page(lbp, sfp)

    # Demo Page
    dp = DemoPage.objects.filter(title='Demo Page')
    if not dp:
        dp = DemoPage(title='Demo Page', slug='demo-page', owner=admin_user)
    else:
        dp = dp[0]
    dp.sidefoot = StreamValue(dp.sidefoot.stream_block, [{
        'type': 'related_links',
        'value': {
            'links': [{
                'url': '/url',
                'text': 'this is a related link'
            }]
        }
    }], True)
    publish_page(dp)

    # Create and configure pages for testing page states
    draft = DemoPage.objects.filter(slug='draft-page')
    if not draft:
        draft = DemoPage(title='Draft Page',
                         slug='draft-page',
                         owner=admin_user,
                         live=False,
                         shared=False)
        site_root.add_child(instance=draft)
    else:
        draft = draft[0]
    draft.save_revision(user=admin_user)

    shared = DemoPage.objects.filter(slug='shared-page')
    if not shared:
        shared = DemoPage(title='Shared Page',
                          slug='shared-page',
                          owner=admin_user,
                          live=False,
                          shared=True)
        site_root.add_child(instance=shared)
    else:
        shared = shared[0]
    shared.save_revision(user=admin_user)

    shared_draft = DemoPage.objects.filter(slug='shared-draft-page')
    if not shared_draft:
        shared_draft = DemoPage(title='Shared Page',
                                slug='shared-draft-page',
                                owner=admin_user,
                                live=False,
                                shared=True)
        site_root.add_child(instance=shared_draft)
    else:
        shared_draft = shared_draft[0]
    shared_draft.save_revision(user=admin_user)
    shared_draft.title = 'Shared Draft Page'
    shared_draft.save()
    shared_draft.save_revision(user=admin_user)

    live = DemoPage.objects.filter(slug='live-page')
    if not live:
        live = DemoPage(title='Live Page',
                        slug='live-page',
                        owner=admin_user,
                        live=True,
                        shared=True)
    else:
        live = live[0]
    publish_page(live)

    livedraft = DemoPage.objects.filter(slug='live-draft-page')
    if not livedraft:
        livedraft = DemoPage(title='Live Draft Page',
                             slug='live-draft-page',
                             owner=admin_user,
                             live=True,
                             shared=True)
    else:
        livedraft = livedraft[0]
    publish_page(livedraft)
    livedraft.live = False
    livedraft.shared = False
    livedraft.title = 'Live Page'
    livedraft.save_revision(user=admin_user)