sqlform time field value representation

28 views
Skip to first unread message

Yebach

unread,
Apr 14, 2016, 9:44:00 AM4/14/16
to web2py-users
Hello

I have the following problem. I have SQLFORM.grid

When I go to edit view i have 4 fields which should be represented as time (clock picker etc)

Once the form is submited only one field is actually send as datetime.time other are as strings. I have no idea why

Also if I edit time fields the value send it '16:00' but if I do not edit them the value is from db '16:00:00'

<Storage {'sh_color': '993199', 'sh_status': '1', 'sh_length2': 1380, 'sh_end2': '05:00:00', 'sh_start2': datetime.time(6, 0), 'sh_start1': '00:00:00', 'sh_name': 'Testriam zta \xc4\x8dase', 'sh_length1': 210, 'sh_note': '', 'sh_duration': 1590, 'sh_code': '0000-0330&0600-0500', 'sh_end1': '03:30'}>


in my model


db.define_table('shifts',
Field('sh_organisation' , 'reference organizations', label = T('Organization')),
Field('sh_code', type= 'string', length = 256, label = T('Code')),
Field('sh_status', type= 'integer', label = T('Status'), widget = SQLFORM.widgets.options.widget, default = 1),
Field('sh_name', type= 'string', length = 256 ,label = T('Name'),requires = IS_NOT_EMPTY(error_message=T('Missing shift name!'))),
Field('sh_color', type= 'string',label = T('Color')), # widget = color_widget,
Field('sh_start1', type= 'time',length = 4, label = T('Start'),requires = IS_NOT_EMPTY(error_message=T('Insert start time')),represent=repr),
Field('sh_end1', type= 'time', label = T('End'),requires=IS_NOT_EMPTY(error_message=T('Insert end time')) if request.post_vars.sh_start1 else None,represent=repr),
Field('sh_length1', type= 'integer', label = T('Length 1'),represent=repr),
Field('sh_start2', type= 'time', label = T('Start 2'),represent=repr),
Field('sh_end2', type= 'time', label = T('End 2'), requires=IS_NOT_EMPTY(error_message=T('Insert second end time')) if request.post_vars.sh_start2 else None,represent=repr),
Field('sh_length2', type= 'integer', label = T('Length 2'),represent=repr),
Field('sh_start3', type= 'time', label = T('Start 3')),
Field('sh_end3', type= 'time',label = T('End ')),
Field('sh_length3', type= 'integer', label = T('Length 3')),
Field('sh_start4', type= 'time', label = T('Start 4')),
Field('sh_end4', type= 'time',label = T('End 4')),
Field('sh_length4', type= 'integer', label = T('Length 4')),
Field('sh_start5', type= 'time', label = T('Start 5')),
Field('sh_end5', type= 'time', label = T('End 5')),
Field('sh_length5', type= 'time', label = T('Length 5')),
Field('sh_duration', type= 'integer', label = T('Duration')),
Field('sh_duration1', type= 'integer', label =T('Duration 2')),
Field('sh_note', type= 'text', label = T('Note')),
migrate=settings.migrate
)


where repr = lambda v, r: v if v is not None else ''



Reply all
Reply to author
Forward
0 new messages