This is perfect, Richard!! Thank you!

I didn't realize how record worked. That is really an eye opener. If there 
is no record for the user I get an error, so I'll have to work on that, but 
this is exactly what I was looking for. Thank you!

On Friday, March 27, 2015 at 10:38:51 AM UTC-4, Richard wrote:
>
> You don't give the record id to the SQLFORM(table, *record*)
>
> If you pass the record id of you stored app parameters you should be able 
> to update the user prefs instead of creating new record prefs each time...
>
> Read SQLFORM doc in book chapter "Forms" 7 I think...
>
> In you case, you will have to retrieve unique_view_peruser record id 
> first with a query like so :
>
> prefs_id = db(db.unique_view_peruser.auth_user_id == auth.user_id).select(
> db.unique_view_peruser.id).first().id
>
> Then
>
> SQLFORM(db.unique_view_peruser, record=prefs_id)
>
> You should be ok to update the right record instead of create a new one...
>
> Richard
>
> On Fri, Mar 27, 2015 at 10:12 AM, LoveWeb2py <atayl...@gmail.com 
> <javascript:>> wrote:
>
>> Hi Richard,
>>
>> Thank you for responding. 
>>
>> I'm basically letting a user create their own view for SQLFORM.grid, by 
>> choosing which fields to use by selecting them.
>>
>> db.unique_view_peruser is my table which allows each user to go and check 
>> the boxes of the fields they want to view. It's just booleans that are set 
>> to On or Off.
>>
>> Whatever they choose I want to select the fields in another table (which 
>> mirror the unique_view_peruser). The problem is each time I access 
>> SQLFORM(db.unique_view_peruser) it simply inserts the record instead of 
>> retrieves the previous selection. I know this is something which has to 
>> reference the db.auth_user.id, but it doesn't seem to be working the way 
>> I had imagined.
>>
>> On Friday, March 27, 2015 at 10:00:49 AM UTC-4, Richard wrote:
>>>
>>> If you only want the user to see the data but not edit : 
>>> readonly=True...
>>>
>>> Richard
>>>
>>> On Fri, Mar 27, 2015 at 9:59 AM, Richard Vézina <ml.richa...@gmail.com> 
>>> wrote:
>>>
>>>> You mean a profile page with user only allow to update their profile ??
>>>>
>>>> SQLFORM(db.auth_user, record=*auth.user_id*)
>>>>
>>>> It is not clear to understand your goal...
>>>>
>>>> Richard
>>>>
>>>> On Fri, Mar 27, 2015 at 9:32 AM, LoveWeb2py <atayl...@gmail.com> wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> I have a database with a few hundred users. How could I allow them to 
>>>>> each have their own SQLFORM without modifying auth.user
>>>>>
>>>>> here is what I have so far:
>>>>>
>>>>>
>>>>> #model
>>>>> db.define_table('unique_view_peruser','
>>>>>         Field('auth_user_id',' db.auth_user, default=auth.user_id, 
>>>>> writable=False),
>>>>>         Field('field1','boolean'),
>>>>>         Field('field2','boolean'),
>>>>>         migrate=False)
>>>>>
>>>>> #controller
>>>>> def unique_view():
>>>>>      grid = SQLFORM(db.unique_view_peruser)
>>>>>      return dict(grid=grid)
>>>>>
>>>>> when I click on the boolean buttons they're not being updated or 
>>>>> insert into the database. I'm using MYSQL and each field is specified as 
>>>>> a 
>>>>> boolean.
>>>>>
>>>>> How could I allow each user to come to the view, click on the 
>>>>> different fields they'd like and have it insert the database. Will it 
>>>>> automatically create the record for them if they don't have a record 
>>>>> associated with their id?
>>>>>
>>>>> 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+un...@googlegroups.com.
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>
>>>  -- 
>> 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+un...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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

Reply via email to