def setup_content(self):
        t = now()

        self.site_settings, unused = SiteSettings.objects.get_or_create(
            site=self.site,
            defaults=dict(
                base_template='animecon2016_base.jade',
                page_template='animecon2016_page.jade',
                blog_index_template='animecon2016_blog_index.jade',
                blog_post_template='animecon2016_blog_post.jade',
                context_processor_code='site_specific.animecon2016.context_processors:animecon2016_context',
            )
        )

        if not self.site_settings.context_processor_code:
            self.site_settings.context_processor_code = 'site_specific.animecon2016.context_processors:animecon2016_context'
            self.site_settings.save()

        ordering = 0
        for page_slug, page_title, child_pages in [
            ('front-page', 'Dummy etusivu', []),

            # Outside fi subsite for technical reasons
            ('blog', 'Ajankohtaista', []),

            ('fi', 'Animecon 2016', [
                ('front-page', 'Etusivu'),
                ('blog', 'Ajankohtaista'), # pseudo page for menu, actually taken over by blog
                ('tapahtuma', 'Tapahtuma'),
                ('ohjelma', 'Ohjelma'),
                ('liput', 'Liput'),
                ('yhteys', 'Ota yhteyttä!'),
            ]),

            ('en', 'Animecon 2016 in English', [
                ('front-page', 'Front page'),
                ('event', 'Event'),
                ('program', 'Program'),
                ('tickets', 'Tickets'),
                ('contact', 'Contact us!'),
            ]),
        ]:
            ordering += 10

            parent_page, unused = Page.objects.get_or_create(
                site=self.site,
                parent=None,
                slug=page_slug,
                defaults=dict(
                    title=page_title,
                    body='Placeholder for {slug}'.format(slug=page_slug),
                    public_from=t,
                    visible_from=t,
                    order=ordering,
                )
            )

            child_ordering = 0
            for child_slug, child_title in child_pages:
                child_ordering += 10

                child_page, unused = Page.objects.get_or_create(
                    site=self.site,
                    parent=parent_page,
                    slug=child_slug,
                    defaults=dict(
                        title=child_title,
                        body='Placeholder for {slug}'.format(slug=child_slug),
                        public_from=t,
                        visible_from=t,
                        order=child_ordering,
                    )
                )

        programme_page = Page.objects.get(site=self.site, path='fi/ohjelma')
        programme_page.page_controller_code = 'site_specific.animecon2016.views:programme_page_controller'
        programme_page.override_page_template = 'animecon2016_programme_page.jade'
        programme_page.save()

        for path, target in [
            ('admin', '/admin/'),
            ('fi', '/fi/front-page'),
            ('en', '/en/front-page'),
            ('front-page', '/fi/front-page'),
        ]:
            redirect, unused = Redirect.objects.get_or_create(
                site=self.site,
                path=path,
                defaults=dict(
                    target=target
                ),
            )

        for stylesheet_name in [
            'layout.css',
            'style.css',
            'usermenu.css',
        ]:
            stylesheet_path = os.path.join(
                os.path.dirname(__file__),
                '..', '..', 'static', 'animecon2016', 'css',
                stylesheet_name
            )

            with open(stylesheet_path) as input_file:
                StyleSheet.ingest(input_file)
Exemple #2
0
    def setup_content(self):
        t = now()

        self.site_settings, unused = SiteSettings.objects.get_or_create(
            site=self.site,
            defaults=dict(
                base_template='aicon_base.jade',
                page_template='aicon_page.jade',
                blog_index_template='aicon_blog_index.jade',
                blog_post_template='aicon_blog_post.jade',
            )
        )

        self.site_settings.save()

        ordering = 0
        for page_slug, page_title, child_pages in [
            ('front-page', 'Verkatehdas, Hämeenlinna, 8.–9.10.2016', []),
            ('blog', 'Ajankohtaista', []), # pseudo page for menu, actually taken over by blog
            ('tapahtuma', 'Tapahtuma', []),
            ('ohjelma', 'Ohjelma', []),
            ('yhteys', 'Yhteystiedot', [
                ('medialle', 'Medialle'),
                ('sponsoriksi', 'Sponsoriksi'),
            ]),
        ]:
            ordering += 10

            parent_page, unused = Page.objects.get_or_create(
                site=self.site,
                parent=None,
                slug=page_slug,
                defaults=dict(
                    title=page_title,
                    body=lorem(),
                    public_from=t,
                    visible_from=t,
                    order=ordering,
                )
            )

            child_ordering = 0
            for child_slug, child_title in child_pages:
                child_ordering += 10

                child_page, unused = Page.objects.get_or_create(
                    site=self.site,
                    parent=parent_page,
                    slug=child_slug,
                    defaults=dict(
                        title=child_title,
                        body=lorem(),
                        public_from=t,
                        visible_from=t,
                        order=child_ordering,
                    )
                )

        front_page = Page.objects.get(site=self.site, slug='front-page')
        if front_page.title == 'Aicon':
            front_page.title = 'Verkatehdas, Hämeenlinna, 8.–9.10.2016'
        if not front_page.override_menu_text:
            front_page.override_menu_text = 'Etusivu'
        if not front_page.override_page_template:
            front_page.override_page_template = 'aicon_front_page.jade'
        if not front_page.page_controller_code:
            front_page.page_controller_code = 'site_specific.aicon.views:front_page_controller'
        if 'Placeholder for front-page' in front_page.body or 'Lorem ipsum' in front_page.body:
            front_page.body = 'Aicon on aasialaiseen musiikkiin ja muotiin keskittyvä kaksipäiväinen tapahtuma, joka järjestään ensimmäistä kertaa syksyllä 2016. Aicon tarjoaa kävijöilleen monipuolista ohjelmaa ja tekemistä täysin omannäköisellään vivahteella, ja toivottaa kaikki aiheesta kiinnostuneet tervetulleiksi tapahtumaan!'
        front_page.save()

        organizers_page = Page.objects.get(site=self.site, slug='yhteys')
        organizers_page.override_page_template = 'aicon_organizers_page.jade'
        organizers_page.page_controller_code = 'site_specific.aicon.views:organizers_page_controller'
        organizers_page.save()

        programme_page = Page.objects.get(site=self.site, path='ohjelma')
        programme_page.page_controller_code = 'site_specific.aicon.views:programme_page_controller'
        programme_page.override_page_template = 'aicon_programme_page.jade'
        programme_page.save()

        for path, target in [
            ('admin', '/admin/'),
        ]:
            redirect, unused = Redirect.objects.get_or_create(
                site=self.site,
                path=path,
                defaults=dict(
                    target=target
                ),
            )

        if settings.DEBUG:
            d = date.today()

            for blog_title in [
                'Japan-poppia, minun conissani!?!',
                'Aiconin kävijäkysely',
                'Seuraa Aiconia Twitterissä ja Facebookissa!',
            ]:
                blog_post, unused = BlogPost.objects.get_or_create(
                    site=self.site,
                    slug=slugify(blog_title),
                    defaults=dict(
                        date=d,
                        override_excerpt='blaa blaa blaa',
                        title=blog_title,
                        body='Dummy blog post',
                        public_from=t,
                        visible_from=t,
                    )
                )

        for stylesheet_name in [
            'aicon.css',
            'aicon_tracontent.css',
        ]:
            stylesheet_path = os.path.join(
                os.path.dirname(__file__),
                '..', '..', 'static', 'aicon', 'css',
                stylesheet_name
            )

            with open(stylesheet_path) as input_file:
                StyleSheet.ingest(input_file)