esup_signature: add new-with-workflow endpoint (#77670) #251
|
@ -35,7 +35,7 @@ SIGN_REQUEST_SCHEMA = {
|
|||
'title': '',
|
||||
'description': '',
|
||||
'type': 'object',
|
||||
'required': ['file', 'recipients_emails', 'eppn'],
|
||||
'required': ['file', 'recipients_emails', 'create_by_eppn'],
|
||||
'unflatten': True,
|
||||
'properties': collections.OrderedDict(
|
||||
{
|
||||
|
@ -62,8 +62,48 @@ SIGN_REQUEST_SCHEMA = {
|
|||
'description': 'Recipients emails',
|
||||
'items': {'type': 'string'},
|
||||
},
|
||||
'eppn': {'type': 'string', 'description': 'EPPN of the sign request owner'},
|
||||
'recipients_cc_emails': {
|
||||
'type': 'array',
|
||||
'description': 'Recipients CC emails',
|
||||
'items': {'type': 'string'},
|
||||
},
|
||||
'all_sign_to_complete': {
|
||||
'type': 'string',
|
||||
'description': 'Every recipient has to sign',
|
||||
'enum': ['true', 'false'],
|
||||
|
||||
'default': 'false',
|
||||
},
|
||||
'user_sign_first': {
|
||||
'type': 'string',
|
||||
'description': 'the author must sign first',
|
||||
'enum': ['true', 'false'],
|
||||
'default': 'false',
|
||||
},
|
||||
'pending': {
|
||||
'type': 'string',
|
||||
'description': 'Pending',
|
||||
'enum': ['true', 'false'],
|
||||
'default': 'true',
|
||||
},
|
||||
'force_all_sign': {
|
||||
'type': 'string',
|
||||
'description': 'Force signing on every document',
|
||||
'enum': ['true', 'false'],
|
||||
'default': 'false',
|
||||
},
|
||||
'comment': {'type': 'string', 'description': 'Comment'},
|
||||
'sign_type': {
|
||||
'type': 'string',
|
||||
'description': 'Signature type',
|
||||
'enum': ['visa', 'pdfImageStamp', 'certSign', 'nexuSign'],
|
||||
'default': 'pdfImageStamp',
|
||||
},
|
||||
'create_by_eppn': {'type': 'string', 'description': 'EPPN of the sign request owner'},
|
||||
'title': {'type': 'string', 'description': 'Title'},
|
||||
'target_url': {
|
||||
'type': 'string',
|
||||
'description': 'End location',
|
||||
},
|
||||
}
|
||||
),
|
||||
}
|
||||
pmarillonnet
commented
Typo ici (s/WTIH/WITH), à reporter dans le test aussi. Typo ici (s/WTIH/WITH), à reporter dans le test aussi.
ecazenave
commented
Corrigé. Corrigé.
|
||||
|
@ -132,6 +172,10 @@ def clean_list(some_list):
|
|||
return [elem for elem in some_list if elem]
|
||||
|
||||
|
||||
def to_bool(some_str):
|
||||
return some_str == 'true'
|
||||
|
||||
|
||||
class EsupSignature(BaseResource, HTTPResource):
|
||||
base_url = models.URLField(_('API URL'))
|
||||
|
||||
|
@ -188,8 +232,18 @@ class EsupSignature(BaseResource, HTTPResource):
|
|||
'recipients_emails/0': 'xx@foo.com',
|
||||
'recipients_emails/1': 'yy@foo.com',
|
||||
'recipients_emails/2': 'zz@foo.com',
|
||||
'eppn': 'aa@foo.com',
|
||||
'recipients_cc_emails/0': 'xx@foo.com',
|
||||
'recipients_cc_emails/1': 'yy@foo.com',
|
||||
'recipients_cc_emails/2': 'zz@foo.com',
|
||||
'all_sign_to_complete': 'true',
|
||||
'user_sign_first': 'false',
|
||||
'pending': 'true',
|
||||
'force_all_sign': 'false',
|
||||
'comment': 'a comment',
|
||||
'sign_type': 'pdfImageStamp',
|
||||
'create_by_eppn': 'aa@foo.com',
|
||||
'title': 'a title',
|
||||
'target_url': 'smb://foo.bar/location-1/',
|
||||
},
|
||||
},
|
||||
)
|
||||
|
@ -207,13 +261,27 @@ class EsupSignature(BaseResource, HTTPResource):
|
|||
}
|
||||
|
||||
params = {
|
||||
'signType': 'pdfImageStamp',
|
||||
'recipientsEmails': clean_list(post_data['recipients_emails']),
|
||||
'eppn': post_data['eppn'],
|
||||
'recipientsCCEmails': clean_list(post_data.get('recipients_cc_emails', [])),
|
||||
'comment': post_data.get('comment', ''),
|
||||
'signType': post_data.get('sign_type', 'pdfImageStamp'),
|
||||
'createByEppn': post_data['create_by_eppn'],
|
||||
'title': post_data.get('title', ''),
|
||||
'pending': True,
|
||||
'targetUrl': post_data.get('target_url', ''),
|
||||
}
|
||||
|
||||
bool_params = {
|
||||
pmarillonnet
commented
Du détail, mais pas compris pourquoi la valeur par défaut est en dur ici et ne reprend pas celle définie dans le schéma. Du détail, mais pas compris pourquoi la valeur par défaut est en dur ici et ne reprend pas celle définie dans le schéma.
ecazenave
commented
Dans la norme JSON schema : "The default keyword specifies a default value. This value is not used to fill in missing values during the validation process." Charge donc à l'application de "fournir" les valeurs par défaut. Dans la norme JSON schema : "The default keyword specifies a default value. This value is not used to fill in missing values during the validation process."
Charge donc à l'application de "fournir" les valeurs par défaut.
pmarillonnet
commented
Cool, j’ignorais ça, merci pour la clarification. Cool, j’ignorais ça, merci pour la clarification.
|
||||
'all_sign_to_complete': ('allSignToComplete', False),
|
||||
'user_sign_first': ('userSignFirst', False),
|
||||
'pending': ('pending', True),
|
||||
'force_all_sign': ('forceAllSign', False),
|
||||
}
|
||||
for key, value in bool_params.items():
|
||||
ext_param, default = value
|
||||
params[ext_param] = default
|
||||
if key in post_data:
|
||||
params[ext_param] = to_bool(post_data[key])
|
||||
|
||||
return {'data': self._call('ws/signrequests/new', method='post', params=params, files=files)}
|
||||
|
||||
@endpoint(
|
||||
|
|
|
@ -31,16 +31,19 @@ def test_new(app, connector):
|
|||
},
|
||||
'recipients_emails/0': 'foo@invalid',
|
||||
'recipients_emails/1': 'bar@invalid',
|
||||
'eppn': 'baz@invalid',
|
||||
'create_by_eppn': 'baz@invalid',
|
||||
'title': 'a title',
|
||||
}
|
||||
with responses.RequestsMock() as rsps:
|
||||
query_params = {
|
||||
'recipientsEmails': ['foo@invalid', 'bar@invalid'],
|
||||
'eppn': 'baz@invalid',
|
||||
'createByEppn': 'baz@invalid',
|
||||
'title': 'a title',
|
||||
'signType': 'pdfImageStamp',
|
||||
'pending': True,
|
||||
'allSignToComplete': False,
|
||||
'userSignFirst': False,
|
||||
'forceAllSign': False,
|
||||
}
|
||||
rsps.post(
|
||||
'https://esup-signature.invalid/ws/signrequests/new',
|
||||
|
|
Loading…
Reference in New Issue
Est-ce que pour plus de clarté on n’a pas intérêt à décider d’une valeur par défaut pour tous ces paramètres booléens nouvellement ajoutés au schéma ?
Fait.