This commit is contained in:
Frédéric Péters 2013-02-13 12:59:56 +01:00
parent e74aeefbbb
commit aa315bfb3d
23 changed files with 570 additions and 1 deletions

2
.gitignore vendored
View File

@ -10,6 +10,6 @@ bin/
develop-eggs/
parts/
src/*
!src/collective/
!src/pfwbged/
var/
buildout-cache/

1
src/pfwbged/__init__.py Normal file
View File

@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)

View File

@ -0,0 +1,8 @@
from zope.i18nmessageid import MessageFactory
_ = MessageFactory('pfwbged.basecontent')
def initialize(context):
'''Initializer called when used as a Zope 2 product.'''

View File

@ -0,0 +1,22 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:grok="http://namespaces.zope.org/grok"
xmlns:i18n="http://namespaces.zope.org/i18n"
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
i18n_domain="pfwbged.basecontent">
<include package="five.grok" />
<grok:grok package="." />
<i18n:registerTranslations directory="locales" />
<genericsetup:registerProfile
name="default"
title="pfwbged.basecontent"
directory="profiles/default"
description="Installs the pfwbged.basecontent package"
provides="Products.GenericSetup.interfaces.EXTENSION"
/>
</configure>

View File

@ -0,0 +1,16 @@
from zope import schema
from zope.interface import implements
from collective.dms.basecontent.dmsdocument import DmsDocument, IDmsDocument
from . import _
class IPfwbDocument(IDmsDocument):
keywords = schema.Set(
title=_(u'Keywords'),
value_type=schema.Choice(vocabulary=u'pfwbged.basecontent.thesaurus'))
class PfwbDocument(DmsDocument):
implements(IPfwbDocument)

View File

@ -0,0 +1,37 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2013-01-09 07:42+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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: en\n"
"Language-Name: English\n"
"Preferred-Encodings: utf-8 latin1\n"
"Domain: pfwbged.basecontent\n"
"X-is-fallback-for: en-au en-ca en-gb en-us\n"
#: ./dmsfile.py:20
msgid "File"
msgstr ""
#: ./dmsdocument.py:19
msgid "Notes"
msgstr ""
#: ./dmsdocument.py:30
msgid "Recipient groups"
msgstr ""
#: ./dmsdocument.py:36
msgid "Related documents"
msgstr ""
#: ./dmsdocument.py:24
msgid "Treating groups"
msgstr ""

View File

@ -0,0 +1,41 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2013-01-09 07:42+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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: en\n"
"Language-Name: English\n"
"Preferred-Encodings: utf-8 latin1\n"
"Domain: plone\n"
"X-is-fallback-for: en-au en-ca en-gb en-us\n"
#: ./profiles/default/types/dmsappendixfile.xml
msgid "Dms appendix file of a Dms document"
msgstr ""
#: ./profiles/default/types/dmsdocument.xml
msgid "Dms base document"
msgstr ""
#: ./profiles/default/types/dmsmainfile.xml
msgid "Dms main file of an Dms document"
msgstr ""
#: ./profiles/default/types/dmsappendixfile.xml
msgid "DmsAppendixFile"
msgstr "Appendix file"
#: ./profiles/default/types/dmsdocument.xml
msgid "DmsDocument"
msgstr "Dms document"
#: ./profiles/default/types/dmsmainfile.xml
msgid "DmsMainFile"
msgstr "Dms file"

View File

@ -0,0 +1,37 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2013-01-09 07:42+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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: pfwbged.basecontent\n"
"X-is-fallback-for: fr-fr fr-be fr-ca\n"
#: ./dmsfile.py:20
msgid "File"
msgstr ""
#: ./dmsdocument.py:19
msgid "Notes"
msgstr ""
#: ./dmsdocument.py:30
msgid "Recipient groups"
msgstr ""
#: ./dmsdocument.py:36
msgid "Related documents"
msgstr ""
#: ./dmsdocument.py:24
msgid "Treating groups"
msgstr ""

View File

@ -0,0 +1,41 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2013-01-09 07:42+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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: plone\n"
"X-is-fallback-for: fr-fr fr-be fr-ca\n"
#: ./profiles/default/types/dmsappendixfile.xml
msgid "Dms appendix file of a Dms document"
msgstr "Fichier annexe lié à un document ged"
#: ./profiles/default/types/dmsdocument.xml
msgid "Dms base document"
msgstr "Document ged de base"
#: ./profiles/default/types/dmsmainfile.xml
msgid "Dms main file of an Dms document"
msgstr "Fichier ged principal d'un document ged"
#: ./profiles/default/types/dmsappendixfile.xml
msgid "DmsAppendixFile"
msgstr "Fichier annexe"
#: ./profiles/default/types/dmsdocument.xml
msgid "DmsDocument"
msgstr "Document Ged"
#: ./profiles/default/types/dmsmainfile.xml
msgid "DmsMainFile"
msgstr "Fichier ged"

View File

@ -0,0 +1,37 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2013-01-09 07:42+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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: nl\n"
"Language-Name: Dutch\n"
"Preferred-Encodings: utf-8 latin1\n"
"Domain: pfwbged.basecontent\n"
"X-is-fallback-for: nl-be nl-nl\n"
#: ./dmsfile.py:20
msgid "File"
msgstr ""
#: ./dmsdocument.py:19
msgid "Notes"
msgstr ""
#: ./dmsdocument.py:30
msgid "Recipient groups"
msgstr ""
#: ./dmsdocument.py:36
msgid "Related documents"
msgstr ""
#: ./dmsdocument.py:24
msgid "Treating groups"
msgstr ""

View File

@ -0,0 +1,41 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2013-01-09 07:42+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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: nl\n"
"Language-Name: Dutch\n"
"Preferred-Encodings: utf-8 latin1\n"
"Domain: plone\n"
"X-is-fallback-for: nl-be nl-nl\n"
#: ./profiles/default/types/dmsappendixfile.xml
msgid "Dms appendix file of a Dms document"
msgstr ""
#: ./profiles/default/types/dmsdocument.xml
msgid "Dms base document"
msgstr ""
#: ./profiles/default/types/dmsmainfile.xml
msgid "Dms main file of an Dms document"
msgstr ""
#: ./profiles/default/types/dmsappendixfile.xml
msgid "DmsAppendixFile"
msgstr ""
#: ./profiles/default/types/dmsdocument.xml
msgid "DmsDocument"
msgstr ""
#: ./profiles/default/types/dmsmainfile.xml
msgid "DmsMainFile"
msgstr ""

View File

@ -0,0 +1,39 @@
# --- PLEASE EDIT THE LINES BELOW CORRECTLY ---
# SOME DESCRIPTIVE TITLE.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2013-01-09 07:42+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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: en\n"
"Language-Name: English\n"
"Preferred-Encodings: utf-8 latin1\n"
"Domain: pfwbged.basecontent\n"
#: ./dmsfile.py:20
msgid "File"
msgstr ""
#: ./dmsdocument.py:19
msgid "Notes"
msgstr ""
#: ./dmsdocument.py:30
msgid "Recipient groups"
msgstr ""
#: ./dmsdocument.py:36
msgid "Related documents"
msgstr ""
#: ./dmsdocument.py:24
msgid "Treating groups"
msgstr ""

View File

@ -0,0 +1,42 @@
# --- PLEASE EDIT THE LINES BELOW CORRECTLY ---
# SOME DESCRIPTIVE TITLE.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2013-01-09 07:42+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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: en\n"
"Language-Name: English\n"
"Preferred-Encodings: utf-8 latin1\n"
"Domain: plone\n"
#: ./profiles/default/types/dmsappendixfile.xml
msgid "DmsAppendixFile"
msgstr ""
#: ./profiles/default/types/dmsappendixfile.xml
msgid "Dms appendix file of a Dms document"
msgstr ""
#: ./profiles/default/types/dmsdocument.xml
msgid "DmsDocument"
msgstr ""
#: ./profiles/default/types/dmsdocument.xml
msgid "Dms base document"
msgstr ""
#: ./profiles/default/types/dmsmainfile.xml
msgid "DmsMainFile"
msgstr ""
#: ./profiles/default/types/dmsmainfile.xml
msgid "Dms main file of an Dms document"
msgstr ""

View File

@ -0,0 +1,69 @@
#!/bin/bash
#
# Shell script to manage locales, languages, .po files...
#
# Run this file in your product folder
# E.g. : in yourproduct.name/yourproduct/name
#
CATALOGNAME="pfwbged.basecontent"
# List of languages used for po initialization (no mandatory update for syncing)
# Ex LANGUAGES="fr|French|fr-fr;fr-be;fr-ca nl|Dutch|nl-be;nl-nl"
LANGUAGES="en|English|en-au;en-ca;en-gb;en-us fr|French|fr-fr;fr-be;fr-ca nl|Dutch|nl-be;nl-nl"
# Create locales folder structure for languages
install -d locales
# Rebuild .pot
if ! test -f locales/$CATALOGNAME.pot || [ "$1" == "rebuild" ]; then
echo "Rebuilding locales/$CATALOGNAME.pot"
i18ndude rebuild-pot --pot locales/$CATALOGNAME.pot --create $CATALOGNAME .
fi
# Finding pot files
for pot in $(find locales -mindepth 1 -maxdepth 1 -type f -name "*.pot" ! -name generated.pot); do
#finding pot basename as catalog
catalog=`basename $pot .pot`
echo "=> Found pot $pot"
# First initialization of po files with base languages if po doesn't exist
for language in $LANGUAGES; do
arr=(`echo $language | cut -d "|" --output-delimiter=" " -f 1-`)
langcode=${arr[0]}
install -d locales/$langcode/LC_MESSAGES
PO=locales/$langcode/LC_MESSAGES/$catalog.po
# Create po file if not exists and modify header
if ! test -f $PO; then
touch $PO
echo " -> Syncing $PO"
i18ndude sync --pot $pot $PO
sed -i -e "/^\\\"Domain: DOMAIN/ s/DOMAIN/$catalog/" $PO
sed -i -e "/^\\\"Language-Code: en/ s/en/$langcode/" $PO
langname=${arr[1]}
if [ -n "$langname" ]; then
sed -i -e "/^\\\"Language-Name: English/ s/English/$langname/" $PO
fi
fallbackstr=${arr[2]}
if [ -n "$fallbackstr" ]; then
fallbacklist=`echo $fallbackstr | cut -d ";" --output-delimiter=" " -f 1-`
echo $fallbacklist
sed -i -e "/^\\\"Language-Name:/ a\"X-is-fallback-for: $fallbacklist\\\n\"" $PO
fi
fi
done
# Sync po files
for lang in $(find locales -mindepth 1 -maxdepth 1 -type d); do
if test -d $lang/LC_MESSAGES; then
PO=$lang/LC_MESSAGES/$catalog.po
# Sync po file
echo " -> Syncing $PO"
i18ndude sync --pot $pot $PO
# Compile .po to .mo
MO=$lang/LC_MESSAGES/$catalog.mo
#echo " -> Compiling $MO"
#msgfmt -o $MO $lang/LC_MESSAGES/$catalog.po
fi
done
done

View File

@ -0,0 +1,8 @@
<?xml version="1.0"?>
<metadata>
<version>0001</version>
<dependencies>
<dependency>profile-plone.app.dexterity:default</dependency>
<dependency>profile-plone.app.relationfield:default</dependency>
</dependencies>
</metadata>

View File

@ -0,0 +1 @@
Profile marker

View File

@ -0,0 +1,5 @@
<?xml version="1.0"?>
<object name="portal_types" meta_type="Plone Types Tool">
<property name="title">Controls the available content types in your portal</property>
<object name="pfwbdocument" meta_type="Dexterity FTI"/>
</object>

View File

@ -0,0 +1,47 @@
<?xml version="1.0"?>
<object name="pfwbdocument" meta_type="Dexterity FTI" i18n:domain="plone"
xmlns:i18n="http://xml.zope.org/namespaces/i18n">
<property name="title" i18n:translate="">PfwbDocument</property>
<property name="description" i18n:translate="">Pfwb base document</property>
<property name="icon_expr">string:${portal_url}/++resource++pfwbdocument_icon.png</property>
<property name="factory">pfwbdocument</property>
<property name="add_view_expr">string:${folder_url}/++add++pfwbdocument</property>
<property name="link_target"></property>
<property name="immediate_view">view</property>
<property name="global_allow">True</property>
<property name="filter_content_types">True</property>
<property name="allowed_content_types">
<element value="dmsmainfile"/>
<element value="dmsappendixfile"/>
</property>
<property name="allow_discussion">False</property>
<property name="default_view">view</property>
<property name="view_methods">
<element value="view"/>
</property>
<property name="default_view_fallback">False</property>
<property name="add_permission">cmf.AddPortalContent</property>
<property name="klass">pfwbged.basecontent.doc.PfwbDocument</property>
<property name="behaviors">
<element value="plone.app.content.interfaces.INameFromTitle"/>
<element value="plone.app.dexterity.behaviors.metadata.IDublinCore"/>
</property>
<property name="schema">pfwbged.basecontent.doc.IPfwbDocument</property>
<!-- DO NOT use a model_source or it removes manually added fields while reapplying the profile -->
<!--property name="model_source" /-->
<property name="schema_policy">schema_policy_pfwbdocument</property>
<alias from="(Default)" to="(dynamic view)"/>
<alias from="edit" to="@@edit"/>
<alias from="sharing" to="@@sharing"/>
<alias from="view" to="(selected layout)"/>
<action title="View" action_id="view" category="object" condition_expr=""
description="" icon_expr="" link_target="" url_expr="string:${object_url}"
visible="True">
<permission value="View"/>
</action>
<action title="Edit" action_id="edit" category="object" condition_expr=""
description="" icon_expr="" link_target=""
url_expr="string:${object_url}/edit" visible="True">
<permission value="Modify portal content"/>
</action>
</object>

View File

@ -0,0 +1,8 @@
<?xml version="1.0"?>
<metadata>
<version>0001</version>
<dependencies>
<dependency>profile-plone.app.dexterity:default</dependency>
<dependency>profile-plone.app.relationfield:default</dependency>
</dependencies>
</metadata>

View File

@ -0,0 +1,22 @@
# -*- coding: utf8 -*-
from plone.app.testing import PloneWithPackageLayer
from plone.app.testing import FunctionalTesting
import pfwbged.basecontent
DMS = PloneWithPackageLayer(
zcml_filename="testing.zcml",
zcml_package=pfwbged.basecontent,
gs_profile_id='pfwbged.basecontent:testing',
name="DMS")
DMS_TESTS_PROFILE = PloneWithPackageLayer(
bases=(DMS, ),
zcml_filename="testing.zcml",
zcml_package=pfwbged.basecontent,
gs_profile_id='pfwbged.basecontent:testing',
name="DMS_TESTS_PROFILE")
DMS_TESTS_PROFILE_FUNCTIONAL = FunctionalTesting(
bases=(DMS_TESTS_PROFILE,), name="DMS_TESTS_PROFILE_FUNCTIONAL")

View File

@ -0,0 +1,15 @@
<configure xmlns="http://namespaces.zope.org/zope"
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
i18n_domain="pfwbged.basecontent">
<include file="configure.zcml"/>
<genericsetup:registerProfile
name="testing"
title="pfwbged.basecontent testing"
directory="profiles/testing"
description="Testing profile for pfwbged.basecontent"
provides="Products.GenericSetup.interfaces.EXTENSION"
/>
</configure>

View File

@ -0,0 +1,32 @@
from zope.interface import implements
from five import grok
from zope.component import queryUtility
from zope.schema.interfaces import IVocabularyFactory
from zope.schema.interfaces import ISource, IContextSourceBinder
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
from Products.CMFCore.utils import getToolByName
class AdministrativeThesaurusSource(object):
grok.implements(IVocabularyFactory)
def __call__(self, context):
catalog = getToolByName(context, 'portal_catalog')
results = catalog(portal_type='dmskeyword')
keywords = [x.getObject() for x in results]
def cmp_keyword(x, y):
return cmp(x.title, y.title)
keywords.sort(cmp_keyword)
keyword_ids = [x.id for x in keywords]
keyword_terms = [SimpleVocabulary.createTerm(
x.id, x.id, x.title) for x in keywords]
return SimpleVocabulary(keyword_terms)
def __iter__(self):
# hack to let schema editor handle the field
yield u'DO NOT TOUCH'
grok.global_utility(AdministrativeThesaurusSource,
name=u'pfwbged.basecontent.thesaurus')