from gluon.utils import web2py_uuid
db.define_table('token',Field('email'),Field('patient_code',default=web2py_uuid()[:4])
auth.settings.extra_fields['auth_user'] = [Field('patient_code
',writable=False)]

if controller

def user():
     if request.args(0) == 'register':
            db.auth_user.patient_code.writable=True
            db.auth_user.patient_code.writable.requires = 
[IS_IN_DB(db(db.token,email==request.vars.email),'patient_code')]
     return dict(form=auth())

On Wednesday, 1 October 2014 14:09:37 UTC-5, Nick C wrote:
>
> Hi, I have a few questions regarding the design of my app:
>
> -Let's say there are two types of users, "doctors" and "patients"; they 
> have different properties. For example, a patient will specify his height 
> and weight, but a doctor will not.  I would like both patients and doctors 
> to have to be registered and logged in to use the system.  How do I handle 
> this situation?  Can there be multiple auth tables?  Or is it better to 
> somehow use a single auth_user table?
>
> -Furthermore, I would like doctors, when they register, to require 
> administrator approval before their account is created.  But not patients. 
>  It seems like requiring administrator approval is handled by:
>
> auth.settings.registration_requires_approval = True
>
> but again, the issue seems to be one of wanting one sort of auth behavior for 
> one group of users, and another auth behavior for the other group; how do I 
> achieve this?
>
> -When a new patient is to be added to the system, I would like it to work 
> like this:
>
>    (a) a logged-in doctor clicks "add new patient"; this creates a new 
> patient id (say it's an 8 digit number, 12345678), and gives this number to 
> the patient
>
>    (b) the patient goes home, and registers, and during registration, is 
> asked for his patient id; if his patient id was not generated by a doctor in 
> step (a), he cannot register.
>
> I was thinking of implementing this by having a db table called 
> "pending_patients"; when the doctor clicks "Add new patient", a new id is 
> generated and placed into this table.  Then with the patient registration, I 
> thought I would have a IS_IN_DB() validator that checks whether the id they 
> input is in the "pending_patients" table.  Is this a reasonable way to do 
> this?
>
> Thanks in advance for any help.
>
> -Nick
>
>
>

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

Reply via email to