From 4f879a530f7c98e7ac73832ebe21641ee9a26417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 29 Oct 2018 15:52:03 +0100 Subject: [PATCH 3/3] misc: set profile image file selector to suggest image files (#27646) --- src/authentic2/forms/widgets.py | 5 +++++ tests/test_attribute_kinds.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/authentic2/forms/widgets.py b/src/authentic2/forms/widgets.py index 36fcf7fa..3cd27a0e 100644 --- a/src/authentic2/forms/widgets.py +++ b/src/authentic2/forms/widgets.py @@ -258,3 +258,8 @@ class ProfileImageInput(ClearableFileInput): ) else: template_name = "authentic2/profile_image_input.html" + + def __init__(self, *args, **kwargs): + attrs = kwargs.pop('attrs', {}) + attrs['accept'] = 'image/*' + super(ProfileImageInput, self).__init__(*args, attrs=attrs, **kwargs) diff --git a/tests/test_attribute_kinds.py b/tests/test_attribute_kinds.py index 50082fbb..c7217eb9 100644 --- a/tests/test_attribute_kinds.py +++ b/tests/test_attribute_kinds.py @@ -442,3 +442,8 @@ def test_profile_image(db, app, admin, mailoutbox, media): assert image.width == 200 assert image.height == 200 assert john().attributes.cityscape_image.name != profile_filename + + # verify file input mentions image files + response = app.get('/accounts/edit/') + form = response.form + assert form['edit-profile-cityscape_image'].attrs['accept'] == 'image/*' -- 2.19.1