Skip to content

Commit

Permalink
Extend signer-class with editors beside of signers
Browse files Browse the repository at this point in the history
  • Loading branch information
elioschmutz committed Dec 13, 2024
1 parent 421cece commit 2d4dc5d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
7 changes: 4 additions & 3 deletions opengever/sign/sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ def validate_token(self, token):
def invalidate_token(self):
self.token_manager.invalidate_token()

def start_signing(self, signers):
def start_signing(self, signers=[], editors=[]):
token = self.issue_token()
response = sign_service_client.queue_signing(self.context, token, signers)

response = sign_service_client.queue_signing(self.context, token,
signers, editors)
self.pending_signing_job = PendingSigningJob(
userid=api.user.get_current().id,
version=self.context.get_current_version_id(missing_as_zero=True),
signers=signers,
editors=editors,
job_id=response.get('id'),
redirect_url=response.get('redirect_url'),
)
Expand Down
23 changes: 22 additions & 1 deletion opengever/sign/tests/test_sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,36 @@ def test_store_signing_document_metadata_when_starting_sign_process(self, mocker
mocker.post(re.compile('/signing-jobs'), json=DEFAULT_MOCK_RESPONSE)
signer = Signer(self.document)

signers = ['[email protected]']
editors = ['[email protected]']
with freeze(FROZEN_NOW):
signer.start_signing(['[email protected]'])
signer.start_signing(signers, editors)

request = mocker.last_request.json()
request['access_token'] = '<token>'
request['download_url'] = '<download-url>'

self.assertDictEqual(
{
u'access_token': u'<token>',
u'document_uid': u'createtreatydossiers000000000002',
u'document_url': u'http://nohost/plone/ordnungssystem/fuhrung/vertrage-und-vereinbarungen/dossier-1/document-14',
u'download_url': u'<download-url>',
u'editors': [u'[email protected]'],
u'signers': [u'[email protected]'],
u'title': u'Vertr\xe4gsentwurf',
u'upload_url': u'http://nohost/plone/ordnungssystem/fuhrung/vertrage-und-vereinbarungen/dossier-1/document-14/@upload-signed-pdf'
},
request
)

self.assertDictEqual(
{
'created': u'2024-02-18T15:45:00',
'job_id': '1',
'redirect_url': 'http://external.example.org/signing-requests/123',
'signers': [{u'email': u'[email protected]', u'userid': u''}],
'editors': [{u'email': u'[email protected]', u'userid': u''}],
'userid': 'regular_user',
'version': 0
}, signer.serialize_pending_signing_job())
Expand Down

0 comments on commit 2d4dc5d

Please sign in to comment.