~mjtamlyn/sahana-eden/cert

« back to all changes in this revision

Viewing changes to controllers/hrm.py

  • Committer: Marc Tamlyn
  • Date: 2011-12-03 19:54:59 UTC
  • Revision ID: marc.tamlyn@gmail.com-20111203195459-jv32htlthw47nv3z
Make the contacts work! Doing it custom at present cos the REST doesn't want to play.

Show diffs side-by-side

added added

removed removed

Lines of Context:
521
521
 
522
522
    import itertools
523
523
 
 
524
    if r.http == 'POST':
 
525
        if '$_pr_contact' in r.post_vars:
 
526
            contact_info = json.loads(r.post_vars['$_pr_contact'])
 
527
            contact_table = db.pr_contact
 
528
            query = (contact_table.id == contact_info['id'])
 
529
            db(query).update(value=contact_info['value'])
 
530
            return json.dumps({'result': 'success'})
 
531
 
524
532
    person = r.record
525
533
 
526
534
    atable = db.pr_address
543
551
        for detail in details:
544
552
            contacts_wrapper.append(P(
545
553
                SPAN(detail.value),
546
 
                A(T('Edit'), _class='edit'),
 
554
                A(T('Edit'), _class='editBtn'),
547
555
                _id='contact-%s' % detail.id,
548
556
                _class='contact',
549
557
                ))
565
573
 
566
574
        for address in addresses:
567
575
            address_wrapper.append(P(address.building_name + ', ' + address.address))
568
 
            address_wrapper.append(A(T('Edit'), _class='edit'))
 
576
            address_wrapper.append(A(T('Edit'), _class='editBtn'))
569
577
            # Get the address form
570
578
            address_wrapper.append(DIV(
571
 
                SQLFORM(atable, address),
 
579
                SQLFORM(atable, address, _class='hidden'),
572
580
                _class='form-container',
573
581
                _id='address-edit'
574
582
            ))
580
588
    rheader = hrm_rheader(r)
581
589
 
582
590
    # Put whatever you want in here
583
 
    information = DIV(address_wrapper, contacts_wrapper)
 
591
    information = DIV(address_wrapper, contacts_wrapper, _class='information-wrapper')
584
592
 
585
593
    # Add the javascript
586
594
    response.s3.scripts.append(URL(c='static', f='scripts', args=['S3', 's3.information.js']))