Skip to content

Commit

Permalink
Py3 fix for S3ImageCropWidget's IS_PROCESSED_IMAGE
Browse files Browse the repository at this point in the history
Tweak default Vol() menu (Hide departments unless using them)
  • Loading branch information
flavour committed Nov 28, 2019
1 parent a1f4a22 commit 482287b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nursix-dev-3360-g4e5d82a (2019-11-28 07:17:00)
b'a1f4a2272' (2019-11-28 11:39:09)
5 changes: 3 additions & 2 deletions modules/s3/s3validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1238,16 +1238,17 @@ def __call__(self, value):
return (value, None)

r = current.request
post_vars = r.post_vars

if r.env.request_method == "GET":
return (value, None)

post_vars = r.post_vars

# If there's a newly uploaded file, accept it. It'll be processed in
# the update form.
# NOTE: A FieldStorage with data evaluates as False (odd!)
uploaded_image = post_vars.get(self.field_name)
if uploaded_image not in ("", None):
if uploaded_image not in ("", b"", None): # Py 3.x it's b""
return (uploaded_image, None)

cropped_image = post_vars.get("imagecrop-data")
Expand Down
4 changes: 2 additions & 2 deletions modules/s3/s3widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3644,6 +3644,7 @@ class S3ImageCropWidget(FormWidget):
Cropping & Scaling (if necessary) done client-side
- currently using JCrop (https://jcrop.com)
- @ToDo: Replace with https://blueimp.github.io/jQuery-File-Upload/ ?
Uses the IS_PROCESSED_IMAGE validator
@ToDo: Doesn't currently work with Inline Component Forms
"""
Expand All @@ -3670,7 +3671,6 @@ def __call__(self, field, value, download_url=None, **attributes):
s3 = current.response.s3
debug = s3.debug
scripts = s3.scripts
settings = current.deployment_settings

if debug:
script = "%s/jquery.color.js" % script_dir
Expand Down Expand Up @@ -3730,7 +3730,7 @@ def __call__(self, field, value, download_url=None, **attributes):
append(canvas)

btn_class = "imagecrop-btn button"
if settings.ui.formstyle == "bootstrap":
if current.deployment_settings.ui.formstyle == "bootstrap":
btn_class = "imagecrop-btn"

buttons = [ A(T("Enable Crop"),
Expand Down
3 changes: 2 additions & 1 deletion modules/s3menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,7 @@ def vol():
show_programmes = lambda i: settings.get_hrm_vol_experience() == "programme"
skills = lambda i: settings.get_hrm_use_skills()
certificates = lambda i: settings.get_hrm_use_certificates()
departments = lambda i: settings.get_hrm_vol_departments()
teams = settings.get_hrm_teams()
use_teams = lambda i: teams
show_staff = lambda i: settings.get_hrm_show_staff()
Expand All @@ -1267,7 +1268,7 @@ def vol():
M("Search Members", f="group_membership"),
M("Import", f="group_membership", m="import"),
),
M("Department Catalog", f="department")(
M("Department Catalog", f="department", check=departments)(
M("Create", m="create"),
),
M("Volunteer Role Catalog", f="job_title")(
Expand Down

0 comments on commit 482287b

Please sign in to comment.