예제 #1
0
 def setUp(self):
     self.layout_1 = G(
         Layout,
         template_name='layout_page/layoutpage/layouts/default.html',
     )
     self.layout_1.content_types.add(
         ContentType.objects.get_for_model(LayoutPage))
     self.layout_1.save()
     self.staff_1 = User.objects.create(
         email='*****@*****.**',
         is_staff=True,
         is_active=True,
         is_superuser=True,
     )
     self.page_1 = LayoutPage()
     self.page_1.title = 'Test Page'
     self.page_1.slug = 'test-page'
     self.page_1.parent_site = Site.objects.first()
     self.page_1.layout = self.layout_1
     self.page_1.author = self.staff_1
     self.page_1.status = 'p'  # Publish the page
     self.page_1.save()
     self.anchor_1 = fluent_contents.create_content_instance(
         models.PageAnchorItem, self.page_1, anchor_name='Jump Link')
     self.anchor_2 = fluent_contents.create_content_instance(
         models.PageAnchorItem, self.page_1, anchor_name='Second Jump Link')
     self.page_1.publish()
     self.page_1_published = self.page_1.get_published()
예제 #2
0
 def setUp(self):
     self.normal_user = G(User)
     self.super_user = G(
         User,
         is_staff=True,
         is_active=True,
         is_superuser=True,
     )
     self.layout = G(
         Layout,
         template_name='icekit/layouts/default.html',
     )
     # LayoutPage is a PublishingModel
     self.layoutpage = LayoutPage.objects.create(
         author=self.super_user,
         title='Test LayoutPage',
         layout=self.layout,
     )
     self.content_instance = fluent_contents.create_content_instance(
         RawHtmlItem, self.layoutpage, html='<b>test content instance</b>')
     # UnpublishableLayoutPage is not a PublishingModel
     self.unpublishablelayoutpage = UnpublishableLayoutPage.objects.create(
         author=self.super_user,
         title='Test Unpublishable LayoutPage',
         layout=self.layout,
         status=UrlNode.DRAFT,
     )
     self.content_instance = fluent_contents.create_content_instance(
         RawHtmlItem,
         self.unpublishablelayoutpage,
         html='<b>test content instance</b>')
예제 #3
0
 def setUp(self):
     self.layout_1 = G(
         Layout,
         template_name='layout_page/layoutpage/layouts/default.html',
     )
     self.layout_1.content_types.add(
         ContentType.objects.get_for_model(LayoutPage))
     self.layout_1.save()
     self.staff_1 = User.objects.create(
         email='*****@*****.**',
         is_staff=True,
         is_active=True,
         is_superuser=True,
     )
     self.page_1 = LayoutPage.objects.create(
         title='Test Page',
         slug='test-page',
         parent_site=Site.objects.first(),
         layout=self.layout_1,
         author=self.staff_1,
         status='p',  # Publish the page
     )
     self.instagram_1 = fluent_contents.create_content_instance(
         models.InstagramEmbedItem,
         self.page_1,
         url='http://instagram.com/p/adasdads')
     self.instagram_2 = fluent_contents.create_content_instance(
         models.InstagramEmbedItem,
         self.page_1,
         url='https://instagram.com/p/6NqtLDqdXD')
     self.instagram_3 = fluent_contents.create_content_instance(
         models.InstagramEmbedItem,
         self.page_1,
         url='https://instagram.com/p/5O26siFtv8/')
예제 #4
0
 def setUp(self):
     self.layout_1 = G(
         Layout,
         template_name='layout_page/layoutpage/layouts/default.html',
     )
     self.layout_1.content_types.add(
         ContentType.objects.get_for_model(LayoutPage))
     self.layout_1.save()
     self.staff_1 = User.objects.create(
         email='*****@*****.**',
         is_staff=True,
         is_active=True,
         is_superuser=True,
     )
     self.page_1 = LayoutPage.objects.create(
         title='Test Page',
         slug='test-page',
         parent_site=Site.objects.first(),
         layout=self.layout_1,
         author=self.staff_1,
         status='p',  # Publish the page
     )
     self.page_2 = LayoutPage.objects.create(
         title='Test Page 2',
         slug='test-page-2',
         parent_site=Site.objects.first(),
         layout=self.layout_1,
         author=self.staff_1,
         status='p',  # Publish the page
     )
     self.page_3 = LayoutPage.objects.create(
         title='Test Page 3',
         slug='test-page-3',
         parent_site=Site.objects.first(),
         layout=self.layout_1,
         author=self.staff_1,
         status='p',  # Publish the page
         parent=self.page_2,
     )
     self.page_4 = LayoutPage.objects.create(
         title='Test Page 4',
         slug='test-page-4',
         parent_site=Site.objects.first(),
         layout=self.layout_1,
         author=self.staff_1,
         status='p',  # Publish the page
         parent=self.page_2,
     )
     self.child_page_1 = fluent_contents.create_content_instance(
         models.ChildPageItem,
         self.page_1,
     )
     self.child_page_2 = fluent_contents.create_content_instance(
         models.ChildPageItem,
         self.page_2,
     )
예제 #5
0
    def setUp(self):
        self.super_user_1 = G(
            User,
            is_staff=True,
            is_active=True,
            is_superuser=True,
        )
        self.image_1 = G(Image)
        self.page_layout_1 = G(PageLayout)
        self.media_category_1 = G(models.MediaCategory)
        self.layout_1 = G(
            models.Layout,
            template_name='icekit/layouts/default.html',
        )
        self.response_page_1 = G(
            ResponsePage,
            type='404',
            is_active=True,
        )
        self.response_page_2 = G(
            ResponsePage,
            type='500',
            is_active=True,
        )

        self.placeholder_1 = Placeholder.objects.create_for_object(
            self.response_page_1,
            'response_page'
        )
        self.placeholder_1 = Placeholder.objects.create_for_object(
            self.response_page_2,
            'response_page'
        )

        self.layoutpage_1 = LayoutPage.objects.create(
            author=self.super_user_1,
            title='Test LayoutPage',
            layout=self.layout_1,
        )
        self.content_instance_1 = fluent_contents.create_content_instance(
            RawHtmlItem,
            self.layoutpage_1,
            html='<b>test 1</b>'
        )
        self.content_instance_2 = fluent_contents.create_content_instance(
            RawHtmlItem,
            self.layoutpage_1,
            html='<b>test 2</b>'
        )
        self.content_instance_3 = fluent_contents.create_content_instance(
            RawHtmlItem,
            self.layoutpage_1,
            html='<b>test 3</b>'
        )
예제 #6
0
    def setUp(self):
        self.super_user_1 = G(
            User,
            is_staff=True,
            is_active=True,
            is_superuser=True,
        )
        self.layout = G(
            Layout,
            template_name='layout_page/layoutpage/layouts/default.html',
        )
        self.layout.content_types.add(
            ContentType.objects.get_for_model(LayoutPage))
        self.page_1 = LayoutPage.objects.create(
            title='Test Title',
            author=self.super_user_1,
            status='p',
            layout=self.layout,
        )

        self.image_1 = G(models.Image)

        self.image_item_1 = fluent_contents.create_content_instance(
            models.ImageItem,
            self.page_1,
            image=self.image_1,
        )
예제 #7
0
 def setUp(self):
     self.layout_1 = G(
         Layout,
         template_name='layout_page/layoutpage/layouts/default.html',
     )
     self.layout_1.content_types.add(ContentType.objects.get_for_model(LayoutPage))
     self.layout_1.save()
     self.staff_1 = User.objects.create(
         email='*****@*****.**',
         is_staff=True,
         is_active=True,
         is_superuser=True,
     )
     self.page_1 = LayoutPage.objects.create(
         title='Test Page',
         slug='test-page',
         parent_site=Site.objects.first(),
         layout=self.layout_1,
         author=self.staff_1,
         status='p',  # Publish the page
     )
     self.file = G(models.File)
     self.file_2 = G(
         models.File,
         ignore_fields=['title', ],
     )
     self.file_item = fluent_contents.create_content_instance(
         models.FileItem,
         self.page_1,
         file=self.file
     )
예제 #8
0
    def setUp(self):
        self.super_user_1 = G(
            User,
            is_staff=True,
            is_active=True,
            is_superuser=True,
        )
        self.layout = G(
            Layout,
            template_name='layout_page/layoutpage/layouts/default.html',
        )
        self.layout.content_types.add(
            ContentType.objects.get_for_model(LayoutPage))
        self.page_1 = LayoutPage.objects.create(
            title='Test Title',
            author=self.super_user_1,
            status='p',
            layout=self.layout,
        )

        self.image_1 = G(models.Image)

        self._image_name = setup_with_context_manager(
            self, get_test_image(self.image_1.image.storage)
        )  # context is automatically exited on teardown.

        self.image_1.image = self._image_name
        self.image_1.save()

        self.image_item_1 = fluent_contents.create_content_instance(
            models.ImageItem,
            self.page_1,
            image=self.image_1,
        )
예제 #9
0
    def setUp(self):
        super(PagesAPITests, self).setUp()

        self.layout_1 = G(
            models.Layout,
            template_name='icekit/layouts/default.html',
        )
        self.layoutpage_1 = LayoutPage.objects.create(
            author=self.superuser,
            title='Test LayoutPage',
            layout=self.layout_1,
        )
        self.content_instance_1 = fluent_contents.create_content_instance(
            RawHtmlItem, self.layoutpage_1, html='<b>test 1</b>')
        self.content_instance_2 = fluent_contents.create_content_instance(
            RawHtmlItem, self.layoutpage_1, html='<b>test 2</b>')
        self.content_instance_3 = fluent_contents.create_content_instance(
            RawHtmlItem, self.layoutpage_1, html='<b>test 3</b>')
예제 #10
0
 def test_incorrect_declaration_on_item(self):
     initial_count = FAQItem.objects.count()
     with self.assertRaises(Exception):
         self.faq_item_1 = fluent_contents.create_content_instance(
             FAQItem,
             self.page_1,
             fake='test answer',
         )
     self.assertEqual(FAQItem.objects.count(), initial_count)
예제 #11
0
    def test_descriptor(self):
        self.assertIsInstance(FluentPage.slots, descriptors.PlaceholderDescriptor)
        self.assertFalse(hasattr(self.page_1.slots, 'main'))
        horizontal_rule_1 = fluent_contents.create_content_instance(
            HorizontalRuleItem,
            self.page_1
        )
        self.assertEqual(self.page_1.slots.main.count(), 1)
        with self.assertRaises(AttributeError):
            getattr(self.page_1.slots, 'fake_slot')
        horizontal_rule_1.delete()
        self.assertEqual(self.page_1.slots.main.count(), 0)

        # Test that the same object is not returned. For context, we have had previous issues with
        # slots which were bound to class objects and cached across instances.
        self.assertNotEqual(self.page_1.slots, self.page_1.slots)
예제 #12
0
    def test_get_slot_contents(self):
        descriptors.contribute_to_class(LayoutPage)
        layout_1 = G(
            models.Layout,
            template_name='icekit/layouts/test_slot_contents.html',
        )
        layout_1.content_types.add(
            ContentType.objects.get_for_model(LayoutPage))
        layout_1.save()
        staff_1 = User.objects.create(
            email='*****@*****.**',
            is_staff=True,
            is_active=True,
            is_superuser=True,
        )

        page_1 = LayoutPage.objects.create(
            title='Test Page',
            slug='test-page',
            parent_site=Site.objects.first(),
            layout=layout_1,
            author=staff_1,
        )

        hr = fluent_contents.create_content_instance(
            HorizontalRuleItem,
            page_1,
            placeholder_name='test-main',
        )
        # Publish the page
        page_1.publish()

        response = self.app.get(page_1.get_published().get_absolute_url())

        response.mustcontain('<div class="filter">Horizontal Rule</div>')
        response.mustcontain('<div class="tag-as"></div>')
        response.mustcontain('<div class="tag-render">Horizontal Rule</div>')
        response.mustcontain('<div class="tag-fake-slot"></div>')
        response.mustcontain('<div class="tag-fake-slot-render">None</div>')
        response.mustcontain('div class="filter-fake-slot">None</div>')
예제 #13
0
    def setUp(self):
        self.share_url = 'https://www.google.com.au/maps/place/Chippen+St,' \
            '+Chippendale+NSW+2008/@-33.8877043,151.2005881,17z/data=!4m' \
            '7!1m4!3m3!1s0x6b12b1d86f0291cf:0x74b2d18fb93fed35!2sChippen' \
            '+St,+Chippendale+NSW+2008!3b1!3m1!1s0x6b12b1d86f0291cf:0x74' \
            'b2d18fb93fed35'
        self.layout_1 = G(
            Layout,
            template_name='layout_page/layoutpage/layouts/default.html',
        )
        self.layout_1.content_types.add(
            ContentType.objects.get_for_model(LayoutPage))
        self.layout_1.save()
        self.staff_1 = User.objects.create(
            email='*****@*****.**',
            is_staff=True,
            is_active=True,
            is_superuser=True,
        )
        self.page_1 = LayoutPage()
        self.page_1.title = 'Test Page'
        self.page_1.slug = 'test-page'
        self.page_1.parent_site = Site.objects.first()
        self.page_1.layout = self.layout_1
        self.page_1.author = self.staff_1
        self.page_1.status = 'p'  # Publish the page
        self.page_1.save()
        self.map_1 = fluent_contents.create_content_instance(
            models.MapItem, self.page_1, share_url=self.share_url)
        self.map_1.parse_share_url()

        self.map_item = models.MapItem(
            parent_type=ContentType.objects.get_for_model(type(self.page_1)),
            parent_id=self.page_1.id,
            placeholder=self.page_1.get_placeholder_by_slot('main')[0],
            share_url=self.share_url,
        )

        self.page_1.publish()
예제 #14
0
    def test_google_map_share_url_parsing(self):
        map_detailed_share_url = fluent_contents.create_content_instance(
            models.MapItem,
            self.page_1,
            share_url=
            'https://www.google.com.au/maps/place/The+Interaction+Consortium/'
            '@-33.8884315,151.2006512,17z/data=!3m1!4b1!4m2!3m1!1s0x6b12b1d842ee9aa9:'
            '0xb0a19ac433ef0be8')
        self.assertEqual('The+Interaction+Consortium',
                         map_detailed_share_url.place_name)
        self.assertEqual('-33.8884315,151.2006512,17z',
                         map_detailed_share_url.loc)

        map_embed_url = fluent_contents.create_content_instance(
            models.MapItem,
            self.page_1,
            share_url=
            'https://www.google.com/maps/d/embed?mid=zLFp8zmG_u7Y.kWM6FxvhXeUw',
        )
        self.assertEqual('Unknown', map_embed_url.place_name)
        self.assertEqual('', map_embed_url.loc)

        # Edit URL converted to embed version
        map_viewer_share_url = fluent_contents.create_content_instance(
            models.MapItem,
            self.page_1,
            share_url=
            'https://www.google.com/maps/d/edit?mid=zLFp8zmG_u7Y.kWM6FxvhXeUw&usp=sharing',
        )
        self.assertEqual(
            'https://www.google.com/maps/d/embed?mid=zLFp8zmG_u7Y.kWM6FxvhXeUw&usp=sharing',
            map_viewer_share_url.share_url)
        self.assertEqual('Unknown', map_viewer_share_url.place_name)
        self.assertEqual('', map_viewer_share_url.loc)

        # Viewer URL converted to embed version
        map_viewer_share_url = fluent_contents.create_content_instance(
            models.MapItem,
            self.page_1,
            share_url=
            'https://www.google.com/maps/d/u/0/viewer?mid=zLFp8zmG_u7Y.kWM6FxvhXeUw',
        )
        self.assertEqual(
            'https://www.google.com/maps/d/embed?mid=zLFp8zmG_u7Y.kWM6FxvhXeUw',
            map_viewer_share_url.share_url)
        self.assertEqual('Unknown', map_viewer_share_url.place_name)
        self.assertEqual('', map_viewer_share_url.loc)

        # Shortened URL converted to full version
        with patch(
                'icekit.plugins.map.abstract_models.urlopen') as mock_urlopen:
            # Fake URL lookup and redirect to get un-shortened URL
            mock_urlopen.return_value.url = (
                'https://www.google.com.au/maps/place/The+Interaction+Consortium/'
                '@-33.8884315,151.2006512,17z/data=!3m1!4b1!4m2!3m1!1s0x6b12b1d842ee9aa9:'
                '0xb0a19ac433ef0be8')

            map_shortened_share_url = fluent_contents.create_content_instance(
                models.MapItem,
                self.page_1,
                share_url='https://goo.gl/maps/P4Mlm',
            )
        self.assertEqual(
            'https://www.google.com.au/maps/place/The+Interaction+Consortium/'
            '@-33.8884315,151.2006512,17z/data=!3m1!4b1!4m2!3m1!1s0x6b12b1d842ee9aa9:'
            '0xb0a19ac433ef0be8', map_shortened_share_url.share_url)
        self.assertEqual('The+Interaction+Consortium',
                         map_detailed_share_url.place_name)
        self.assertEqual('-33.8884315,151.2006512,17z',
                         map_detailed_share_url.loc)

        # Unrecognised share URL rejected
        with self.assertRaises(exceptions.ValidationError):
            fluent_contents.create_content_instance(
                models.MapItem,
                self.page_1,
                share_url='https://www.google.com/',
            )
예제 #15
0
 def setUp(self):
     self.site, __ = Site.objects.get_or_create(pk=1,
                                                defaults={
                                                    'name': 'example.com',
                                                    'domain': 'example.com'
                                                })
     self.user_1 = G(User)
     self.form_1 = G(Form)
     if apps.is_installed('icekit.plugins.brightcove'):
         self.brightcove_video_1 = G(BrightcoveItems)
     self.image_1 = G(Image)
     self.page_layout_1 = G(PageLayout)
     self.layout_1 = G(
         models.Layout,
         template_name='icekit/layouts/default.html',
     )
     self.layout_1.content_types.add(
         ContentType.objects.get_for_model(FluentPage))
     self.page_1 = FluentPage.objects.create(
         author=self.user_1,
         title='Test title',
         layout=self.page_layout_1,
     )
     if apps.is_installed('icekit.plugins.brightcove'):
         self.brightcove_item_1 = fluent_contents.create_content_instance(
             BrightcoveItem,
             self.page_1,
             video=self.brightcove_video_1,
         )
     self.image_item_1 = fluent_contents.create_content_instance(
         ImageItem,
         self.page_1,
         image=self.image_1,
     )
     self.faq_item_1 = fluent_contents.create_content_instance(
         FAQItem,
         self.page_1,
         question='test question',
         answer='test answer',
     )
     self.quote_item_1 = fluent_contents.create_content_instance(
         QuoteItem,
         self.page_1,
         quote='test quote',
     )
     self.slide_show_1 = G(SlideShow)
     self.slide_show_item_1 = fluent_contents.create_content_instance(
         SlideShowItem,
         self.page_1,
         slide_show=self.slide_show_1,
     )
     self.twitter_response_1 = fluent_contents.create_content_instance(
         TwitterEmbedItem,
         self.page_1,
         twitter_url='http://twitter.com/asdf/status/sdfsdfsdf')
     self.instagram_embed_1 = fluent_contents.create_content_instance(
         InstagramEmbedItem,
         self.page_1,
         url='http://instagram.com/p/adasdads')
     self.reusable_form_1 = fluent_contents.create_content_instance(
         FormItem,
         self.page_1,
         form=self.form_1,
     )
     self.map_1 = fluent_contents.create_content_instance(
         MapItem,
         self.page_1,
         share_url=
         'https://www.google.com.au/maps/place/The+Interaction+Consortium/'
         '@-33.8884315,151.2006512,17z/data=!3m1!4b1!4m2!3m1!1s0x6b12b1d842ee9aa9:'
         '0xb0a19ac433ef0be8')
     self.map_with_text_1 = fluent_contents.create_content_instance(
         MapWithTextItem,
         self.page_1,
         share_url=
         'https://www.google.com.au/maps/place/The+Interaction+Consortium/'
         '@-33.8884315,151.2006512,17z/data=!3m1!4b1!4m2!3m1!1s0x6b12b1d842ee9aa9:'
         '0xb0a19ac433ef0be8')
     self.horizontal_rule_1 = fluent_contents.create_content_instance(
         HorizontalRuleItem, self.page_1)