[web2py] Re: Add extra fields to db.auth_user

2016-01-30 Thread Ron Chatterjee
Beside adding extra field, is it possible to split the table for auth_user? 
For example, I want the profile to be broken in different tables based on 
address, education, portfolio...etc. that someone can create a profile. And 
add fields to that tables as that person see fit. 



On Wednesday, December 4, 2013 at 11:56:06 AM UTC-5, Gael Princivalle wrote:

> Thanks a lot Massimo, in fact I've made testing on an existing user. Now 
> with requires=IS_NOT_EMPTY() the form ask to fill the company field. 
> Perfect.
>
> For problem 2 I'm gone define my own auth_user table, have a nice day.
>
> Il giorno mercoledì 4 dicembre 2013 16:29:14 UTC+1, Massimo Di Pierro ha 
> scritto:
>>
>> I cannot reproduce problem 1. There is nothing wrong in your code and 
>> something else is causing the problem. Are you sure the issue is that "A 
>> user can register without filling this field." or is it the users who 
>> registered before the contraint was introduced do not have a company field?
>>
>> Problem 2. To fix that you need define your own auth_user table. If you 
>> do:
>>
>> db.define_table('auth_user', )
>>
>> before auth.define_tables() it should use yours.
>>
>> On Tuesday, 3 December 2013 09:14:02 UTC-6, Gael Princivalle wrote:
>>>
>>> Hi.
>>>
>>> I've had extra fields to db.auth_user like that in db.py:
>>>
>>> auth = Auth(db)
>>> auth.settings.extra_fields['auth_user']= [Field('Company', 
>>> requires=IS_NOT_EMPTY()),Field('Phone')]
>>>
>>> Problem n°1, requires=IS_NOT_EMPTY() don't have any effect. A user can 
>>> register without filling this field.
>>>
>>> Problem n° 2, Company and Phone fields are in the form after passwords 
>>> field, I would like to change the fild order.
>>>
>>> How can I do it ?
>>>
>>> Thanks.
>>>
>>

-- 
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/d/optout.


[web2py] Re: Add extra fields to db.auth_user

2013-12-04 Thread Gael Princivalle
Thanks James but also required=True don't have any effect. Perhaps I have 
to make a custom form or register, do you know I can do it ? 

Il giorno martedì 3 dicembre 2013 19:56:39 UTC+1, James Burke ha scritto:

 For problem no1, you could try using required=True instead of 
 requires=IS_NOT_EMPTY()

 For your second problem you can define the auth_user table yourself (from 
 web2py book):

 Another way to do this, although not really recommended, consists of 
 defining your auth tables yourself. If a table is declared before 
 auth.define_tables() it is used instead of the default one. Here is how 
 to do it:

 ## after auth = Auth(db)
 db.define_table(
 auth.settings.table_user_name,
 Field('first_name', length=128, default=''),
 Field('last_name', length=128, default=''),
 Field('email', length=128, default='', unique=True), # required
 Field('password', 'password', length=512,# required
   readable=False, label='Password'),
 Field('address'),
 Field('city'),
 Field('zip'),
 Field('phone'),
 Field('registration_key', length=512,# required
   writable=False, readable=False, default=''),
 Field('reset_password_key', length=512,  # required
   writable=False, readable=False, default=''),
 Field('registration_id', length=512, # required
   writable=False, readable=False, default=''))

 ## do not forget validators
 custom_auth_table = db[auth.settings.table_user_name] # get the 
 custom_auth_table
 custom_auth_table.first_name.requires =   
 IS_NOT_EMPTY(error_message=auth.messages.is_empty)
 custom_auth_table.last_name.requires =   
 IS_NOT_EMPTY(error_message=auth.messages.is_empty)
 custom_auth_table.password.requires = [IS_STRONG(), CRYPT()]
 custom_auth_table.email.requires = [
   IS_EMAIL(error_message=auth.messages.invalid_email),
   IS_NOT_IN_DB(db, custom_auth_table.email)]

 auth.settings.table_user = custom_auth_table # tell auth to use 
 custom_auth_table

 ## before auth.define_tables()



-- 
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.


[web2py] Re: Add extra fields to db.auth_user

2013-12-04 Thread Massimo Di Pierro
I cannot reproduce problem 1. There is nothing wrong in your code and 
something else is causing the problem. Are you sure the issue is that A 
user can register without filling this field. or is it the users who 
registered before the contraint was introduced do not have a company field?

Problem 2. To fix that you need define your own auth_user table. If you do:

db.define_table('auth_user', )

before auth.define_tables() it should use yours.

On Tuesday, 3 December 2013 09:14:02 UTC-6, Gael Princivalle wrote:

 Hi.

 I've had extra fields to db.auth_user like that in db.py:

 auth = Auth(db)
 auth.settings.extra_fields['auth_user']= [Field('Company', 
 requires=IS_NOT_EMPTY()),Field('Phone')]

 Problem n°1, requires=IS_NOT_EMPTY() don't have any effect. A user can 
 register without filling this field.

 Problem n° 2, Company and Phone fields are in the form after passwords 
 field, I would like to change the fild order.

 How can I do it ?

 Thanks.


-- 
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.


[web2py] Re: Add extra fields to db.auth_user

2013-12-04 Thread Gael Princivalle
Thanks a lot Massimo, in fact I've made testing on an existing user. Now 
with requires=IS_NOT_EMPTY() the form ask to fill the company field. 
Perfect.

For problem 2 I'm gone define my own auth_user table, have a nice day.

Il giorno mercoledì 4 dicembre 2013 16:29:14 UTC+1, Massimo Di Pierro ha 
scritto:

 I cannot reproduce problem 1. There is nothing wrong in your code and 
 something else is causing the problem. Are you sure the issue is that A 
 user can register without filling this field. or is it the users who 
 registered before the contraint was introduced do not have a company field?

 Problem 2. To fix that you need define your own auth_user table. If you do:

 db.define_table('auth_user', )

 before auth.define_tables() it should use yours.

 On Tuesday, 3 December 2013 09:14:02 UTC-6, Gael Princivalle wrote:

 Hi.

 I've had extra fields to db.auth_user like that in db.py:

 auth = Auth(db)
 auth.settings.extra_fields['auth_user']= [Field('Company', 
 requires=IS_NOT_EMPTY()),Field('Phone')]

 Problem n°1, requires=IS_NOT_EMPTY() don't have any effect. A user can 
 register without filling this field.

 Problem n° 2, Company and Phone fields are in the form after passwords 
 field, I would like to change the fild order.

 How can I do it ?

 Thanks.



-- 
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.


[web2py] Re: Add extra fields to db.auth_user

2013-12-03 Thread James Burke
For problem no1, you could try using required=True instead of 
requires=IS_NOT_EMPTY()

For your second problem you can define the auth_user table yourself (from 
web2py book):

Another way to do this, although not really recommended, consists of 
defining your auth tables yourself. If a table is declared before 
auth.define_tables() it is used instead of the default one. Here is how to 
do it:

## after auth = Auth(db)
db.define_table(
auth.settings.table_user_name,
Field('first_name', length=128, default=''),
Field('last_name', length=128, default=''),
Field('email', length=128, default='', unique=True), # required
Field('password', 'password', length=512,# required
  readable=False, label='Password'),
Field('address'),
Field('city'),
Field('zip'),
Field('phone'),
Field('registration_key', length=512,# required
  writable=False, readable=False, default=''),
Field('reset_password_key', length=512,  # required
  writable=False, readable=False, default=''),
Field('registration_id', length=512, # required
  writable=False, readable=False, default=''))

## do not forget validators
custom_auth_table = db[auth.settings.table_user_name] # get the 
custom_auth_table
custom_auth_table.first_name.requires =   
IS_NOT_EMPTY(error_message=auth.messages.is_empty)
custom_auth_table.last_name.requires =   
IS_NOT_EMPTY(error_message=auth.messages.is_empty)
custom_auth_table.password.requires = [IS_STRONG(), CRYPT()]
custom_auth_table.email.requires = [
  IS_EMAIL(error_message=auth.messages.invalid_email),
  IS_NOT_IN_DB(db, custom_auth_table.email)]

auth.settings.table_user = custom_auth_table # tell auth to use 
custom_auth_table

## before auth.define_tables()

-- 
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.