Enforce maximum height of signwell fields
authorMagnus Hagander <magnus@hagander.net>
Tue, 24 Jun 2025 13:11:47 +0000 (15:11 +0200)
committerMagnus Hagander <magnus@hagander.net>
Tue, 24 Jun 2025 13:14:11 +0000 (15:14 +0200)
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

index 30c92d4284668abb100f7aa991a791c21b3ea095..6de7a4e3249e401e1e4854d61d7b11a4a41d2900 100644 (file)
@@ -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)