Commit 92c143cb authored by Noé Gaumont's avatar Noé Gaumont 🐙
Browse files

[pep8] Fix various pep8 error

parent bfba2d98ced1
......@@ -24,8 +24,6 @@ from logilab.mtconverter import xml_escape
_ = unicode
class TreeViewWidget(fwdgs.FieldWidget):
"""form widget to link to keywords of a given classification"""
......@@ -36,7 +34,7 @@ class TreeViewWidget(fwdgs.FieldWidget):
needs_css = ('jquery.treeview.css', 'jquery.ui.css', 'cubes.treeview.css')
html = (u'''<a href="javascript:$.noop()" '''
u'''onclick="$('#%(tree_uid)s').treewidget(%(required)s, %(multiple)s, false, {'cancelButton': '%(cancel)s', 'okButton': '%(ok)s'}) ;return false;">'''
u'''onclick="$('#%(tree_uid)s').treewidget(%(required)s, %(multiple)s, false, {'cancelButton': '%(cancel)s', 'okButton': '%(ok)s'}) ;return false;">''' # noqa
u'''%(open_link)s&nbsp;%(remove_link)s</a>'''
u'''<div id="sel_%(tree_uid)s">%(selected)s</div>'''
u'''<div id="%(tree_uid)s" style="display: none;">'''
......@@ -69,10 +67,11 @@ class TreeViewWidget(fwdgs.FieldWidget):
related = self.compute_related(form, field)
treeform = self.render_treeform(form, treerset, tree_uid, related)
remove_link = self.remove_link_html % (field.name, tree_uid, _('remove'))
selected = u'\n'.join(self.render_selected(field.input_name(form, self.suffix), related))
return self.html % {
'required': self.required,
'multiple': self.multiple,
'selected': u'\n'.join(self.render_selected(field.input_name(form, self.suffix), related)),
'selected': selected,
'tree_uid': tree_uid, 'form': treeform,
'open_link': xml_escape(_('select').capitalize()),
'remove_link': remove_link,
......@@ -127,6 +126,7 @@ class TreeViewWidget(fwdgs.FieldWidget):
yield tags.input(id=name, name=name, value='', type='hidden')
for keyword in related:
input = tags.input(id=name, name=name, value=keyword.eid, type='hidden')
yield tags.div(u'<a href="javascript:$.noop()" onclick="$(this).parent().remove()">[x]</a>'
yield tags.div(u'<a href="javascript:$.noop()" onclick="$(this).parent().remove()">[x]'
u'</a>'
u'%(input)s %(title)s' % {'input': input,
'title': xml_escape(keyword.dc_title())})
......@@ -19,15 +19,12 @@
__docformat__ = "restructuredtext en"
from cubicweb.uilib import cut
from cubicweb.web.views import baseviews, treeview
from cubicweb.predicates import is_instance, match_kwargs, adaptable
from cubicweb.predicates import match_kwargs, adaptable
from logilab.mtconverter import xml_escape
import json
_ = unicode
class TVTreeViewItemView(treeview.TreeViewItemView):
def _is_leaf(self, itree):
......@@ -116,7 +113,7 @@ class TVTreeViewEditItemView(TVTreeViewItemView):
__regid__ = 'itemvid_edit'
__select__ = (treeview.TreeView.__select__
& (match_kwargs('related', 'required', 'multiple', 'leavesonly',
'tree_uid', 'level')))
'tree_uid', 'level')))
_open_branch_memo = None
def open_state(self, eeid, treeid):
......@@ -126,8 +123,8 @@ class TVTreeViewEditItemView(TVTreeViewItemView):
is_last=False, **morekwargs):
entity = self.cw_rset.get_entity(row, col)
self._open_branch_memo = set(entity.cw_adapt_to('ITree').path())
return super(TVTreeViewEditItemView, self).cell_call(row, col, treeid, vid=vid, parentvid=parentvid,
is_last=is_last, **morekwargs)
return super(TVTreeViewEditItemView, self).cell_call(
row, col, treeid, vid=vid, parentvid=parentvid, is_last=is_last, **morekwargs)
def _is_leaf(self, itree):
return itree is None or itree.is_editable_leaf()
......@@ -142,14 +139,15 @@ class TVTreeEditView(treeview.TreeView):
itemvid = 'itemvid_edit'
__select__ = (treeview.TreeView.__select__
& (match_kwargs('related', 'required', 'multiple', 'leavesonly',
'tree_uid', 'level')) & adaptable('ITree'))
'tree_uid', 'level')) & adaptable('ITree'))
def _init_params(self, subvid, treeid, initial_load, initial_thru_ajax, morekwargs):
form = self._cw.form
initial_fname = form.get('fname', None)
if initial_fname == 'reledit_form':
form.pop('fname')
return super(TVTreeEditView, self)._init_params(subvid, treeid, initial_load, initial_thru_ajax, morekwargs)
return super(TVTreeEditView, self)._init_params(
subvid, treeid, initial_load, initial_thru_ajax, morekwargs)
class TVNotTreeEditView(treeview.DefaultTreeViewItemView):
......@@ -190,7 +188,8 @@ class TVTreeviewOneLineEditView(baseviews.InContextView):
% {'eid': entity.eid, 'sel': entity.eid
in related and u'checked="checked"' or u''})
self.w(u'<span class="hidden">%s</span>' % entity_name)
self.w(u'<a href="javascript:$.noop()" onclick="$(\'#treeitem_%s\').click()" class="selectable">'
self.w(u'<a href="javascript:$.noop()" onclick="$(\'#treeitem_%s\').click()"'
u'class="selectable">'
u'%s</a>' % (entity.eid, entity_name))
else:
self.w(u'<span>%s</span>' % (entity_name))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment