Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#649 closed defect (fixed)

Use form.field.data instead of request.form['field']

Reported by: Elrond Owned by: Hans Lo
Priority: minor Milestone: 0.4.0
Component: programming Keywords: bitesized sprint
Cc: Parent Tickets:

Description

After submitting a form, our code needs to fetch the data from the form and put it to good use (update the db!).

Our current code uses:

  form = EditForm(request.form)
  if ... and form.validate():
    some_object.one_field = request.form.get('one_field')
    some_object_two_field = request.form['two_field']

This works mostly, but doesn't benefit from all the validation and cleanup that wtforms gives us. So this should be rewrittn to:

  form = EditForm(request.form)
  if ... and form.validate():
    some_object.one_field = form.one_field.data
    some_object_two_field = form.two_field.data

This can be done in small chunks on a file by file basis, or whatever fits someone wanting to work on this. No need to do all at once. Small changes are easier to review anyway.

Subtickets

Change History (7)

comment:1 Changed 9 years ago by Elrond

Keywords: sprint added

comment:2 Changed 9 years ago by Hans Lo

Owner: set to Hans Lo
Status: newaccepted

comment:4 Changed 9 years ago by Christopher Allan Webber

Merged, thank you!

There are still some more forms that need to be fixed as such but this is a great start :)

comment:5 Changed 9 years ago by Hans Lo

I believe my branch now covers everything for this issue. Please review and thank you for your patience :)

comment:6 Changed 9 years ago by Elrond

Resolution: fixed
Status: acceptedclosed

Merged.

Thanks for also finding all the remaining bits!

4924b93bac328d9753f51ad9a3d3dd2dcb370871

I think, we can close this now.

comment:7 Changed 9 years ago by Elrond

Milestone: 0.4.0
Note: See TracTickets for help on using tickets.