Maybe something like:
def add_company(user_set, fields):
if 'registration_key' in fields and not fields['registration_key']:
for user in user_set.select():
dbs.company.update_or_insert(name=user.Company, created_by=user.
id)
dbs.auth_user._after_update.append(add_company)
So, whenever you explicitly set the registration_key of some records to
blank, it will make inserts into the company table (though not if the
record already exists).
Anthony
On Friday, August 29, 2014 1:32:55 PM UTC-4, asumal wrote:
>
> Hello everyone,
>
> My situation. I would like to approve every user that signs up with my
> site. I understand that I should set the following to True (in db.py):
>
> auth.settings.registration_requires_approval = True
>
>
> After I approve the user, I would like to insert a value into the
> database. I tried the following (in default.py):
>
> auth.settings.register_onaccept.append(lambda form: __add_company(form))
>>
>
>
> def __add_company(form):
>> print 'user.id', auth.user_id
>> dbs.company.insert(name = form.vars.Company, created_by =
>> auth.user_id)
>
>
> However, this inserts the value when the user signs up and before I can
> verify. Also, the auth.user_id is None because the user is not signed in.
> Is there another way to do this? Is there a function that runs after an
> update to the auth.user_id.
>
--
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.