Skip to content

Commit

Permalink
Handle newly introduced invite_url coming from the sign service
Browse files Browse the repository at this point in the history
  • Loading branch information
elioschmutz committed Dec 13, 2024
1 parent 22a6e02 commit bd6582e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
6 changes: 4 additions & 2 deletions opengever/api/transition.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,10 @@ class GEVERDocumentWorkflowTransition(GEVERWorkflowTransition):
def reply(self):
response = super(GEVERDocumentWorkflowTransition, self).reply()
if self.transition in self.SIGNING_TRANSITIONS:
response['redirect_url'] = Signer(
self.context).serialize_pending_signing_job().get('redirect_url')
pending_signing_job = Signer(
self.context).serialize_pending_signing_job()
response['redirect_url'] = pending_signing_job.get('redirect_url')
response['invite_url'] = pending_signing_job.get('invite_url')
return response


Expand Down
2 changes: 2 additions & 0 deletions opengever/document/tests/test_document_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ def test_can_start_signing_a_document_in_draft_state(self, mocker):
'created': u'2024-02-18T15:45:00',
'job_id': '1',
'redirect_url': 'http://external.example.org/signing-requests/123',
'invite_url': 'http://external.example.org/invite/signing-requests/123',
'signers': [],
'editors': [
{
Expand Down Expand Up @@ -261,6 +262,7 @@ def test_can_start_signing_a_document_in_final_state(self, mocker):
'created': u'2024-02-18T15:45:00',
'job_id': '1',
'redirect_url': 'http://external.example.org/signing-requests/123',
'invite_url': 'http://external.example.org/invite/signing-requests/123',
'signers': [],
'editors': [
{
Expand Down
3 changes: 3 additions & 0 deletions opengever/sign/pending_signing_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def __init__(self,
editors=list(),
job_id='',
redirect_url='',
invite_url='',
):

self.created = created or datetime.now()
Expand All @@ -27,13 +28,15 @@ def __init__(self,
self.editors = PendingEditors([PendingEditor(email=editors) for editors in editors])
self.job_id = job_id
self.redirect_url = redirect_url
self.invite_url = invite_url

def serialize(self):
return json_compatible({
'created': self.created,
'userid': self.userid,
'job_id': self.job_id,
'redirect_url': self.redirect_url,
'invite_url': self.invite_url,
'signers': self.signers.serialize(),
'editors': self.editors.serialize(),
'version': self.version,
Expand Down
1 change: 1 addition & 0 deletions opengever/sign/sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def start_signing(self, signers=[], editors=[]):
editors=editors,
job_id=response.get('id'),
redirect_url=response.get('redirect_url'),
invite_url=response.get('invite_url'),
)
return token

Expand Down
6 changes: 4 additions & 2 deletions opengever/sign/tests/test_pending_signing_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def test_can_be_serialized(self):
signers=['[email protected]'],
editors=['[email protected]'],
job_id='1',
redirect_url='[email protected]')
redirect_url='[email protected]',
invite_url='[email protected]/invite')

self.assertDictEqual(
{
Expand All @@ -49,7 +50,8 @@ def test_can_be_serialized(self):
}
],
'job_id': '1',
'redirect_url': '[email protected]'
'redirect_url': '[email protected]',
'invite_url': '[email protected]/invite',
}, metadata.serialize())

def test_can_be_converted_to_a_signed_version(self):
Expand Down
2 changes: 2 additions & 0 deletions opengever/sign/tests/test_sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
DEFAULT_MOCK_RESPONSE = {
'id': '1',
'redirect_url': 'http://external.example.org/signing-requests/123',
'invite_url': 'http://external.example.org/invite/signing-requests/123',
}


Expand Down Expand Up @@ -59,6 +60,7 @@ def test_store_signing_document_metadata_when_starting_sign_process(self, mocker
'created': u'2024-02-18T15:45:00',
'job_id': '1',
'redirect_url': 'http://external.example.org/signing-requests/123',
'invite_url': 'http://external.example.org/invite/signing-requests/123',
'signers': [{u'email': u'[email protected]', u'userid': u''}],
'editors': [{u'email': u'[email protected]', u'userid': u''}],
'userid': 'regular_user',
Expand Down

0 comments on commit bd6582e

Please sign in to comment.