yournextrepresentative icon indicating copy to clipboard operation
yournextrepresentative copied to clipboard

Partial ISO birth date raises ValidationError

Open wfdd opened this issue 9 years ago • 2 comments

Internal Server Error: /election/vouleftikes-ekloges-2016/person/create/
Traceback (most recent call last):
  ...
django.core.exceptions.ValidationError: {'start_date': ['date seems not to be correct 1984-06-00']}

...

POST:{'birth_date': '1984-06',

candidates.models.popolo_extra.parse_approximate_date appends a '-00' to partial dates which popolo.behaviors.models.validate_partial_date can't parse.

wfdd avatar May 06 '16 19:05 wfdd

This appears to be attempting to insert the string representation of ApproximateDate into a CharField.

wfdd avatar May 06 '16 19:05 wfdd

I've patched it up with

class WorseApproximateDate(ApproximateDate):

    def __repr__(self):
        repr_, *_ = super().__repr__().partition('-00')
        return repr_

but then PersonExtra.dob_as_date can't parse it because

ValueError: day is out of range for month

and at this point I think I'm gonna need a drink ;)

wfdd avatar May 06 '16 20:05 wfdd