Sorry, wasn't too clear. I posted the code....What I am trying to do is, I
have a table call consumer. It has a profile statement.
auth.settings.register_onaccept = lambda form: after_registration(form)
I use this to create that profile.
I would like that to be updated when someone update their profile.
On Tuesday, May 17, 2016 at 11:50:17 AM UTC-4, villas wrote:
>
> Why not use auth.settings.profile_onaccept or profile_next to simply
> redirect to another url. You can easily access your auth info, create a
> new form, or even post auth info into another table.
>
> It isn't clear what you are trying to do.
>
> If you need better access to auth.profile function then you could use
> auth.profile() feature as per book:
>
> def myprofile(): return dict(form=auth.profile())
>
>
> If you need to update or create a consumer record, then do that in a
> completely different function. Simply redirect there setting args or
> vars.
>
> If you want your auth information available, you can always access it
> like this: auth.user.last_name
>
> Also don't forget that db.auth_user is a table like any other. You can
> access it and read or write information, if that's what you'd like to do.
>
>
>
> On Tuesday, 17 May 2016 14:54:52 UTC+1, Ron Chatterjee wrote:
>>
>> Profile onaccept works but my logic is wrong I am guessing because it
>> escapes and always end up going to index page
>>
>> Basically I am trying to update the form (which I call form2) with the
>> info that was used to create db.consumer
>>
>> in db I have
>> auth.settings.profile_onaccept = lambda form: profile_update(form)
>>
>> db.define_table("consumer",
>> Field("seller_profile", 'reference auth_user', readable =
>> False, writable = False, widget=SQLFORM.widgets.options.widget, requires=
>> IS_EMPTY_OR(IS_IN_DB(db,db.auth_user.id))),
>> Field("profile_statement", "text", label='Profile
>> hightlights*',requires=IS_NOT_EMPTY(),comment='Write few things to
>> summarize your profile'))
>>
>> That brings it to the controller
>> def profile_update(form):
>> form2 = [];
>> db.consumer.seller_profile.default = auth.user_id
>> if form.vars.user_type != 'Seller':
>> redirect(URL('default','index'))
>>
>> else:
>> query = (db.consumer.created_by==auth.user_id);
>> profile= db(query).select();
>> form2 = SQLFORM(db.consumer,profile[0].id,deletable=True,
>> submit_button='Update Profile').process()
>> if form2.accepted:
>> session.flash = T('Profile is modified')
>> return dict(form2 = form2)
>>
>>
>> in view profile_update I have {{=form2}}
>>
>> Any thoughts?
>>
>> On Tuesday, May 17, 2016 at 4:37:37 AM UTC-4, villas wrote:
>>>
>>> There is:
>>>
>>> profile_next and profile_onaccept
>>>
>>
--
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.