~ideamonk/sahana-eden/gsoc

« back to all changes in this revision

Viewing changes to models/01_extcrud.py

  • Committer: ideamonk
  • Date: 2010-08-16 17:03:24 UTC
  • Revision ID: abhishekmishra@mbp.local-20100816170324-bm9f36i24qihohua
fixed creat_list views, added dirty hacks to handle it, createProxy changed to hook format param properly, need @value to solve value less references 

Show diffs side-by-side

added added

removed removed

Lines of Context:
180
180
 
181
181
    if not list_fields:
182
182
        list_fields = [ f for f in headers.keys() ]
183
 
 
184
183
    output.update(headers=headers, list_fields=list_fields, authorised=authorised)
185
184
    shn_custom_view(r, "list.html")
186
185
    return output
207
206
    #if jr.method in ("create", "update"):
208
207
    # not caring about action, sometime default one has a form too  # ^ would have a form
209
208
    # or in case of calls needed from within views like list_create
 
209
    if jr.response.view == "s3ui_list_create.html":
 
210
        ## WARNING DIRTY HACK AHEAD -
 
211
        list_fields = s3xrc.model.get_config(jr.table, "list_fields")
 
212
        # Which fields do we display?
 
213
        fields = None
 
214
        if list_fields:
 
215
            fkey = jr.fkey or None
 
216
            fields = [f for f in list_fields if jr.table[f].readable and f != fkey]
 
217
        if fields and len(fields) == 0:
 
218
            fields.append("id")
 
219
        if not fields:
 
220
            fields = [f for f in jr.table.fields if jr.table[f].readable]
 
221
        headers = dict(map(lambda f: (jr.table[f].name,
 
222
            {'label':jr.table[f].label, 'type':jr.table[f].type, 'writable':jr.table[f].writable,
 
223
                            'has_options':has_options(jr.table[f].requires)}), fields))
 
224
        
 
225
        if not list_fields:
 
226
            list_fields = [ f for f in headers.keys() ]
 
227
        output.update(headers=headers, list_fields=list_fields)
 
228
        # END OF HACK
 
229
        
210
230
    if jr.request.vars.formjson=="true":
211
231
        output.update(form = s3xrc.xml.tree2json(etree.ElementTree(etree.XML(output["form"].xml()))))
212
232
        jr.response.view=""