--- a/src/pyams_content/root/zmi/__init__.py Mon Jan 18 16:08:56 2016 +0100
+++ b/src/pyams_content/root/zmi/__init__.py Mon Jan 18 16:09:49 2016 +0100
@@ -25,6 +25,7 @@
from pyams_content.zmi.interfaces import IDashboardMenu, IMyDashboardMenu, IAllContentsMenu
from pyams_i18n.interfaces import II18n
from pyams_skin.interfaces import IInnerPage, IPageHeader
+from pyams_skin.interfaces.viewlet import IBreadcrumbItem
from pyams_skin.layer import IPyAMSLayer
from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
from pyams_workflow.interfaces import IWorkflowVersions, IWorkflowState, IWorkflow
@@ -42,6 +43,7 @@
from pyams_skin.container import ContainerView
from pyams_skin.page import DefaultPageHeaderAdapter
from pyams_skin.table import I18nColumn
+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
@@ -62,6 +64,17 @@
#
+# Site root breadcrumbs
+#
+
+@adapter_config(context=(ISiteRoot, IPyAMSLayer), provides=IBreadcrumbItem)
+class SiteRootBreadcrumbAdapter(BreadcrumbItem):
+ """Site root breadcrumb adapter"""
+
+ label = _("Home")
+
+
+#
# Main dashboard menu
#
@@ -118,7 +131,8 @@
class SiteRootDashboardManagerWaitingTable(BaseDashboardTable):
"""Site root dashboard manager waiting contents table"""
- _title = _("MANAGER - {0} content(s) waiting for your action")
+ _single_title = _("MANAGER - {0} content waiting for your action")
+ _plural_title = _("MANAGER - {0} contents waiting for your action")
dt_sort_order = 'asc'
@@ -162,7 +176,8 @@
class SiteRootDashboardOwnerWaitingTable(BaseDashboardTable):
"""Site root dashboard waiting owned contents table"""
- _title = _("CONTRIBUTOR - Your {0} content(s) waiting for action")
+ _single_title = _("CONTRIBUTOR - {0} content waiting for action")
+ _plural_title = _("CONTRIBUTOR - {0} contents waiting for action")
dt_sort_order = 'asc'
@@ -195,7 +210,14 @@
class SiteRootDashboardOwnerModifiedTable(BaseDashboardTable):
"""Site root dashboard modified contents table"""
- _title = _("CONTRIBUTOR - Your last modified contents (limited to {0})")
+ _single_title = _("CONTRIBUTOR - {0} modified content")
+
+ @property
+ def _plural_title(self):
+ if len(self.values) <= 50:
+ return _("CONTRIBUTOR - {0} modified contents")
+ else:
+ return _("CONTRIBUTOR - Last {0} modified contents")
@adapter_config(context=(ISiteRoot, IPyAMSLayer, SiteRootDashboardOwnerModifiedTable), provides=IValues)
@@ -213,7 +235,7 @@
params = params | query if params else query
return unique(map(lambda x: IWorkflowVersions(x).get_last_versions()[0],
CatalogResultSet(CatalogQuery(catalog).query(params,
- limit=IAdminProfile(self.request.principal).table_page_length,
+ limit=50,
sort_index='modified_date',
reverse=True))))
@@ -235,6 +257,65 @@
#
+# My favorites
+# Dashboard of owned and modified contents which can be updated
+#
+
+@viewlet_config(name='my-favorites.menu', context=ISiteRoot, layer=IAdminLayer,
+ manager=IMyDashboardMenu, permission=VIEW_SYSTEM_PERMISSION, weight=3)
+class SiteRootFavoritesMenu(MenuItem):
+ """Site root favorites dashboard menu"""
+
+ label = _("My favorites")
+ icon_class = None
+ url = '#my-favorites.html'
+
+
+@implementer(ISiteRootDashboardTable)
+class SiteRootFavoritesTable(BaseDashboardTable):
+ """Site root favorites table"""
+
+ _single_title = _("CONTRIBUTOR - {0} favorite")
+ _plural_title = _("CONTRIBUTOR - {0} favorites")
+
+
+@adapter_config(context=(ISiteRoot, IPyAMSLayer, SiteRootFavoritesTable), provides=IValues)
+class SiteRootFavoritesValues(ContextRequestViewAdapter):
+ """Site root favorites values adapter"""
+
+ @property
+ def values(self):
+ catalog = get_utility(ICatalog)
+ profile = IAdminProfile(self.request.principal)
+ params = None
+ for name, tool in get_utilities_for(ISharedTool):
+ query = And(Eq(catalog['content_type'], tool.shared_content_type),
+ Any(catalog['oid'], profile.favorites or ()))
+ params = params | query if params else query
+ return unique(map(lambda x: IWorkflowVersions(x).get_last_versions()[0],
+ CatalogResultSet(CatalogQuery(catalog).query(params,
+ sort_index='modified_date',
+ reverse=True))))
+
+
+@pagelet_config(name='my-favorites.html', context=ISiteRoot, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
+@implementer(IInnerPage)
+class SiteRootFavoritesView(AdminView, ContainerView):
+ """Site root favorites view"""
+
+ table_class = SiteRootFavoritesTable
+
+
+@adapter_config(context=(ISiteRoot, IPyAMSLayer, SiteRootFavoritesView), provides=IPageHeader)
+class SiteRootFavoritesHeaderAdapter(DefaultPageHeaderAdapter):
+ """Site root favorites header adapter"""
+
+ icon_class = 'fa fa-fw fa-star'
+
+ title = _("Your favorites")
+
+
+#
# My preparations
# Dashboard of owned and modified contents which can be updated
#
@@ -253,7 +334,8 @@
class SiteRootPreparationsTable(BaseDashboardTable):
"""Site root preparations table"""
- _title = _("CONTRIBUTOR - Your {0} prepared contents")
+ _single_title = _("CONTRIBUTOR - {0} prepared content")
+ _plural_title = _("CONTRIBUTOR - {0} prepared contents")
@adapter_config(context=(ISiteRoot, IPyAMSLayer, SiteRootPreparationsTable), provides=IValues)
@@ -269,7 +351,7 @@
query = And(Eq(catalog['content_type'], tool.shared_content_type),
Or(Eq(catalog['role:owner'], self.request.principal.id),
Eq(catalog['role:contributor'], self.request.principal.id)),
- Any(catalog['workflow_state'], workflow.update_states))
+ Eq(catalog['workflow_state'], workflow.initial_state))
params = params | query if params else query
return unique(CatalogResultSet(CatalogQuery(catalog).query(params,
sort_index='modified_date',
@@ -294,6 +376,66 @@
#
+# My submissions
+# Dashboard of owned and modified contents which are waiting manager action
+#
+
+@viewlet_config(name='my-submissions.menu', context=ISiteRoot, layer=IAdminLayer,
+ manager=IMyDashboardMenu, permission=VIEW_SYSTEM_PERMISSION, weight=7)
+class SiteRootSubmissionsMenu(MenuItem):
+ """Site root submissions dashboard menu"""
+
+ label = _("My submissions")
+ icon_class = None
+ url = '#my-submissions.html'
+
+
+@implementer(ISiteRootDashboardTable)
+class SiteRootSubmissionsTable(BaseDashboardTable):
+ """Site root submissions table"""
+
+ _single_title = _("CONTRIBUTOR - {0} submitted content")
+ _plural_title = _("CONTRIBUTOR - {0} submitted contents")
+
+
+@adapter_config(context=(ISiteRoot, IPyAMSLayer, SiteRootSubmissionsTable), provides=IValues)
+class SiteRootSubmissionsValues(ContextRequestViewAdapter):
+ """Site root submissions values adapter"""
+
+ @property
+ def values(self):
+ catalog = get_utility(ICatalog)
+ params = None
+ for name, tool in get_utilities_for(ISharedTool):
+ workflow = get_utility(IWorkflow, name=tool.shared_content_workflow)
+ query = And(Eq(catalog['content_type'], tool.shared_content_type),
+ Or(Eq(catalog['role:owner'], self.request.principal.id),
+ Eq(catalog['role:contributor'], self.request.principal.id)),
+ Any(catalog['workflow_state'], workflow.waiting_states))
+ params = params | query if params else query
+ return unique(CatalogResultSet(CatalogQuery(catalog).query(params,
+ sort_index='modified_date',
+ reverse=True)))
+
+
+@pagelet_config(name='my-submissions.html', context=ISiteRoot, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION)
+@implementer(IInnerPage)
+class SiteRootSubmissionsView(AdminView, ContainerView):
+ """Site root submissions view"""
+
+ table_class = SiteRootSubmissionsTable
+
+
+@adapter_config(context=(ISiteRoot, IPyAMSLayer, SiteRootSubmissionsView), provides=IPageHeader)
+class SiteRootSubmissionsHeaderAdapter(DefaultPageHeaderAdapter):
+ """Site root submissions header adapter"""
+
+ icon_class = 'fa fa-fw fa-user'
+
+ title = _("Your submitted contents")
+
+
+#
# My publications
# Dashboard of owned and modified contents which are published
#
@@ -312,7 +454,8 @@
class SiteRootPublicationsTable(BaseDashboardTable):
"""Site root publications table"""
- _title = _("CONTRIBUTOR - Your {0} published contents")
+ _single_title = _("CONTRIBUTOR - {0} published content")
+ _plural_title = _("CONTRIBUTOR - {0} published contents")
@adapter_config(context=(ISiteRoot, IPyAMSLayer, SiteRootPublicationsTable), provides=IValues)
@@ -371,7 +514,8 @@
class SiteRootRetiredContentsTable(BaseDashboardTable):
"""Site root retired contents table"""
- _title = _("CONTRIBUTOR - Your {0} retired contents")
+ _single_title = _("CONTRIBUTOR - {0} retired content")
+ _plural_title = _("CONTRIBUTOR - {0} retired contents")
@adapter_config(context=(ISiteRoot, IPyAMSLayer, SiteRootRetiredContentsTable), provides=IValues)
@@ -431,7 +575,8 @@
class SiteRootArchivedContentsTable(BaseDashboardTable):
"""Site root archived contents table"""
- _title = _("CONTRIBUTOR - Your {0} archived contents")
+ _single_title = _("CONTRIBUTOR - {0} archived content")
+ _plural_title = _("CONTRIBUTOR - {0} archived contents")
@adapter_config(context=(ISiteRoot, IPyAMSLayer, SiteRootArchivedContentsTable), provides=IValues)
@@ -513,7 +658,14 @@
class SiteRootAllPublicationsTable(BaseDashboardTable):
"""Site root published contents table"""
- _title = _("CONTRIBUTORS - Last published contents (in the limit of 50)")
+ _single_title = _("CONTRIBUTORS - {0} published content")
+
+ @property
+ def _plural_title(self):
+ if len(self.values) <= 50:
+ return _("CONTRIBUTORS - Last {0} published contents")
+ else:
+ return _("CONTRIBUTORS - Last published contents (in the limit of 50)")
@adapter_config(context=(ISiteRoot, IPyAMSLayer, SiteRootAllPublicationsTable), provides=IValues)
@@ -572,7 +724,14 @@
class SiteRootAllUpdatesTable(BaseDashboardTable):
"""Site root updated contents table"""
- _title = _("CONTRIBUTORS - Last updated contents (in the limit of 50)")
+ _single_title = _("CONTRIBUTORS - {0} updated content")
+
+ @property
+ def _plural_title(self):
+ if len(self.values) <= 50:
+ return _("CONTRIBUTORS - Last {0} updated contents")
+ else:
+ return _("CONTRIBUTORS - Last updated contents (in the limit of 50)")
@adapter_config(context=(ISiteRoot, IPyAMSLayer, SiteRootAllUpdatesTable), provides=IValues)