Exemplo n.º 1
0
    def test_default_template_show_children_plugins(self):
        placeholder = get_page_placeholders(
            self.page,
            self.language,
        ).get(slot='content')

        plugin = add_plugin(
            placeholder,
            'HtmlLink',
            language=self.language,
            url=self.url,
            label='Test URL plugin',
        )
        add_plugin(
            placeholder,
            'TextPlugin',
            language=self.language,
            target=plugin,
            body='Children plugin 1',
        )

        with self.login_user_context(self.superuser):
            response = self.client.get(self.page.get_absolute_url())

        self.assertNotContains(response, 'Test URL plugin')
        self.assertContains(response, 'Children plugin 1')
Exemplo n.º 2
0
 def setUp(self):
     self.language = "en"
     self.superuser = self.get_superuser()
     self.page = self._create_page(title="test", language=self.language)
     self.placeholder = get_page_placeholders(
         self.page, self.language).get(slot="content")
     self.default_site = Site.objects.first()
     self.site2 = Site.objects.create(name="foo.com", domain="foo.com")
     self.page2 = self._create_page(title="test2",
                                    language=self.language,
                                    site=self.site2)
     self.url = self._create_url(content_object=self.page)
     self.url2 = self._create_url(manual_url="https://example.com/",
                                  site=self.site2)
     self.url_queryset_published = UrlModel.objects.all()
     self.url_queryset = UrlModel._base_manager.all()
     self.poll = Poll.objects.create(name="Test poll")
     self.poll_content = PollContent.objects.create(poll=self.poll,
                                                    language=self.language,
                                                    text="example")
     self.poll_content2 = PollContent.objects.create(poll=self.poll,
                                                     language=self.language,
                                                     text="example2")
     self.page_contenttype_id = ContentType.objects.get_for_model(Page).id
     self.poll_content_contenttype_id = ContentType.objects.get_for_model(
         PollContent).id
     self.url_admin = UrlAdmin(UrlModel, admin)
     self.url_admin_request = RequestFactory().get(
         "/admin/djangocms_url_manager")
Exemplo n.º 3
0
    def test_default_template_show_children_plugins(self):
        placeholder = get_page_placeholders(self.page,
                                            self.language).get(slot="content")
        url_version = self.url.versions.last()
        url_version.publish(user=self.superuser)

        plugin = add_plugin(
            placeholder,
            "HtmlLink",
            language=self.language,
            url_grouper=self.url.url_grouper,
            label="Test URL plugin",
        )
        add_plugin(
            placeholder,
            "TextPlugin",
            language=self.language,
            target=plugin,
            body="Children plugin 1",
        )

        with self.login_user_context(self.superuser):
            response = self.client.get(self.page.get_absolute_url())

        self.assertNotContains(response, "Test URL plugin")
        self.assertContains(response, "Children plugin 1")
Exemplo n.º 4
0
 def test_urlplugin_str(self):
     placeholder = get_page_placeholders(self.page,
                                         self.language).get(slot="content")
     plugin = add_plugin(
         placeholder,
         "HtmlLink",
         language=self.language,
         url=self.url,
         label="Test URL plugin",
     )
     self.assertEqual(str(plugin), plugin.label)
Exemplo n.º 5
0
 def test_urlplugin_str(self):
     placeholder = get_page_placeholders(
         self.page,
         self.language,
     ).get(slot='content')
     plugin = add_plugin(
         placeholder,
         'HtmlLink',
         language=self.language,
         url=self.url,
         label='Test URL plugin',
     )
     self.assertEqual(str(plugin), plugin.label)
Exemplo n.º 6
0
    def test_get_render_template(self):
        placeholder = get_page_placeholders(self.page,
                                            self.language).get(slot="content")

        plugin = add_plugin(
            placeholder,
            "HtmlLink",
            language=self.language,
            url=self.url,
            label="Test URL plugin",
        )

        self.assertEqual(
            HtmlLink().get_render_template({}, plugin, placeholder),
            "djangocms_url_manager/default/url.html",
        )
Exemplo n.º 7
0
    def test_default_template_show_label_when_no_children_plugins(self):
        placeholder = get_page_placeholders(self.page,
                                            self.language).get(slot="content")

        add_plugin(
            placeholder,
            "HtmlLink",
            language=self.language,
            url=self.url,
            label="Test URL plugin",
        )

        with self.login_user_context(self.superuser):
            response = self.client.get(self.page.get_absolute_url())

        self.assertContains(response, "Test URL plugin")
Exemplo n.º 8
0
    def test_get_render_template(self):
        placeholder = get_page_placeholders(
            self.page,
            self.language,
        ).get(slot='content')

        plugin = add_plugin(
            placeholder,
            'HtmlLink',
            language=self.language,
            url=self.url,
            label='Test URL plugin',
        )

        self.assertEqual(
            HtmlLink().get_render_template({}, plugin, placeholder),
            'djangocms_url_manager/default/url.html',
        )
Exemplo n.º 9
0
 def setUp(self):
     self.language = 'en'
     self.superuser = self.get_superuser()
     self.page = self._create_page(
         title='test',
         language=self.language,
     )
     self.placeholder = get_page_placeholders(
         self.page,
         self.language,
     ).get(slot='content')
     self.default_site = Site.objects.first()
     self.site2 = Site.objects.create(
         name='foo.com',
         domain='foo.com',
     )
     self.page2 = self._create_page(
         title='test2',
         language=self.language,
         site=self.site2,
     )
     self.url = self._create_url(content_object=self.page, )
     self.url2 = self._create_url(
         manual_url='https://example.com/',
         site=self.site2,
     )
     self.poll = Poll.objects.create(name='Test poll')
     self.poll_content = PollContent.objects.create(poll=self.poll,
                                                    language=self.language,
                                                    text='example')
     self.poll_content2 = PollContent.objects.create(
         poll=self.poll,
         language=self.language,
         text='example2',
     )
     self.page_contenttype_id = ContentType.objects.get_for_model(Page).id
     self.poll_content_contenttype_id = ContentType.objects.get_for_model(
         PollContent).id
Exemplo n.º 10
0
 def setUp(self):
     self.language = "en"
     self.superuser = self.get_superuser()
     self.page = self._create_page(title="test", language=self.language)
     self.placeholder = get_page_placeholders(
         self.page, self.language).get(slot="content")
     self.default_site = Site.objects.first()
     self.site2 = Site.objects.create(name="foo.com", domain="foo.com")
     self.page2 = self._create_page(title="test2",
                                    language=self.language,
                                    site=self.site2)
     self.url = self._create_url(content_object=self.page)
     self.url2 = self._create_url(manual_url="https://example.com/",
                                  site=self.site2)
     self.poll = Poll.objects.create(name="Test poll")
     self.poll_content = PollContent.objects.create(poll=self.poll,
                                                    language=self.language,
                                                    text="example")
     self.poll_content2 = PollContent.objects.create(poll=self.poll,
                                                     language=self.language,
                                                     text="example2")
     self.page_contenttype_id = ContentType.objects.get_for_model(Page).id
     self.poll_content_contenttype_id = ContentType.objects.get_for_model(
         PollContent).id