~sahana-eden-jp/sahana-eden/reload_s3

« back to all changes in this revision

Viewing changes to controllers/budget.py

  • Committer: Fran Boon
  • Date: 2009-05-14 20:46:22 UTC
  • Revision ID: flavour@partyvibe.com-20090514204622-tbm4objxm11qgieb
Reusable Deletion_Status field for Synchronization
Security Model implementation for 'full'
- default permissions: all registered users are able to Read & only Administrators & users specifically added to 'Editors' able to Edit
Progress with Budgetting module's M2M controller
- fix kit description in kit_item_list_create
- make Total Costs visible when adding/removing items
Update Auth in sahana.py to sync with current Web2Py trunk
Expose new LDAP Auth option in __db.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
    
53
53
    title=db.budget_kit[kit].code
54
54
    description=db.budget_kit[kit].description
 
55
    total_cost=db.budget_kit[kit].total_unit_cost
 
56
    monthly_cost=db.budget_kit[kit].total_monthly_cost
55
57
    query = table.kit_id==kit
 
58
    # Start building the Return with the common items
 
59
    output=dict(module_name=module_name,modules=modules,options=options,title=title,description=description,total_cost=total_cost,monthly_cost=monthly_cost)
56
60
    if authorised:
57
61
        # Display a List_Create page with editable Quantities
58
62
        item_list=[]
59
63
        sqlrows=db(query).select()
 
64
        forms=Storage()
60
65
        even = True
61
66
        for row in sqlrows:
62
67
            if even:
66
71
                theclass = "odd"
67
72
                even = True
68
73
            id = row.item_id
69
 
            description = db.budget_item[id].description
 
74
            forms[id]=SQLFORM(table,id)
 
75
            if forms[id].accepts(request.vars,session):
 
76
                response.flash=T("Quantity Updated")
 
77
            item_description = db.budget_item[id].description
70
78
            id_link = A(id,_href=URL(r=request,f='item',args=['read',id]))
71
79
            quantity_box = INPUT(_value=row.quantity,_size=4)
 
80
            #quantity_box = INPUT(_value=forms[id].custom.dspval.quantity,_size=4)
72
81
            checkbox = INPUT(_type="checkbox",_value="on",_name=kit,_id=id,_class="remove_item")
73
 
            item_list.append(TR(TD(id_link),TD(description),TD(quantity_box),TD(checkbox),_class=theclass))
 
82
            item_list.append(TR(TD(id_link),TD(item_description),TD(quantity_box),TD(checkbox),_class=theclass))
74
83
            
75
84
        table_header=THEAD(TR(TH('ID'),TH(table.item_id.label),TH(table.quantity.label),TH(T('Delete'))))
76
85
        table_footer=TFOOT(TR(TD(_colspan=2),TD(INPUT(_id='submit_quantity_button', _type='submit', _value=T('Update'))),TD(INPUT(_id='submit_delete_button', _type='submit', _value=T('Delete')))))
77
 
        items=DIV(FORM(TABLE(table_header,TBODY(item_list),table_footer,_id="table-container"),_method='post', _enctype='multipart/form-data', _action=''))
 
86
        items=DIV(FORM(TABLE(table_header,TBODY(item_list),table_footer,_id="table-container"),_name='custom',_method='post', _enctype='multipart/form-data', _action=''))
78
87
        subtitle=T("Contents")
79
88
        
80
89
        crud.settings.submit_button='Add'
84
93
        form=crud.create(table,next=URL(r=request,args=[kit]))
85
94
        addtitle=T("Add New Item to Kit")
86
95
        response.view='%s/kit_item_list_create.html' % module
87
 
        return dict(module_name=module_name,modules=modules,options=options,title=title,description=description,subtitle=subtitle,items=items,addtitle=addtitle,form=form,kit=kit)
 
96
        output.update(dict(subtitle=subtitle,items=items,addtitle=addtitle,form=form,kit=kit))
 
97
        return output
88
98
    else:
89
99
        # Display a simple List page
90
100
        table.kit_id.readable=False
97
107
        id = 'item_id'
98
108
        items=crud.select(table,query=query,fields=fields,headers=headers,linkto=linkto,id=id)
99
109
        response.view='%s/kit_item_list.html' % module
100
 
        return dict(module_name=module_name,modules=modules,options=options,title=title,description=description,items=items)
 
110
        output.update(dict(items=items))
 
111
        return output
101
112
 
102
113
def totals(form):
103
114
    "Calculate Totals for the Kit"