Skip to content

Commit 60eb8d1

Browse files
committed
Made session title more flexible
1 parent 2911e7f commit 60eb8d1

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/imio/esign/browser/table.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ def external_session_link(session, title=None):
2525
return u"Sign url not yet received."
2626
if not title:
2727
title = session.get("title", "") or session.get("sign_id", "")
28-
return u'<a href="{url}" target="_blank">{title} ({id})</a>'.format(
28+
return u'<a href="{url}" target="_blank">{title}</a>'.format(
2929
url=session["sign_url"],
3030
title=safe_unicode(title),
31-
id=session["sign_id"],
3231
)
3332

3433

@@ -50,8 +49,6 @@ def renderCell(self, item):
5049
title = safe_unicode(item.get("title", ""))
5150
if item["sign_url"]:
5251
return external_session_link(item, title=title)
53-
elif item["sign_id"]:
54-
return u"{} ({})".format(title, item["sign_id"])
5552
else:
5653
return title
5754

src/imio/esign/utils.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)