Changeset 2952

Show
Ignore:
Timestamp:
02/22/07 17:40:21 (2 years ago)
Author:
mscott
Message:

Save changes to unicode-compatible fields in transactions

Files:

Legend:

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

    r2951 r2952  
    3030        #    h.form(h.url_for('transaction', id=ID), method='put') 
    3131        # url_for('transaction', id=ID) 
    32         pass 
     32        postvars = request.POST 
     33        tx = g.tx_cache[id] 
     34        for field_name, field in tx.sys.field_map().iteritems(): 
     35            if field_name in postvars: 
     36                value = postvars[field_name] 
     37                setattr(tx, field_name, value) 
     38        return redirect_to(h.url_for('transaction', id=id)) 
    3339     
    3440    def delete(self, id): 
  • sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/templates/transactions/edit.html

    r2951 r2952  
    1616 
    1717<%def name="fields()"> 
    18     <ul> 
    19         % for name, field in c.tx.sys.field_map().iteritems(): 
    20             <li> 
    21                 <label for="${name}"> 
    22                     ${h.label(field)} 
    23                 </label>  
    24                 <span id="${name}" class="value"> 
    25                     ${field.value} 
    26                 </span> 
    27             </li> 
    28         % endfor 
    29     </ul> 
     18    <form method="post" action="${h.url_for('transaction', id=c.tx_id)}"> 
     19        <input type="hidden" name="_method" value="PUT" /> 
     20         
     21        <ul> 
     22            % for name, field in c.tx.sys.field_map().iteritems(): 
     23                <li> 
     24                    <label for="f_${name}"> 
     25                        ${h.label(field)} 
     26                    </label>  
     27                    <span class="value"> 
     28                        <input type="text" id="f_${name}" name="${name}"  
     29                            value="${field.value}" /> 
     30                    </span> 
     31                </li> 
     32            % endfor 
     33        </ul> 
     34         
     35        <div> 
     36            <input type="submit" value="Save" /> 
     37        </div> 
     38    </form> 
     39 
    3040</%def> 
    3141 
  • sandbox/mscott/SchevoPylonsNav/trunk/schevopylonsnav/tests/functional/test_transactions.py

    r2951 r2952  
    2121        # Call it to get the transaction. 
    2222        response = response.follow() 
    23         # Find the edit button
     23        # Find the edit button and click it
    2424        assert 'Edit' in response 
    25         # Click it. 
    2625        form = response.forms[0] 
    2726        response = form.submit() 
     27 
     28    def test_update(self): 
     29        # Get the transaction. 
     30        response = self.app.post( 
     31            url_for('extent_call_transaction', db_id='db', extent_id='Foo', 
     32            id='create')) 
     33        # Call it to get the transaction. 
     34        response = response.follow() 
     35        # Find the edit button and click it. 
     36        assert 'Edit' in response 
     37        form = response.forms[0] 
     38        response = form.submit() 
     39        # Find the bar field and edit it. 
     40        form = response.forms[0] 
     41        bar = form.fields['bar'][0] 
     42        assert bar.value == u'' 
     43        bar.value = 'newvalue123' 
     44        # Save the form and follow its redirection. 
     45        response = form.submit() 
     46        response = response.follow() 
     47        # The new value should now be on the page. 
     48        assert 'newvalue123' in response