Would you use this patch instead...

I would prefer using my personal email instead... Tortoise Hg didn't use
the proper email even if I update .hgrc because I had to restart before :(

Thanks


Richard


On Wed, Dec 4, 2013 at 11:57 AM, Richard Vézina <ml.richard.vez...@gmail.com
> wrote:

> Hello,
>
> I get in trouble with Github and can't commit when I make change for some
> reasons... The folks at github investigate about the issue...
>
> So here a patch, see attachement.
>
> Richard
>
>
> On Tue, Dec 3, 2013 at 5:25 PM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> yes please.
>>
>>
>> On Tuesday, 3 December 2013 12:00:54 UTC-6, Richard wrote:
>>
>>> Would you I make a patch on Github?
>>>
>>> Richard
>>>
>>>
>>> On Tue, Dec 3, 2013 at 12:58 PM, Massimo Di Pierro <
>>> massimo....@gmail.com> wrote:
>>>
>>>> I opened a ticket and will process asap.
>>>>
>>>>
>>>> On Monday, 2 December 2013 14:46:41 UTC-6, Richard wrote:
>>>>>
>>>>> Hello,
>>>>>
>>>>> I set a label True/False flag for checkbox widget like so :
>>>>>
>>>>> class CheckboxesWidget(OptionsWidget):
>>>>>
>>>>>     @classmethod
>>>>>     def widget(cls, field, value, **attributes):
>>>>>         """
>>>>>         generates a TABLE tag, including INPUT checkboxes (multiple
>>>>> allowed)
>>>>>
>>>>>         see also: :meth:`FormWidget.widget`
>>>>>         """
>>>>>         # was values = re.compile('[\w\-:]+').findall(str(value))
>>>>>         if isinstance(value, (list, tuple)):
>>>>>             values = [str(v) for v in value]
>>>>>         else:
>>>>>             values = [str(value)]
>>>>>
>>>>>         attr = cls._attributes(field, {}, **attributes)
>>>>>         attr['_class'] = attr.get('_class', 'web2py_checkboxeswidget')
>>>>>
>>>>>         label = attr.get('label')
>>>>>         if not isinstance(label, bool):
>>>>>             label = True
>>>>>         elif label is True:
>>>>>             label = True
>>>>>         elif label is False:
>>>>>             label = False
>>>>>
>>>>>         requires = field.requires
>>>>>         if not isinstance(requires, (list, tuple)):
>>>>>             requires = [requires]
>>>>>         if requires and hasattr(requires[0], 'options'):
>>>>>             options = requires[0].options()
>>>>>         else:
>>>>>             raise SyntaxError('widget cannot determine options of %s'
>>>>>                               % field)
>>>>>
>>>>>         options = [(k, v) for k, v in options if k != '']
>>>>>         opts = []
>>>>>         cols = attributes.get('cols', 1)
>>>>>         totals = len(options)
>>>>>         mods = totals % cols
>>>>>         rows = totals / cols
>>>>>         if mods:
>>>>>             rows += 1
>>>>>
>>>>>         #widget style
>>>>>         wrappers = dict(
>>>>>             table=(TABLE, TR, TD),
>>>>>             ul=(DIV, UL, LI),
>>>>>             divs=(CAT, DIV, DIV)
>>>>>         )
>>>>>         parent, child, inner = wrappers[attributes.get('style',
>>>>> 'table')]
>>>>>
>>>>>         for r_index in range(rows):
>>>>>             tds = []
>>>>>             for k, v in options[r_index * cols:(r_index + 1) * cols]:
>>>>>                 if k in values:
>>>>>                     r_value = k
>>>>>                 else:
>>>>>                     r_value = []
>>>>>                 tds.append(inner(INPUT(_type='checkbox',
>>>>>                                        _id='%s%s' % (field.name, k),
>>>>>                                        _name=field.name,
>>>>>                                        requires=attr.get('requires',
>>>>> None),
>>>>>                                        hideerror=True, _value=k,
>>>>>                                        value=r_value),
>>>>>                                  LABEL(v, _for='%s%s' % (field.name,
>>>>> k)) if label is True else ''))
>>>>>             opts.append(child(tds))
>>>>>
>>>>>         if opts:
>>>>>             opts.append(
>>>>>                 INPUT(requires=attr.get('requires', None),
>>>>>                       _style="display:none;",
>>>>>                       _disabled="disabled",
>>>>>                       _name=field.name,
>>>>>                       hideerror=False))
>>>>>         return parent(*opts, **attr)
>>>>>
>>>>> The purpose of this change is in context where a user need single
>>>>> checkbox for each row of a grid where he don't need to display a label
>>>>> beside the checkbox, since he only want to know which record is checked 
>>>>> and
>>>>> need to be updated...
>>>>>
>>>>> I need that in order to create a special form that allow bunch/batch
>>>>> records update, see attach image (sorry I had to hide data of some
>>>>> columns)... You can see, that each row has a checkbox that is generated
>>>>> like this :
>>>>>
>>>>> form_fields = [Field('checkbox_%s' % r['table'].id, 'integer',
>>>>>                          requires=IS_EMPTY_OR(IS_IN_SE
>>>>> T([r['table'].id])),
>>>>>                           widget=lambda field, value:
>>>>> SQLFORM.widgets.checkboxes.widget(field, value, style='divs',
>>>>> label=False)) for r in rows]
>>>>>
>>>>> The form is then create with .factory() after adding the last fields
>>>>> of the models that appears in the last line of the html table on the 
>>>>> attach
>>>>> image...
>>>>>
>>>>> I can, make the change on Git and send a PR, if this change is kind of
>>>>> approved!!
>>>>>
>>>>> Thanks
>>>>>
>>>>> Richard
>>>>>
>>>>>  --
>>>> Resources:
>>>> - http://web2py.com
>>>> - http://web2py.com/book (Documentation)
>>>> - http://github.com/web2py/web2py (Source code)
>>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>>> ---
>>>> You received this message because you are subscribed to the Google
>>>> Groups "web2py-users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to web2py+un...@googlegroups.com.
>>>>
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>
>>>  --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
# HG changeset patch
# User Richard Vézina <ml.richard.vez...@gmail.com>
# Date 1386176506 18000
#      mer déc 04 12:01:46 2013 -0500
# Node ID baad0a6bfb18bffe93beac9aa5e09dbd368aa19b
# Parent  f59e42d2de63434be6ab016f236bd7ff9e6af6fc
Checkbox widget label attribute to allow display or not of label beside checkbox

diff -r f59e42d2de63 -r baad0a6bfb18 gluon/sqlhtml.py
--- a/gluon/sqlhtml.py	mar déc 03 09:32:42 2013 -0600
+++ b/gluon/sqlhtml.py	mer déc 04 12:01:46 2013 -0500
@@ -400,6 +400,14 @@
         attr = cls._attributes(field, {}, **attributes)
         attr['_class'] = attr.get('_class', 'web2py_checkboxeswidget')
 
+        label = attr.get('label')
+        if not isinstance(label, bool):
+            label = True
+        elif label is True or label is False:
+            label = label
+        else:
+            label = True
+
         requires = field.requires
         if not isinstance(requires, (list, tuple)):
             requires = [requires]
@@ -439,7 +447,7 @@
                                        requires=attr.get('requires', None),
                                        hideerror=True, _value=k,
                                        value=r_value),
-                                 LABEL(v, _for='%s%s' % (field.name, k))))
+                                 LABEL(v, _for='%s%s' % (field.name, k)) if label is True else ''))
             opts.append(child(tds))
 
         if opts:

Reply via email to