Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error on personal-information when leaving existing portrait unchanged #129

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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