11import base64
22from os import path
33
4- from docusign_esign import EnvelopesApi , ReturnUrlRequest , EnvelopesApi , EnvelopeDefinition , \
5- Document , Signer , CarbonCopy , SignHere , Tabs , Recipients
4+ from docusign_esign import EnvelopesApi , EnvelopesApi , EnvelopeDefinition , \
5+ Document , Signer , CarbonCopy , SignHere , Tabs , Recipients , EnvelopeViewRequest , EnvelopeViewSettings , \
6+ EnvelopeViewRecipientSettings , EnvelopeViewDocumentSettings , EnvelopeViewTaggerSettings , EnvelopeViewTemplateSettings
67from flask import url_for , session , request
78
89from ...consts import pattern , demo_docs_path
@@ -36,6 +37,7 @@ def get_args():
3637 "access_token" : session ["ds_access_token" ],
3738 "envelope_args" : envelope_args ,
3839 "ds_return_url" : url_for ("ds.ds_return" , _external = True ),
40+ "starting_view" : starting_view ,
3941 }
4042 return args
4143
@@ -58,21 +60,19 @@ def worker(cls, args, doc_docx_path, doc_pdf_path):
5860 @classmethod
5961 #ds-snippet-start:eSign11Step3
6062 def create_sender_view (cls , args , envelope_id ):
61- view_request = ReturnUrlRequest ( return_url = args [ "ds_return_url" ] )
63+ view_request = cls . make_envelope_view_request ( args )
6264 # Exceptions will be caught by the calling function
6365 api_client = create_api_client (base_path = args ["base_path" ], access_token = args ["access_token" ])
6466
6567 envelope_api = EnvelopesApi (api_client )
6668 sender_view = envelope_api .create_sender_view (
6769 account_id = args ["account_id" ],
6870 envelope_id = envelope_id ,
69- return_url_request = view_request
71+ envelope_view_request = view_request
7072 )
7173
7274 # Switch to Recipient and Documents view if requested by the user
7375 url = sender_view .url
74- if args ["starting_view" ] == "recipient" :
75- url = url .replace ("send=1" , "send=0" )
7676
7777 return url
7878 #ds-snippet-end:eSign11Step3
@@ -199,6 +199,40 @@ def make_envelope(cls, args, doc_docx_path, doc_pdf_path):
199199 env .status = args ["status" ]
200200
201201 return env
202+
203+ @classmethod
204+ def make_envelope_view_request (cls , args ):
205+ view_request = EnvelopeViewRequest (
206+ return_url = args ["ds_return_url" ],
207+ view_access = "envelope" ,
208+ settings = EnvelopeViewSettings (
209+ starting_screen = args ["starting_view" ],
210+ send_button_action = "send" ,
211+ show_back_button = "false" ,
212+ back_button_action = "previousPage" ,
213+ show_header_actions = "false" ,
214+ show_discard_action = "false" ,
215+ lock_token = "" ,
216+ recipient_settings = EnvelopeViewRecipientSettings (
217+ show_edit_recipients = "false" ,
218+ show_contacts_list = "false"
219+ ),
220+ document_settings = EnvelopeViewDocumentSettings (
221+ show_edit_documents = "false" ,
222+ show_edit_document_visibility = "false" ,
223+ show_edit_pages = "false"
224+ ),
225+ tagger_settings = EnvelopeViewTaggerSettings (
226+ palette_sections = "default" ,
227+ palette_default = "custom"
228+ ),
229+ template_settings = EnvelopeViewTemplateSettings (
230+ show_matching_templates_prompt = "true"
231+ )
232+ )
233+ )
234+
235+ return view_request
202236
203237 @classmethod
204238 def create_document1 (cls , args ):
0 commit comments