Skip to content

Commit 83364fa

Browse files
committed
Add view: horizontal-rule-view
1 parent 4571f66 commit 83364fa

4 files changed

Lines changed: 117 additions & 0 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# -*- coding: utf-8 -*-
2+
from cs_dynamicpages.testing import CS_DYNAMICPAGES_FUNCTIONAL_TESTING
3+
from cs_dynamicpages.testing import CS_DYNAMICPAGES_INTEGRATION_TESTING
4+
from cs_dynamicpages.views.horizontal_rule_view import IHorizontalRuleView
5+
from plone import api
6+
from plone.app.testing import setRoles
7+
from plone.app.testing import TEST_USER_ID
8+
from zope.component import getMultiAdapter
9+
from zope.interface.interfaces import ComponentLookupError
10+
11+
import unittest
12+
13+
14+
class ViewsIntegrationTest(unittest.TestCase):
15+
16+
layer = CS_DYNAMICPAGES_INTEGRATION_TESTING
17+
18+
def setUp(self):
19+
self.portal = self.layer['portal']
20+
setRoles(self.portal, TEST_USER_ID, ['Manager'])
21+
api.content.create(self.portal, 'Folder', 'other-folder')
22+
api.content.create(self.portal, 'Document', 'front-page')
23+
24+
def test_horizontal_rule_view_is_registered(self):
25+
view = getMultiAdapter(
26+
(self.portal['other-folder'], self.portal.REQUEST),
27+
name='horizontal-rule-view'
28+
)
29+
self.assertTrue(IHorizontalRuleView.providedBy(view))
30+
31+
def test_horizontal_rule_view_not_matching_interface(self):
32+
view_found = True
33+
try:
34+
view = getMultiAdapter(
35+
(self.portal['front-page'], self.portal.REQUEST),
36+
name='horizontal-rule-view'
37+
)
38+
except ComponentLookupError:
39+
view_found = False
40+
else:
41+
view_found = IHorizontalRuleView.providedBy(view)
42+
self.assertFalse(view_found)
43+
44+
45+
class ViewsFunctionalTest(unittest.TestCase):
46+
47+
layer = CS_DYNAMICPAGES_FUNCTIONAL_TESTING
48+
49+
def setUp(self):
50+
self.portal = self.layer['portal']
51+
setRoles(self.portal, TEST_USER_ID, ['Manager'])

src/cs_dynamicpages/views/configure.zcml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66

77
<!-- -*- extra stuff goes here -*- -->
88

9+
<browser:page
10+
name="horizontal-rule-view"
11+
for="*"
12+
class=".horizontal_rule_view.HorizontalRuleView"
13+
template="horizontal_rule_view.pt"
14+
permission="zope2.View"
15+
layer="cs_dynamicpages.interfaces.ICsDynamicpagesLayer"
16+
/>
17+
918
<browser:page
1019
name="dynamic-view"
1120
for="plone.app.contenttypes.interfaces.IFolder"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<html xmlns="http://www.w3.org/1999/xhtml"
2+
xmlns:metal="http://xml.zope.org/namespaces/metal"
3+
xmlns:tal="http://xml.zope.org/namespaces/tal"
4+
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
5+
i18n:domain="cs_dynamicpages"
6+
metal:use-macro="context/main_template/macros/master">
7+
<body>
8+
9+
<metal:custom_title fill-slot="content-title">
10+
<h1 tal:replace="structure context/@@title" />
11+
12+
<!-- @@title view template: -->
13+
<!--
14+
<h1 tal:define="title context/Title" tal:condition="title" tal:content="title">
15+
Title or id
16+
</h1>
17+
-->
18+
19+
</metal:custom_title>
20+
21+
<metal:custom_description fill-slot="content-description">
22+
<p tal:replace="structure context/@@description" />
23+
</metal:custom_description>
24+
25+
<metal:content-core fill-slot="content-core">
26+
<metal:block define-macro="content-core">
27+
28+
<h2>Main content</h2>
29+
<!--<div tal:replace="view/my_custom_view_method" />-->
30+
<!--<div tal:replace="context/my_custom_field" />-->
31+
32+
</metal:block>
33+
</metal:content-core>
34+
</body>
35+
</html>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# from cs_dynamicpages import _
4+
from Products.Five.browser import BrowserView
5+
from zope.interface import implementer
6+
from zope.interface import Interface
7+
8+
# from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
9+
10+
class IHorizontalRuleView(Interface):
11+
""" Marker Interface for IHorizontalRuleView"""
12+
13+
14+
@implementer(IHorizontalRuleView)
15+
class HorizontalRuleView(BrowserView):
16+
# If you want to define a template here, please remove the template from
17+
# the configure.zcml registration of this view.
18+
# template = ViewPageTemplateFile('horizontal_rule_view.pt')
19+
20+
def __call__(self):
21+
# Implement your own actions:
22+
return self.index()

0 commit comments

Comments
 (0)