| 1 |
from Products.CMFCore.utils import getToolByName |
|---|
| 2 |
from Products.PloneXL8.config import PROJECTNAME, TRANSLATION_DOC_TYPES, TRANSLATION_URGENCIES, TO_INDEX, META_TYPES_NOT_TO_LIST |
|---|
| 3 |
from Products.ExternalMethod.ExternalMethod import manage_addExternalMethod |
|---|
| 4 |
|
|---|
| 5 |
def install(self): |
|---|
| 6 |
addActions(self) |
|---|
| 7 |
addActionIcons(self) |
|---|
| 8 |
registerNavigationTreeSettings(self) |
|---|
| 9 |
catalog = getToolByName(self, 'portal_catalog') |
|---|
| 10 |
for item in TO_INDEX: |
|---|
| 11 |
addCatalogMetadata(self, catalog, item) |
|---|
| 12 |
addExternalMethods(self) |
|---|
| 13 |
|
|---|
| 14 |
def addActions(self): |
|---|
| 15 |
pa = getToolByName(self, 'portal_actions') |
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
pa.addAction('pophtml', |
|---|
| 19 |
name='Show document in new window', |
|---|
| 20 |
action="string:javascript:(function(){open('${object_url}/pophtml', 'newwin', 'menubar=1,scrollbars=1,resizable=1,width=800,height=600')})()", |
|---|
| 21 |
condition="python: object.meta_type == 'TranslationDoc'", |
|---|
| 22 |
permission='View', |
|---|
| 23 |
category='document_actions') |
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
pa.addAction('changeTransOwner', |
|---|
| 27 |
name='Unlock translation doc', |
|---|
| 28 |
action="changeTransOwner", |
|---|
| 29 |
condition="python: (object.wasEditedOneDayAgo())", |
|---|
| 30 |
permission='View', |
|---|
| 31 |
category='document_actions') |
|---|
| 32 |
|
|---|
| 33 |
def addActionIcons(self): |
|---|
| 34 |
ai = getToolByName(self, 'portal_actionicons') |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
try: |
|---|
| 38 |
ai.getActionIcon('plone','pophtml') |
|---|
| 39 |
except KeyError: |
|---|
| 40 |
ai.addActionIcon('plone', 'pophtml', 'htmldoc.gif', 'Show document in new window') |
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
try: |
|---|
| 44 |
ai.getActionIcon('plone','changeTransOwner') |
|---|
| 45 |
except KeyError: |
|---|
| 46 |
ai.addActionIcon('plone', 'changeTransOwner', 'key.gif', 'Unlock this document and take ownership.') |
|---|
| 47 |
|
|---|
| 48 |
def registerNavigationTreeSettings(self): |
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
data = META_TYPES_NOT_TO_LIST |
|---|
| 53 |
pp=getToolByName(self,'portal_properties') |
|---|
| 54 |
p = getattr(pp , 'navtree_properties', None) |
|---|
| 55 |
mdntl = list(p.getProperty('metaTypesNotToList', [])) |
|---|
| 56 |
if not mdntl: |
|---|
| 57 |
p._setProperty('metaTypesNotToList', data) |
|---|
| 58 |
else: |
|---|
| 59 |
for t in data: |
|---|
| 60 |
if t not in mdntl: |
|---|
| 61 |
mdntl.append(t) |
|---|
| 62 |
p._updateProperty('metaTypesNotToList', mdntl) |
|---|
| 63 |
|
|---|
| 64 |
def addCatalogMetadata(self, catalog, column): |
|---|
| 65 |
"""Add the given column to the catalog's metadata schema""" |
|---|
| 66 |
if column not in catalog.schema(): |
|---|
| 67 |
catalog.addColumn(column) |
|---|
| 68 |
|
|---|
| 69 |
else: |
|---|
| 70 |
pass |
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
def addExternalMethods(self): |
|---|
| 74 |
portal = self.portal_url.getPortalObject() |
|---|
| 75 |
manage_addExternalMethod(portal, 'changeTransOwner', |
|---|
| 76 |
'Change translation object owner', |
|---|
| 77 |
PROJECTNAME+'.XL8External', |
|---|
| 78 |
'changeTransOwner') |
|---|
| 79 |
|
|---|