Changeset 6560b8f in OpenWorkouts-current


Ignore:
Timestamp:
Dec 16, 2018, 1:32:35 AM (5 years ago)
Author:
borja <borja@…>
Branches:
current, feature/docs, master
Children:
f24ad73
Parents:
1d92bf2
Message:

Fixed a bug in the edit_profile view that was breaking the edit profile

operation when a profile image was not provided.

This comes from the latest Formencode in python 3.x, this patch is a quick
and dirty hack while upstream does not fix it.

Location:
ow
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ow/schemas/user.py

    r1d92bf2 r6560b8f  
    7171    weight = validators.Number()
    7272    gender = validators.OneOf(('male', 'female'), not_empty=True)
    73     picture = FieldStorageBlob(whitelist=['jpg', 'jpeg', 'png', 'gif'])
     73    picture = FieldStorageBlob(if_emtpy=None, if_missing=None,
     74                               whitelist=['jpg', 'jpeg', 'png', 'gif'])
    7475
    7576
  • ow/views/user.py

    r1d92bf2 r6560b8f  
    144144    renderer='ow:templates/edit_profile.pt')
    145145def edit_profile(context, request):
     146    # if not given a file there is an empty byte in POST, which breaks
     147    # our blob storage validator.
     148    # dirty fix until formencode fixes its api.is_empty method
     149    if isinstance(request.POST.get('picture', None), bytes):
     150        request.POST['picture'] = ''
     151
    146152    form = Form(request, schema=UserProfileSchema(), obj=context)
     153
    147154    if 'submit' in request.POST and form.validate():
    148155        # No picture? do not override it
Note: See TracChangeset for help on using the changeset viewer.