i think you shouldn't define the auth_user table, just keep it default, and
if you want to add the new field of auth_user table, please use
extra_fields. e.g.
# append fields : auth.signature
db._common_fields.append(auth.signature)
# custom auth user table add fields gender, address, zip_code, city,
country, phone, branch, bank, account_no
auth.settings.extra_fields['auth_user'] = [
Field('gender',
label = T('Gender'),
notnull = True,
required = True,
requires = IS_IN_SET({T('Male'), T('Female') } ) ),
Field('address', 'text',
label = T('Address'),
notnull = True,
represent = lambda address, field: A(address, _title=T("View Maps"),
_target="_blank",
_href="http://maps.google.com/maps?f=q&hl=en&geocode=&time=&date=&ttype=&q=%s,+%s,+%s"
% (field.address, field.city, field.country) ),
required = True,
requires = IS_NOT_EMPTY() ),
Field('zip_code',
label = T('Zip Code'),
notnull = True,
required = True,
requires = IS_MATCH('^\d{5,5}$', error_message = 'not a Zip Code') ),
Field('city',
label = T('City'),
notnull = True,
required = True,
requires = IS_NOT_EMPTY() ),
Field('country',
label = T('Country'),
notnull = True,
required = True,
requires = IS_NOT_EMPTY() ),
Field('phone', 'list:string',
label = T('Phone'),
notnull = True,
required = True),
Field('branch', 'reference branch',
label = T('Branch'),
notnull = True,
required = True,
requires = IS_IN_DB(db, db.branch.id, '%(address)s') ),
Field('bank', 'reference bank',
label = T('Bank'),
notnull = True,
represent = lambda bank, field: A(bank.bank, _title=T("eBanking"),
_target="_blank", _href="%s" % bank.ebanking),
required = True,
requires = IS_IN_DB(db, db.bank.id, '%(bank)s') ),
Field('account_no',
label = T('Account No'),
notnull = True,
required = True,
requires = IS_NOT_EMPTY() ),
]
# create all tables needed by auth if not custom tables, add username field
auth.define_tables(username = True, signature = True)
""" custom_auth_table """
custom_auth_table = db[auth.settings.table_user_name]
# label
custom_auth_table.first_name.label = T('First Name')
custom_auth_table.last_name.label = T('Last Name')
custom_auth_table.email.label = T('Email')
# represent
custom_auth_table.email.represent = lambda email, field: \
A(email, _title=T("Send to %s") % email, _target="_blank",
_href="mailto:%s" % email)
# requires
custom_auth_table.phone.requires = IS_NOT_IN_DB(db, custom_auth_table.phone)
auth.settings.table_user = custom_auth_table
best regards,
stifan
--
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/groups/opt_out.