--- 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()