# HG changeset patch
# User Damien Correia
# Date 1529490080 -7200
# Node ID 35f7015089bc74da85828605e9b47336d08f71f6
# Parent 634e5e520bd0a9228450ec2ef07b82d624124bb4# Parent dd257ef7fcaa45d9998b871d49e9a4b603ccbd4b
merge default
diff -r 634e5e520bd0 -r 35f7015089bc src/pyams_content/component/links/zmi/reverse.py
--- a/src/pyams_content/component/links/zmi/reverse.py Mon Jun 18 10:14:25 2018 +0200
+++ b/src/pyams_content/component/links/zmi/reverse.py Wed Jun 20 12:21:20 2018 +0200
@@ -19,6 +19,8 @@
from hypatia.interfaces import ICatalog
from pyams_content.shared.common.interfaces import IWfSharedContent
from pyams_content.shared.common.interfaces.zmi import ISiteRootDashboardTable
+from pyams_content.shared.site.interfaces import ISiteContainer
+from pyams_portal.interfaces import IPortalTemplate
from pyams_sequence.interfaces import ISequentialIdInfo
from pyams_skin.interfaces import IInnerPage
from pyams_skin.layer import IPyAMSLayer
@@ -77,11 +79,23 @@
@property
def values(self):
+
+ def get_item(result):
+ parent = get_parent(result, IWfSharedContent)
+ if parent is not None:
+ return IWorkflowVersions(parent).get_last_versions(count=1)[0]
+ parent = get_parent(result, IPortalTemplate)
+ if parent is None:
+ parent = get_parent(result, ISiteContainer)
+ if parent is None:
+ parent = self.request.root
+ return parent
+
catalog = get_utility(ICatalog)
oid = ISequentialIdInfo(self.context).hex_oid
params = Or(Eq(catalog['link_reference'], oid),
Eq(catalog['link_references'], oid))
- return unique(map(lambda x: IWorkflowVersions(get_parent(x, IWfSharedContent)).get_last_versions(count=1)[0],
+ return unique(map(get_item,
CatalogResultSet(CatalogQuery(catalog).query(params,
sort_index='modified_date'))))
diff -r 634e5e520bd0 -r 35f7015089bc src/pyams_content/component/paragraph/zmi/pictogram.py
--- a/src/pyams_content/component/paragraph/zmi/pictogram.py Mon Jun 18 10:14:25 2018 +0200
+++ b/src/pyams_content/component/paragraph/zmi/pictogram.py Wed Jun 20 12:21:20 2018 +0200
@@ -39,6 +39,7 @@
BaseParagraphPropertiesEditForm, BaseParagraphAJAXEditForm
from pyams_content.features.renderer.zmi.widget import RendererFieldWidget
from pyams_content.reference.pictograms.zmi.widget import PictogramSelectFieldWidget
+from pyams_file.zmi.image import render_image
from pyams_form.form import AJAXAddForm, ajax_config
from pyams_form.security import ProtectedFormObjectMixin
from pyams_i18n.column import I18nAttrColumn
@@ -227,7 +228,7 @@
if pictogram is not None:
image = II18n(pictogram).query_attribute('image', request=self.request)
if image:
- return ''.format(absolute_url(image, self.request, '++thumb++48x48'))
+ return render_image(image, 48, 48, self.request)
return '--'
diff -r 634e5e520bd0 -r 35f7015089bc src/pyams_content/reference/pictograms/zmi/__init__.py
--- a/src/pyams_content/reference/pictograms/zmi/__init__.py Mon Jun 18 10:14:25 2018 +0200
+++ b/src/pyams_content/reference/pictograms/zmi/__init__.py Wed Jun 20 12:21:20 2018 +0200
@@ -14,9 +14,6 @@
# import standard library
-import sys
-
-from random import randint
from uuid import uuid4
# import interfaces
@@ -32,6 +29,7 @@
# import packages
from pyams_content.reference.pictograms import Pictogram
+from pyams_file.zmi.image import render_image
from pyams_form.form import AJAXAddForm, ajax_config
from pyams_i18n.column import I18nAttrColumn
from pyams_pagelet.pagelet import pagelet_config
@@ -40,7 +38,6 @@
from pyams_skin.viewlet.toolbar import ToolbarAction
from pyams_utils.adapter import adapter_config
from pyams_utils.traversing import get_parent
-from pyams_utils.url import absolute_url
from pyams_viewlet.viewlet import viewlet_config
from pyams_zmi.form import AdminDialogAddForm, AdminDialogEditForm
from pyramid.httpexceptions import HTTPNotFound
@@ -142,8 +139,8 @@
def getValue(self, obj):
image = II18n(obj).query_attribute('image', request=self.request)
if image:
- timestamp = randint(0, sys.maxsize)
- return ''.format(absolute_url(image, self.request, '++thumb++32x32'), timestamp)
+ return render_image(image, 32, 32, timestamp=True)
+ return '--'
@adapter_config(name='name', context=(IPictogramTable, IAdminLayer, PictogramTableContentsTable), provides=IColumn)
diff -r 634e5e520bd0 -r 35f7015089bc src/pyams_content/reference/pictograms/zmi/templates/manager-selection.pt
--- a/src/pyams_content/reference/pictograms/zmi/templates/manager-selection.pt Mon Jun 18 10:14:25 2018 +0200
+++ b/src/pyams_content/reference/pictograms/zmi/templates/manager-selection.pt Wed Jun 20 12:21:20 2018 +0200
@@ -22,9 +22,9 @@
-
+
Title
@@ -49,9 +49,9 @@
-
+
Title
diff -r 634e5e520bd0 -r 35f7015089bc src/pyams_content/reference/pictograms/zmi/templates/pictogram-header.pt
--- a/src/pyams_content/reference/pictograms/zmi/templates/pictogram-header.pt Mon Jun 18 10:14:25 2018 +0200
+++ b/src/pyams_content/reference/pictograms/zmi/templates/pictogram-header.pt Wed Jun 20 12:21:20 2018 +0200
@@ -1,8 +1,8 @@
-
-
-
+
+ Default header:
diff -r 634e5e520bd0 -r 35f7015089bc src/pyams_content/root/__init__.py
--- a/src/pyams_content/root/__init__.py Mon Jun 18 10:14:25 2018 +0200
+++ b/src/pyams_content/root/__init__.py Wed Jun 20 12:21:20 2018 +0200
@@ -47,6 +47,8 @@
from pyramid.events import subscriber
from zope.interface import implementer
+from pyams_content import _
+
@implementer(IDefaultProtectionPolicy, ISiteRoot, ISiteRootRoles, IPortalContext,
IIllustrationTarget, IHeaderTarget, IFooterTarget, IAlertTarget, IPreviewTarget)
@@ -62,6 +64,8 @@
operators = RolePrincipalsFieldProperty(ISiteRootRoles['operators'])
templates_managers = RolePrincipalsFieldProperty(ISiteRootRoles['templates_managers'])
+ content_name = _("Site root")
+
@utility_config(provides=ISiteRootFactory)
class SiteRootFactory(object):
diff -r 634e5e520bd0 -r 35f7015089bc src/pyams_content/root/zmi/__init__.py
--- a/src/pyams_content/root/zmi/__init__.py Mon Jun 18 10:14:25 2018 +0200
+++ b/src/pyams_content/root/zmi/__init__.py Wed Jun 20 12:21:20 2018 +0200
@@ -25,7 +25,8 @@
from pyams_content.skin.zmi.interfaces import IDashboardMenu, IMyDashboardMenu, IAllContentsMenu
from pyams_i18n.interfaces import II18n
from pyams_skin.interfaces import IInnerPage, IPageHeader
-from pyams_skin.interfaces.configuration import IBackOfficeConfiguration
+from pyams_skin.interfaces.configuration import IBackOfficeConfiguration, IConfiguration
+from pyams_skin.interfaces.container import ITableElementName, ITableElementEditor
from pyams_skin.interfaces.viewlet import IBreadcrumbItem
from pyams_skin.layer import IPyAMSLayer
from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
@@ -45,11 +46,11 @@
from pyams_pagelet.pagelet import pagelet_config
from pyams_skin.container import ContainerView
from pyams_skin.page import DefaultPageHeaderAdapter
-from pyams_skin.table import I18nColumn
+from pyams_skin.table import I18nColumn, DefaultElementEditorAdapter
from pyams_skin.viewlet.breadcrumb import BreadcrumbItem
from pyams_skin.viewlet.menu import MenuItem
from pyams_template.template import template_config
-from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter
+from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter, ContextRequestAdapter
from pyams_utils.list import unique
from pyams_utils.registry import get_utility, get_all_utilities_registered_for
from pyams_viewlet.manager import viewletmanager_config
@@ -77,6 +78,24 @@
label = _("Home")
+@adapter_config(context=(ISiteRoot, IPyAMSLayer), provides=ITableElementName)
+class SiteRootTableElementNameAdapter(ContextRequestAdapter):
+ """Site root table element name adapter"""
+
+ @property
+ def name(self):
+ configuration = IConfiguration(self.context)
+ return II18n(configuration).query_attribute('short_title', request=self.request)
+
+
+@adapter_config(context=(ISiteRoot, IAdminLayer, Interface), provides=ITableElementEditor)
+class SiteRootTableElementEditorAdapter(DefaultElementEditorAdapter):
+ """Site root table element editor adapter"""
+
+ view_name = 'admin#site-tree.html'
+ modal_target = False
+
+
#
# Main dashboard menu
#
@@ -800,4 +819,7 @@
weight = 1
def getValue(self, obj):
- return self.request.localizer.translate(obj.content_name)
+ try:
+ return self.request.localizer.translate(obj.content_name)
+ except AttributeError:
+ return '--'
diff -r 634e5e520bd0 -r 35f7015089bc src/pyams_content/root/zmi/templates/dashboard.pt
--- a/src/pyams_content/root/zmi/templates/dashboard.pt Mon Jun 18 10:14:25 2018 +0200
+++ b/src/pyams_content/root/zmi/templates/dashboard.pt Wed Jun 20 12:21:20 2018 +0200
@@ -25,7 +25,9 @@
@@ -36,7 +38,8 @@
-
+
+
@@ -46,6 +49,6 @@
You are not actually concerned by any content.
-
+
diff -r 634e5e520bd0 -r 35f7015089bc src/pyams_content/shared/common/zmi/templates/dashboard.pt
--- a/src/pyams_content/shared/common/zmi/templates/dashboard.pt Mon Jun 18 10:14:25 2018 +0200
+++ b/src/pyams_content/shared/common/zmi/templates/dashboard.pt Wed Jun 20 12:21:20 2018 +0200
@@ -25,7 +25,9 @@
@@ -36,7 +38,8 @@
-
+
+
@@ -46,6 +49,6 @@
You are not actually concerned by any content.
-
+
diff -r 634e5e520bd0 -r 35f7015089bc src/pyams_content/shared/site/folder.py
--- a/src/pyams_content/shared/site/folder.py Mon Jun 18 10:14:25 2018 +0200
+++ b/src/pyams_content/shared/site/folder.py Wed Jun 20 12:21:20 2018 +0200
@@ -42,6 +42,8 @@
from pyams_content import _
+from pyams_content import _
+
@implementer(IDefaultProtectionPolicy, ISiteFolder, ISiteFolderRoles,
IIllustrationTarget, ILinkIllustrationTarget, IPortalContext, IPreviewTarget)
diff -r 634e5e520bd0 -r 35f7015089bc src/pyams_content/shared/site/manager.py
--- a/src/pyams_content/shared/site/manager.py Mon Jun 18 10:14:25 2018 +0200
+++ b/src/pyams_content/shared/site/manager.py Wed Jun 20 12:21:20 2018 +0200
@@ -50,6 +50,8 @@
from zope.schema.fieldproperty import FieldProperty
from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
+from pyams_content import _
+
@implementer(ISiteManager, IParagraphFactorySettings, IThemesManagerTarget, IPictogramManagerTarget,
IIllustrationTarget, ILinkIllustrationTarget, IPortalContext, IHeaderTarget,
@@ -63,6 +65,8 @@
sequence_name = '' # use default sequence generator
sequence_prefix = ''
+ content_name = _("Site manager")
+
@property
def folder_factory(self):
return ISiteFolderFactory(self, SiteFolder)
diff -r 634e5e520bd0 -r 35f7015089bc src/pyams_content/shared/site/zmi/folder.py
--- a/src/pyams_content/shared/site/zmi/folder.py Mon Jun 18 10:14:25 2018 +0200
+++ b/src/pyams_content/shared/site/zmi/folder.py Wed Jun 20 12:21:20 2018 +0200
@@ -20,6 +20,7 @@
from pyams_content.shared.common.interfaces import IBaseSharedTool
from pyams_content.shared.site.interfaces import ISiteContainer, ISiteManager, ISiteFolder
from pyams_i18n.interfaces import INegotiator, II18n
+from pyams_skin.interfaces.container import ITableElementName, ITableElementEditor
from pyams_skin.interfaces.viewlet import IToolbarAddingMenu, IMenuHeader
from pyams_skin.layer import IPyAMSLayer
from pyams_zmi.interfaces.menu import ISiteManagementMenu
@@ -33,6 +34,7 @@
from pyams_form.form import AJAXAddForm, AJAXEditForm, ajax_config
from pyams_i18n.schema import I18nTextLineField
from pyams_pagelet.pagelet import pagelet_config
+from pyams_skin.table import DefaultElementEditorAdapter
from pyams_skin.viewlet.toolbar import ToolbarMenuItem
from pyams_utils.adapter import adapter_config, ContextRequestAdapter
from pyams_utils.registry import get_utility
@@ -164,6 +166,23 @@
# Site folder edit form
#
+@adapter_config(context=(ISiteFolder, IPyAMSLayer), provides=ITableElementName)
+class SiteFolderTableElementNameAdapter(ContextRequestAdapter):
+ """Site folder table element name adapter"""
+
+ @property
+ def name(self):
+ return II18n(self.context).query_attribute('short_name', request=self.request)
+
+
+@adapter_config(context=(ISiteFolder, IAdminLayer, Interface), provides=ITableElementEditor)
+class SiteFolderTableElementEditorAdapter(DefaultElementEditorAdapter):
+ """Site folder table element editor adapter"""
+
+ view_name = 'admin#site-tree.html'
+ modal_target = False
+
+
@pagelet_config(name='properties.html', context=ISiteFolder, layer=IPyAMSLayer, permission=MANAGE_TOOL_PERMISSION)
class SiteFolderPropertiesEditForm(SharedToolPropertiesEditForm):
"""Site folder properties edit form"""
diff -r 634e5e520bd0 -r 35f7015089bc src/pyams_content/shared/site/zmi/manager.py
--- a/src/pyams_content/shared/site/zmi/manager.py Mon Jun 18 10:14:25 2018 +0200
+++ b/src/pyams_content/shared/site/zmi/manager.py Wed Jun 20 12:21:20 2018 +0200
@@ -21,7 +21,7 @@
from pyams_content.shared.site.interfaces import ISiteManager, ISiteManagerFactory
from pyams_content.skin.zmi.interfaces import ISiteTreeTable, IUserAddingsMenuLabel
from pyams_i18n.interfaces import II18n, INegotiator
-from pyams_skin.interfaces.container import ITableElementEditor
+from pyams_skin.interfaces.container import ITableElementEditor, ITableElementName
from pyams_skin.interfaces.viewlet import IToolbarAddingMenu, IBreadcrumbItem, IMenuHeader
from pyams_skin.layer import IPyAMSLayer
from pyams_zmi.interfaces.menu import ISiteManagementMenu
@@ -45,7 +45,7 @@
from pyramid.events import subscriber
from pyramid.path import DottedNameResolver
from z3c.form import field
-from zope.interface import Invalid
+from zope.interface import Invalid, Interface
from pyams_content import _
@@ -68,6 +68,31 @@
css_class = 'strong'
+@adapter_config(context=(ISiteManager, IPyAMSLayer), provides=ITableElementName)
+class SiteManagerTableElementNameAdapter(ContextRequestAdapter):
+ """Site manager table element name adapter"""
+
+ @property
+ def name(self):
+ return II18n(self.context).query_attribute('short_name', request=self.request)
+
+
+@adapter_config(context=(ISiteManager, IAdminLayer, Interface), provides=ITableElementEditor)
+class SiteManagerTableElementEditorAdapter(DefaultElementEditorAdapter):
+ """Site manager table element editor adapter"""
+
+ view_name = 'admin#site-tree.html'
+ modal_target = False
+
+
+@adapter_config(context=(ISiteManager, IAdminLayer, ISiteTreeTable), provides=ITableElementEditor)
+class SiteManagerTableElementEditor(DefaultElementEditorAdapter):
+ """Site tree table element editor"""
+
+ view_name = 'admin#site-tree.html'
+ modal_target = False
+
+
@adapter_config(context=(ISiteManager, IAdminLayer), provides=IUserAddingsMenuLabel)
class SiteManagerUserAddingsMenuLabelAdapter(ContextRequestAdapter):
"""Site manager user addings menu label adapter"""
@@ -137,11 +162,3 @@
site = query_utility(ISiteManager, name=short_name)
if site is not None:
event.form.widgets.errors += (Invalid(_("A site manager is already registered with this name!!")),)
-
-
-@adapter_config(context=(ISiteManager, IAdminLayer, ISiteTreeTable), provides=ITableElementEditor)
-class SiteManagerTableElementEditor(DefaultElementEditorAdapter):
- """Site tree table element editor"""
-
- view_name = 'admin#site-tree.html'
- modal_target = False