CottageLabs / uniboard

UniBoard project
0 stars 0 forks source link

Add £ to price field in advert create and validate appropriately #36

Closed richard-jones closed 10 years ago

richard-jones commented 10 years ago

The price field should be prefixed with a "£"

When the advert is created, the back end should strip any leading and trailing spaces/characters before validating the content as a number with optionally 2 digits.

Nimphal commented 10 years ago

Just a note, trying to do the character stripping uncovered inconsistency in the way WTForms handles the FloatField. If the input is not a float it simply does not take it, as in, does not even give it to the form, which results in a nice None when I try to do anything to the field if the input isn't valid. I will change the field type to a general TextField with a bunch of validators to handle it being a float and so on.

Nimphal commented 10 years ago

Pound sign has been added.

Nimphal commented 10 years ago

I changed the field type to a TextField and created a custom validator to make sure it is a float. This raises an error when the value in the field cannot be cast to a float, so the user will not be able to input erroneous characters. That means there is no need for character stripping.