b840016 frontend: copr homepage/contact to be valid or None

2 files Authored by praiskup 3 years ago, Committed by praiskup 3 years ago,
    frontend: copr homepage/contact to be valid or None
    
    Fix forms.py so the empty string in homepage/contact fields are replaced
    with None value.  That way we fill the database with correct values
    (empty string is invalid) and later we can use python-marshmallow to
    serialize the Copr info to be sent via APIv2.
    
    I previously tried to fix similar problem in 00f9473570bfa88e.  That fix
    worked because the invalid empty string values triggered ValidationError
    in all previous versions of marshmallow on dump/serialize (sending data
    to user).  Newer versions of marshmallow though don't validate()
    automatically when serializing, only when deserializing!  That's why
    don't get ValidationError nowadays, and so even invalid values are sent
    to the user.
    
    Well, to be precise - previous marshmallow did validate **only** the
    Email and URL versions before, nothing else [1].
    
    So the effect of this patch is that we'll never got invalid values in
    database, and all the existing empty values are migrated to None by
    Alembic migration.
    
    [1] https://github.com/marshmallow-code/marshmallow/issues/1132
    
    Fixes: #1588