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,23 +60,55 @@ 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
78+
79+ @classmethod
80+ def make_envelope_view_request (cls , args ):
81+ view_request = EnvelopeViewRequest (
82+ return_url = args ["ds_return_url" ],
83+ view_access = "envelope" ,
84+ settings = EnvelopeViewSettings (
85+ starting_screen = args ["starting_view" ],
86+ send_button_action = "send" ,
87+ show_back_button = "false" ,
88+ back_button_action = "previousPage" ,
89+ show_header_actions = "false" ,
90+ show_discard_action = "false" ,
91+ lock_token = "" ,
92+ recipient_settings = EnvelopeViewRecipientSettings (
93+ show_edit_recipients = "false" ,
94+ show_contacts_list = "false"
95+ ),
96+ document_settings = EnvelopeViewDocumentSettings (
97+ show_edit_documents = "false" ,
98+ show_edit_document_visibility = "false" ,
99+ show_edit_pages = "false"
100+ ),
101+ tagger_settings = EnvelopeViewTaggerSettings (
102+ palette_sections = "default" ,
103+ palette_default = "custom"
104+ ),
105+ template_settings = EnvelopeViewTemplateSettings (
106+ show_matching_templates_prompt = "true"
107+ )
108+ )
109+ )
110+
111+ return view_request
78112 #ds-snippet-end:eSign11Step3
79113
80114 @classmethod
0 commit comments