Changeset 2966

Show
Ignore:
Timestamp:
02/24/07 12:30:12 (2 years ago)
Author:
mscott
Message:

Support for editing param queries

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/controllers/extent_q_methods.py

    r2954 r2966  
    2727        token = g.new_cache_token(query_cache) 
    2828        query_cache[token] = query 
    29         return redirect_to(h.url_for('query', id=token)) 
     29        return redirect_to(h.url_for('query', db_id=db_id, id=token)) 
    3030 
    3131    def create(self): 
  • sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/controllers/queries.py

    r2938 r2966  
    2323        pass 
    2424     
    25     def update(self, id): 
     25    def update(self, db_id, id): 
    2626        """PUT /id: Update an existing item.""" 
    2727        # Forms posted to this method should contain a hidden field: 
     
    3030        #    h.form(h.url_for('query', id=ID), method='put') 
    3131        # url_for('query', id=ID) 
    32         pass 
     32        # 
     33        # XXX: Only works for param queries. 
     34        postvars = request.POST 
     35        query = g.query_cache[id] 
     36        for field_name, field in query.sys.field_map().iteritems(): 
     37            if field_name in postvars: 
     38                value = postvars[field_name] 
     39                setattr(query, field_name, value) 
     40        return redirect_to(h.url_for('query', db_id=db_id, id=id)) 
    3341     
    3442    def delete(self, id): 
     
    4149        pass 
    4250     
    43     def show(self, id, format='html'): 
     51    def show(self, db_id, id, format='html'): 
    4452        """GET /id: Show a specific item.""" 
    4553        # url_for('query', id=ID) 
     54        c.db_id = db_id 
    4655        c.query = g.query_cache[id] 
    4756        c.query_id = id 
    4857        return render_response('/queries/show.html') 
    4958     
    50     def edit(self, id, format='html'): 
     59    def edit(self, db_id, id, format='html'): 
    5160        """GET /id;edit: Form to edit an existing item.""" 
    5261        # url_for('edit_query', id=ID) 
    53         pass 
    54      
     62        c.db_id = db_id 
     63        c.query = g.query_cache[id] 
     64        c.query_id = id 
     65        return render_response('/queries/edit.html') 
  • sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/templates/queries/show.html

    r2944 r2966  
    2929</%def> 
    3030 
     31<%def name="actions()"> 
     32    <form method="get" action="${h.url_for('edit_query', db_id=c.db_id, id=c.query_id)}"> 
     33        <input type="submit" value="Edit" /> 
     34    </form> 
     35</%def>