@@ -33,7 +33,7 @@ def add_files_to_session(
3333 :param seal: seal or not
3434 :param acroform: boolean to indicate if signer tag is in files
3535 :param session_id: session number
36- :param title: optional string
36+ :param title: optional string for session title. If it contains {sign_id} or {session_id} it will be replaced
3737 :param discriminators: optional list of string discriminators to use for session discrimination
3838 :param watchers: optional list of external esign session watchers emails (used only when creating a new session)
3939 :return: session_id, session
@@ -75,6 +75,11 @@ def add_files_to_session(
7575 if session ["client_id" ] is None :
7676 # FIXME what if scan_id is None ?
7777 session ["client_id" ] = session ["files" ][0 ]["scan_id" ][0 :7 ]
78+ session ["sign_id" ] = "{}{:05d}" .format (session ["client_id" ], session_id )
79+ if u"{sign_id}" in session ["title" ]:
80+ session ["title" ] = session ["title" ].replace (u"{sign_id}" , session ["sign_id" ])
81+ if u"{session_id}" in session ["title" ]:
82+ session ["title" ] = session ["title" ].replace (u"{session_id}" , str (session_id ))
7883 session ["last_update" ] = datetime .now ()
7984 return session_id , session
8085
@@ -95,17 +100,14 @@ def create_external_session(session_id, b64_cred=None, esign_root_url=None):
95100 return "_session_not_found_"
96101 files_uids = [fdic ["uid" ] for fdic in session ["files" ]]
97102 files = get_files_from_uids (files_uids )
98- app_session_id = "{}{:05d}" .format (session ["client_id" ], session_id )
99103 portal = api .portal .get () # noqa F841
100104 if not session ["title" ]:
101105 session ["title" ] = _ ("Session ${id}" , mapping = {"id" : session_id })
102- if not session ["sign_id" ]:
103- session ["sign_id" ] = app_session_id
104106 data_payload = {
105107 "commonData" : {
106108 "endpointUrl" : portal .absolute_url () + "/@external_session_feedback" ,
107109 "documentData" : [{"filename" : filename , "uniqueCode" : unique_code } for unique_code , filename , z in files ],
108- "imioAppSessionId" : app_session_id ,
110+ "imioAppSessionId" : session [ "sign_id" ] ,
109111 "sessionName" : session ["title" ],
110112 }
111113 }
0 commit comments