# HG changeset patch # User Thierry Florac # Date 1505812132 -7200 # Node ID 2912fbd45f6264891876764c5949469b39261c15 # Parent 826753ab9e5224172da913534e2728f7e9d24941 Use new 'ContainerAdminView' base class diff -r 826753ab9e52 -r 2912fbd45f62 src/pyams_content/component/association/zmi/__init__.py --- a/src/pyams_content/component/association/zmi/__init__.py Wed Sep 13 15:58:14 2017 +0200 +++ b/src/pyams_content/component/association/zmi/__init__.py Tue Sep 19 11:08:52 2017 +0200 @@ -21,7 +21,6 @@ from pyams_content.component.association.zmi.interfaces import IAssociationsParentForm, IAssociationsView from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION from pyams_form.interfaces.form import IInnerSubForm -from pyams_skin.interfaces import IInnerPage from pyams_skin.layer import IPyAMSLayer from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION from pyams_zmi.interfaces.menu import IPropertiesMenu @@ -39,7 +38,7 @@ from pyams_utils.url import absolute_url from pyams_viewlet.viewlet import viewlet_config from pyams_zmi.form import InnerAdminDisplayForm -from pyams_zmi.view import AdminView +from pyams_zmi.view import ContainerAdminView from pyramid.decorator import reify from pyramid.exceptions import NotFound from pyramid.view import view_config @@ -58,7 +57,7 @@ """Association item add form, JSON renderer""" def get_ajax_output(self, changes): - associations_table = AssociationsTable(self.context, self.request, None) + associations_table = AssociationsTable(self.context, self.request) associations_table.update() return {'status': 'success', 'message': self.request.localizer.translate(_("Association was correctly added.")), @@ -72,7 +71,7 @@ def get_associations_table(self): target = get_parent(self.context, IAssociationTarget) - associations_table = AssociationsTable(target, self.request, None) + associations_table = AssociationsTable(target, self.request) associations_table.update() return {'status': 'success', 'message': self.request.localizer.translate(self.successMessage), @@ -95,43 +94,6 @@ url = '#associations.html' -@pagelet_config(name='associations.html', context=IAssociationTarget, layer=IPyAMSLayer, - permission=VIEW_SYSTEM_PERMISSION) -@template_config(template='templates/associations-view.pt', layer=IPyAMSLayer) -@implementer(IInnerPage, IAssociationsView) -class AssociationsContainerView(AdminView, Pagelet): - """Associations container view""" - - title = _("Associations list") - - def __init__(self, context, request): - super(AssociationsContainerView, self).__init__(context, request) - self.table = AssociationsTable(context, request, self) - - def update(self): - super(AssociationsContainerView, self).update() - self.table.update() - - -@adapter_config(name='associations', context=(IAssociationTarget, IPyAMSLayer, IAssociationsParentForm), - provides=IInnerSubForm) -@template_config(template='templates/associations.pt', layer=IPyAMSLayer) -@implementer(IAssociationsView) -class AssociationsView(InnerAdminDisplayForm): - """Associations view""" - - fields = field.Fields(Interface) - weight = 90 - - def __init__(self, context, request, view): - super(AssociationsView, self).__init__(context, request, view) - self.table = AssociationsTable(context, request, self) - - def update(self): - super(AssociationsView, self).update() - self.table.update() - - class AssociationsTable(ProtectedFormObjectMixin, BaseTable): """Associations view inner table""" @@ -142,10 +104,6 @@ hide_header = True sortOn = None - def __init__(self, context, request, view): - super(AssociationsTable, self).__init__(context, request) - self.view = view - @property def cssClasses(self): classes = ['table', 'table-bordered', 'table-striped', 'table-hover', 'table-tight'] @@ -297,3 +255,33 @@ @adapter_config(name='trash', context=(IAssociationTarget, IPyAMSLayer, AssociationsTable), provides=IColumn) class AssociationsTableTrashColumn(ProtectedFormObjectMixin, TrashColumn): """Associations table trash column""" + + +@pagelet_config(name='associations.html', context=IAssociationTarget, layer=IPyAMSLayer, + permission=VIEW_SYSTEM_PERMISSION) +@implementer(IAssociationsView) +class AssociationsContainerView(ContainerAdminView, Pagelet): + """Associations container view""" + + title = _("Associations list") + table_class = AssociationsTable + + +@adapter_config(name='associations', context=(IAssociationTarget, IPyAMSLayer, IAssociationsParentForm), + provides=IInnerSubForm) +@template_config(template='templates/associations.pt', layer=IPyAMSLayer) +@implementer(IAssociationsView) +class AssociationsView(InnerAdminDisplayForm): + """Associations view""" + + fields = field.Fields(Interface) + weight = 90 + + def __init__(self, context, request, view): + super(AssociationsView, self).__init__(context, request, view) + self.table = AssociationsTable(context, request) + self.table.view = self + + def update(self): + super(AssociationsView, self).update() + self.table.update() diff -r 826753ab9e52 -r 2912fbd45f62 src/pyams_content/component/association/zmi/templates/associations-view.pt --- a/src/pyams_content/component/association/zmi/templates/associations-view.pt Wed Sep 13 15:58:14 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -
-
- - -

- - -
-
- -
-