add object for homenews (copy from tabellio.pcfviews)

This commit is contained in:
Frédéric Péters 2016-05-06 09:08:36 +02:00
parent 33e5c76770
commit 61f750a223
7 changed files with 172 additions and 0 deletions

View File

@ -8,6 +8,14 @@
<grok:grok package="." />
<five:registerPackage package="." initialize=".initialize" />
<i18n:registerTranslations directory="locales" />
<browser:view
for=".homenews.IHomeNews"
name="pic"
class=".homenews.PictureView"
permission="zope2.View"
/>
<browser:page
for="tabellio.pfbviews.IHemicycleDocument"

View File

@ -0,0 +1,34 @@
from five import grok
from zope import schema
from zope.interface import implements
from z3c.relationfield.schema import RelationChoice
from Products.Five import BrowserView
from plone.directives import form, dexterity
from plone.dexterity.content import Item
from plone.formwidget.contenttree import ObjPathSourceBinder
from plone.app.textfield import RichText
from plone.namedfile.field import NamedImage
from tabellio.pcfviews import MessageFactory as _
class IHomeNews(form.Schema):
picture = NamedImage(title=_(u'Picture'), required=False)
homepage_text = RichText(title=_(u'Homepage Text'), required=True)
text = RichText(title=_(u'Text'), required=False)
on_homepage = schema.Bool(title=_(u'Include on homepage'), default=True)
class HomeNews(Item):
implements(IHomeNews)
class View(grok.View):
grok.context(IHomeNews)
grok.require('zope2.View')
class PictureView(BrowserView):
def __call__(self):
if not self.context.picture:
return None
self.request.response.setHeader('Content-type', self.context.picture.contentType)
return self.context.picture.data

View File

@ -0,0 +1,31 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
lang="en"
metal:use-macro="context/main_template/macros/master"
i18n:domain="tabellio.webviews">
<body>
<metal:main fill-slot="main">
<tal:main-macro metal:define-macro="main">
<div tal:replace="structure provider:plone.abovecontenttitle" />
<h1 class="documentFirstHeading"><span tal:content="context/title"/></h1>
<div tal:replace="structure provider:plone.belowcontenttitle" />
<p class="description" tal:content="context/description">
Lorem
</p>
<div tal:condition="context/text">
<div tal:content="structure context/text/output"/>
</div>
<div tal:replace="structure provider:plone.belowcontentbody" />
</tal:main-macro>
</metal:main>
</body>
</html>

View File

@ -0,0 +1,40 @@
msgid ""
msgstr ""
"Project-Id-Version: tabellio.ppfbviews 1.0\n"
"POT-Creation-Date: 2011-11-06 10:06+0000\n"
"PO-Revision-Date: 2016-05-06 09:07+0200\n"
"Last-Translator: Frederic Peters <fpeters@entrouvert.com>\n"
"Language-Team: French <@>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0\n"
"Language-Code: fr\n"
"Language-Name: French\n"
"Preferred-Encodings: utf-8 latin1\n"
"Domain: tabellio.ppfbviews\n"
#: ./profiles/default/types/tabellio.ppfbviews.homenews.xml
msgid "A news for the homepage news tab"
msgstr "Une actualité pour l'onglet de la page d'accueil"
#: ./profiles/default/types/tabellio.ppfbviews.homenews.xml
msgid "Home News"
msgstr "Actualité sur l'accueil"
#: ./homenews.py:17
msgid "Homepage Text"
msgstr "Texte pour la page d'accueil"
#: ./homenews.py:19
msgid "Include on homepage"
msgstr "Inclure sur la page d'accueil"
#: ./homenews.py:16
msgid "Picture"
msgstr "Image"
#: ./homenews.py:18
msgid "Text"
msgstr "Texte"

View File

@ -0,0 +1,4 @@
<?xml version="1.0"?>
<metadata>
<version>1000</version>
</metadata>

View File

@ -0,0 +1,4 @@
<object name="portal_types">
<object name="tabellio.pfbviews.homenews" meta_type="Dexterity FTI" />
</object>

View File

@ -0,0 +1,51 @@
<?xml version="1.0"?>
<object name="tabellio.pfbviews.homenews" meta_type="Dexterity FTI"
i18n:domain="tabellio.pfbviews" xmlns:i18n="http://xml.zope.org/namespaces/i18n">
<!-- Basic metadata -->
<property name="title" i18n:translate="">Home News</property>
<property name="description" i18n:translate="">A news for the homepage news tab</property>
<property name="content_icon">document_icon.gif</property>
<property name="allow_discussion">False</property>
<property name="global_allow">True</property>
<property name="filter_content_types">True</property>
<property name="allowed_content_types" />
<!-- schema interface -->
<property name="schema">tabellio.pfbviews.homenews.IHomeNews</property>
<!-- class used for content items -->
<property name="klass">tabellio.pfbviews.homenews.HomeNews</property>
<!-- add permission -->
<property name="add_permission">cmf.AddPortalContent</property>
<!-- enabled behaviors -->
<property name="behaviors">
<element value="plone.app.content.interfaces.INameFromTitle" />
<element value="plone.app.dexterity.behaviors.metadata.IDublinCore" />
</property>
<!-- View information -->
<property name="default_view">view</property>
<property name="default_view_fallback">False</property>
<property name="view_methods">
<element value="view"/>
</property>
<!-- Method aliases -->
<alias from="(Default)" to="(dynamic view)"/>
<alias from="edit" to="@@edit"/>
<alias from="sharing" to="@@sharing"/>
<alias from="view" to="(selected layout)"/>
<!-- Actions -->
<action title="View" action_id="view" category="object" condition_expr=""
url_expr="string:${object_url}" visible="True">
<permission value="View"/>
</action>
<action title="Edit" action_id="edit" category="object" condition_expr=""
url_expr="string:${object_url}/edit" visible="True">
<permission value="Modify portal content"/>
</action>
</object>