Hello
I have to make a validator on my SQLFORM that checks 4 fields
my table is
db.define_table('workers_skills',
Field('ws_organisation', type ='integer'),
Field('ws_worker', 'reference workers', label = T('Worker')),
Field('ws_skill', 'reference skills', label = T('Skill')),
Field('ws_priority', type ='integer', label = T('Priority')),
Field ('ws_status', type= 'integer', label = T('Status'),
widget = SQLFORM.widgets.options.widget, default = 1),
migrate = settings.migrate)
The check is on fields ws_organisation, ws_worker, ws_skill and ws_priority
So a worker cannot have the same ws_priority value for two different
skills.
this are the validators already set
db.workers_skills.ws_priority.requires = [IS_NOT_EMPTY(error_message=T('Missing
priority level')),
IS_INT_IN_RANGE(1,
100000,error_message=T('Priority cannot be 0 or larger then 100000!'))
db.workers_skills.ws_worker.requires = IS_IN_DB(
db((db.workers.w_organisation == org) &
(db.workers.w_status < 100)),
db.workers.id, '%(w_nick_name)s -
%(w_last_name)s %(w_first_name)s', zero=T('Select worker'))
#preprečmo da bi ble podvojene vrednosti isti delavc isti skill pa da je
dropdown mani sk_name glede na organizacijo
db.workers_skills.ws_skill.requires = IS_IN_DB(db((db.skills.sk_organisation ==
org) &
(db.skills.sk_status < 100)),
db.skills.id, '%(sk_name)s',
zero=T('Select skill'),
_and=IS_NOT_IN_DB(db(db.workers_skills.ws_worker == request.vars.ws_worker),
'workers_skills.ws_skill'))
What would be the most elegant way to solve this?
thank you
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.