Skip to content

Commit

Permalink
Merge pull request #129 from plone/maurits-fix-portrait-not-changed
Browse files Browse the repository at this point in the history
Fix error on personal-information when leaving existing portrait unchanged
  • Loading branch information
jensens authored Jun 7, 2024
2 parents 43bafd7 + cd12376 commit 2c8f9d0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions news/126.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix error on personal-information page when you leave an existing portrait unchanged.
The previous release added validation, but this caused a regression.
[maurits]
9 changes: 7 additions & 2 deletions plone/app/users/browser/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from Products.statusmessages.interfaces import IStatusMessage
from z3c.form import button
from z3c.form import form
from z3c.form.interfaces import NOT_CHANGED
from zope import schema
from zope.cachedescriptors.property import Lazy as lazy_property
from zope.component import getMultiAdapter
Expand Down Expand Up @@ -272,8 +273,12 @@ def validate_portrait(self, action, data):
SVG files are not yet supported.
"""
error_keys = [error.field.getName() for error in action.form.widgets.errors]
if "portrait" not in error_keys and data["portrait"] is not None:
portrait = data["portrait"].open()
if "portrait" in error_keys:
return
portrait_file = data["portrait"]
if portrait_file is None or portrait_file is NOT_CHANGED:
return
with portrait_file.open() as portrait:
try:
Image.open(portrait)
except UnidentifiedImageError:
Expand Down

0 comments on commit 2c8f9d0

Please sign in to comment.