~chamindra/sahana-eden/frp3

« back to all changes in this revision

Viewing changes to controllers/or.py

  • Committer: nursix.org
  • Date: 2010-02-15 01:29:48 UTC
  • Revision ID: dominic@nursix.org-20100215012948-kdzt8v2unjq5gdnt
Tags: 0.9.7
frp-0.9.7

Add Contact => Drop-down list for person

Show diffs side-by-side

added added

removed removed

Lines of Context:
183
183
 
184
184
    def shn_contact_prep(xr):
185
185
        if xr.representation=='html' and xr.method=='create':
186
 
            table_contact.person_id.requires = IS_ONE_OF_EMPTY(db, 'pr_person.id')
 
186
            contact_persons = db(table_person.id==table_contact.person_id).select(table_person.id)
 
187
            if contact_persons:
 
188
                contact_persons = [p.id for p in contact_persons]
 
189
            else:
 
190
                contact_persons = []
 
191
            table_contact.person_id.requires = IS_ONE_OF(
 
192
                db(~table_person.id.belongs(contact_persons)), 'pr_person.id', shn_pr_person_represent)
187
193
            table_contact.organisation_id.requires = IS_NULL_OR(IS_ONE_OF_EMPTY(db, 'or_organisation.id'))
188
194
        else:
189
195
            table_contact.person_id.writable = False