From 1febf08ad2ff6ff835dc51433d52d6d0766056bb Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Tue, 24 Jun 2025 15:11:47 +0200 Subject: [PATCH] Enforce maximum height of signwell fields Signwell have implemented a size limitation that no fields can have a height bigger than 34px. Unfortunately, their own GUI editor allows the creation of fields that are larger than this, and once one has done that they can no longer be loaded for editing or sent through the API (it appears the limitation is only in the public API and not their internal ones). So to make signing work at all, when editing a contract enforce the limit to 34px (with a warning). Things might not look very nice anymore but they should at least work. Support case has been opened with Signwell to see if this was actually intentional (the max size in the UI editor appears to be 74), and if so if they are planning to align the UI with the API. This commit goes in pending a possible change on their side and we can revert if if we end up not needing it permanently. --- postgresqleu/digisign/implementations/signwell.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/postgresqleu/digisign/implementations/signwell.py b/postgresqleu/digisign/implementations/signwell.py index 30c92d42..6de7a4e3 100644 --- a/postgresqleu/digisign/implementations/signwell.py +++ b/postgresqleu/digisign/implementations/signwell.py @@ -12,6 +12,7 @@ from postgresqleu.digisign.util import digisign_handlers import base64 import dateutil.parser +from decimal import Decimal import hashlib import hmac import json @@ -177,6 +178,11 @@ class Signwell(BaseProvider): elif f['type'] == 'datefield': f['type'] = 'date' + # (possibly temporary) workaround for that signwell returns fields that are bigger than they then allow us to set + if Decimal(f.get('height', '0')) > 34: + messages.warning(request, "Reduced size of field {} to 34 pixels due to signwell API limitation".format(f.get('api_id', '*unknown name*'))) + f['height'] = "34" + savecallback(fieldjson) # Delete the temporary document @@ -248,6 +254,11 @@ class Signwell(BaseProvider): # Workaround: seems it gets returned mixed case but has to be specified lowercase! f['type'] = f['type'].lower() + # (possibly temporary) workaround for that signwell returns fields that are bigger than they then allow us to set + if Decimal(f.get('height', '0')) > 34: + messages.warning(request, "Reduced size of field {} when loading contract to 34 pixels due to signwell API limitation".format(f.get('api_id', '*unknown name*'))) + f['height'] = "34" + r = requests.post('https://www.signwell.com/api/v1/documents/', json=payload, headers={ 'X-Api-Key': self.provider.config.get('apikey'), }, timeout=15) -- 2.39.5