# HG changeset patch # User Denis Laxalde # Date 1552480598 -3600 # Node ID 4548234cccf9bc1a7c39314078eb5f52460f7f28 # Parent ef2168f389f62da6be3c026f987992ea3791811b Flake8 cubicweb/web/box.py diff -r ef2168f389f6 -r 4548234cccf9 cubicweb/web/box.py --- a/cubicweb/web/box.py Thu Mar 14 14:38:55 2019 +0100 +++ b/cubicweb/web/box.py Wed Mar 13 13:36:38 2019 +0100 @@ -29,10 +29,10 @@ from cubicweb.schema import display_name from cubicweb.predicates import no_cnx, one_line_rset from cubicweb.view import View -from cubicweb.web import INTERNAL_FIELD_VALUE, stdmsgs from cubicweb.web.htmlwidgets import (BoxLink, BoxWidget, SideBoxWidget, RawBoxItem, BoxSeparator) from cubicweb.web.action import UnregisteredAction +from cubicweb.web.component import AjaxEditRelationCtxComponent, EditRelationMixIn def sort_by_category(actions, categories_in_order=None): @@ -41,13 +41,13 @@ actions_by_cat = {} for action in actions: actions_by_cat.setdefault(action.category, []).append( - (action.title, action) ) + (action.title, action)) for key, values in actions_by_cat.items(): actions_by_cat[key] = [act for title, act in sorted(values, key=lambda x: x[0])] if categories_in_order: for cat in categories_in_order: if cat in actions_by_cat: - result.append( (cat, actions_by_cat[cat]) ) + result.append((cat, actions_by_cat[cat])) for item in sorted(actions_by_cat.items()): result.append(item) return result @@ -69,7 +69,9 @@ box.render(self.w) """ - __deprecation_warning__ = '[3.10] *BoxTemplate classes are deprecated, use *CtxComponent instead (%(cls)s)' + __deprecation_warning__ = ( + '[3.10] *BoxTemplate classes are deprecated, use *CtxComponent instead (%(cls)s)' + ) __registry__ = 'ctxcomponents' __select__ = ~no_cnx() @@ -78,13 +80,13 @@ cw_property_defs = { _('visible'): dict(type='Boolean', default=True, help=_('display the box or not')), - _('order'): dict(type='Int', default=99, - help=_('display order of the box')), + _('order'): dict(type='Int', default=99, + help=_('display order of the box')), # XXX 'incontext' boxes are handled by the default primary view _('context'): dict(type='String', default='left', vocabulary=(_('left'), _('incontext'), _('right')), help=_('context where this box should be displayed')), - } + } context = 'left' def sort_actions(self, actions): @@ -161,8 +163,6 @@ """classes inheriting from EntityBoxTemplate should define cell_call""" self.cell_call(row, col, **kwargs) -from cubicweb.web.component import AjaxEditRelationCtxComponent, EditRelationMixIn - class EditRelationBoxTemplate(EditRelationMixIn, EntityBoxTemplate): """base class for boxes which let add or remove entities linked @@ -172,6 +172,7 @@ class attributes. """ rtype = None + def cell_call(self, row, col, view=None, **kwargs): self._cw.add_js('cubicweb.ajax.js') entity = self.cw_rset.get_entity(row, col) diff -r ef2168f389f6 -r 4548234cccf9 flake8-ok-files.txt --- a/flake8-ok-files.txt Thu Mar 14 14:38:55 2019 +0100 +++ b/flake8-ok-files.txt Wed Mar 13 13:36:38 2019 +0100 @@ -113,6 +113,7 @@ cubicweb/test/unittest_wfutils.py cubicweb/toolsutils.py cubicweb/web/application.py +cubicweb/web/box.py cubicweb/web/formwidgets.py cubicweb/web/test/data/entities.py cubicweb/web/test/unittest_application.py