You can still use SQLFORM, and append additional fields. The code is here:
http://web2py.com/books/default/chapter/29/07#Adding-extra-form-elements-to-SQLFORM

You need to add code to ensure that the user is being added to the 
particular groups under form.process().

form=SQLFORM(db.table)
//additional elements to add to the form goes here
if form.process().accepted: 
    // add them to the relevant group here
    response.flash = 'record inserted'




On Sunday, December 2, 2012 9:35:38 PM UTC+8, Daniele wrote:
>
> Alright I've created the two groups with the web2py appadmin interface. 
> Now I suppose the rest of the logic goes in the controller.
> I have a SQLFORM right now but it probably makes more sense to just use a 
> FORM, right? And then when that is processed, I can run the command 
>
> auth.add_membership(group_id, user_id)
>
> Am I on the money or is this incorrect?
> Thanks guys :D
>
>
> On Sunday, December 2, 2012 1:27:26 PM UTC, Daniele wrote:
>>
>> OK I think that's probably the easiest solution for now.
>> How can I do this? Do I need to add 
>>
>>
>> auth.add_group('role', 'description')
>>
>> in my db.py file and then have a form that when a user submits, runs
>>
>> auth.add_membership(group_id, user_id)
>>
>> in the controller? Or do both of these go inside the controller? I guess the 
>> groups only need to be created once, which is why I am assuming the first 
>> line goes in db.py
>>
>> Thanks
>>
>>
>> On Saturday, December 1, 2012 6:11:24 PM UTC, villas wrote:
>>>
>>> Put everyone in the auth_user table and use groups.  That could save you 
>>> heaps of time down the line.  Otherwise I can imagine you'll start 
>>> reinventing what's already available to you in web2py.  Use the framework 
>>> and the force will be with you!
>>>
>>> If you need to keep lots of different info depending on what group they 
>>> are in,  then you can always think about splitting that into different 
>>> tables,  but only as a last resort.
>>>
>>> Best wishes for your app,  D
>>>
>>> On Saturday, 1 December 2012 13:13:13 UTC, Daniele wrote:
>>>>
>>>> Hmmm that's one option, but here's the problem.
>>>> Basically, I want users to sign up very easily. So I'm just using 
>>>> web2py's default auth for that.
>>>> Then, I'd like them to pick if they are tutors/students or both. There 
>>>> is additional information they'd have to input in some forms for both 
>>>> roles.
>>>> While I could just create two groups, the way I have it now as tutors 
>>>> are a table and students are another table in the database.
>>>>
>>>> I guess I'm a bit lost as to how the correct way to let the signed up 
>>>> users be either students/tutors or both is. Should it all be part of the 
>>>> signed up users table? Or should I have three tables? Should I just make 
>>>> groups?
>>>>
>>>> Any advice is much appreciated,
>>>> Thanks!
>>>>
>>>>
>>>> On Friday, November 23, 2012 7:24:42 PM UTC, Joe Barnhart wrote:
>>>>>
>>>>> Why not create a group for each class -- tutor and student -- and 
>>>>> assign group membership for each student?  A student can participate in 
>>>>> more than one group.  It's easy to test for group membership -- just use 
>>>>> the decorator:
>>>>>
>>>>> @auth.requires_membership('tutor')
>>>>>
>>>>> -- Joe B.
>>>>>
>>>>>
>>>>> On Tuesday, November 20, 2012 5:57:57 PM UTC-8, Daniele wrote:
>>>>>>
>>>>>> I am trying to build a model where each logged user can decide if 
>>>>>> he/she is a tutor or student or both.
>>>>>> So the tutor table has to 'reference auth.settings.table_user_name' 
>>>>>> and student also has to have the same reference.
>>>>>>
>>>>>> The tutor/student/logged user have to be related by their id key I 
>>>>>> imagine.
>>>>>>
>>>>>> Is this the proper way to go about this? Moreover, how can I check 
>>>>>> that the relationship is working?
>>>>>>
>>>>>

-- 



Reply via email to