Skip to content

Commit 145dbc3

Browse files
Sync click with other web launchers
1 parent c62fe29 commit 145dbc3

9 files changed

Lines changed: 54 additions & 61 deletions

app/click/examples/eg002_activate_clickwrap.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from docusign_click import AccountsApi, ClickwrapRequest
2-
from flask import session
2+
from flask import session, request
33

44
from ..utils import create_click_api_client
55

@@ -11,8 +11,7 @@ def get_args():
1111
return {
1212
"account_id": session.get("ds_account_id"), # Represents your {ACCOUNT_ID}
1313
"access_token": session.get("ds_access_token"), # Represents your {ACCESS_TOKEN}
14-
"clickwrap_id": session.get("clickwrap_id"),
15-
"clickwrap_name": session.get("clickwrap_name"),
14+
"clickwrap_id": request.form.get("clickwrap_id"),
1615
}
1716

1817
@staticmethod

app/click/examples/eg003_create_new_clickwrap_version.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from docusign_click import AccountsApi, ClickwrapRequest, DisplaySettings, \
55
Document
6-
from flask import session
6+
from flask import session, request
77

88
from ...consts import demo_docs_path
99
from ...ds_config import DS_CONFIG
@@ -17,8 +17,8 @@ def get_args():
1717
return {
1818
"account_id": session.get("ds_account_id"), # Represents your {ACCOUNT_ID}
1919
"access_token": session.get("ds_access_token"), # Represents your {ACCESS_TOKEN}
20-
"clickwrap_id": session.get("clickwrap_id"),
21-
"clickwrap_name": session.get("clickwrap_name"),
20+
"clickwrap_id": request.form.get("clickwrap_id"),
21+
"clickwrap_name": request.form.get("clickwrap_name"),
2222
}
2323

2424
@staticmethod

app/click/examples/eg005_clickwrap_responses.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ def get_args():
1111
return {
1212
"account_id": session.get("ds_account_id"), # Represents your {ACCOUNT_ID}
1313
"access_token": session.get("ds_access_token"), # Represents your {ACCESS_TOKEN}
14-
"clickwrap_id": session.get("clickwrap_id"),
15-
"client_user_id": request.form.get("client_user_id"),
14+
"clickwrap_id": request.form.get("clickwrap_id"),
1615
}
1716

1817
@staticmethod
@@ -31,7 +30,6 @@ def worker(args):
3130
response = accounts_api.get_clickwrap_agreements(
3231
account_id=args["account_id"],
3332
clickwrap_id=args["clickwrap_id"],
34-
client_user_id=args["client_user_id"],
3533
status="agreed"
3634
)
3735

app/click/templates/eg002_activate_clickwrap.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ <h4>2. Activate a clickwrap</h4>
1515

1616
{% include 'github_source.html' %}
1717

18-
{% if args['clickwraps'] is empty %}
18+
{% if clickwraps_data['clickwraps'] is undefined %}
1919
<p class="">
2020
Problem: You do not have clickwraps to activate. Go to example#1 and create one: <a
2121
href="{{ app_url ~ 'index.php?page=' }}ceg001">create clickwrap.</a> <br/>
@@ -28,7 +28,7 @@ <h4>2. Activate a clickwrap</h4>
2828
<label for="clickwrap_id">Clickwrap</label>
2929
<select class="custom-select" id="clickwrap_id"
3030
name="clickwrap_id">
31-
{% for clickwrap in args['clickwraps'] %}
31+
{% for clickwrap in clickwraps_data['clickwraps'] %}
3232
<option value="{{ clickwrap['clickwrap_id'] }}">{{ clickwrap['clickwrap_name'] }}</option>
3333
{% endfor %}
3434
</select>

app/click/templates/eg003_create_new_clickwrap_version.html

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,29 @@ <h4>3. Create a new clickwrap version</h4>
2020

2121
{% include 'github_source.html' %}
2222

23-
{% if clickwrap_ok %}
24-
<p>The clickwrap you created via example 1 will be queried.</p>
25-
26-
<form class="eg" action="" method="post" data-busy="form">
27-
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
28-
<button type="submit" class="btn btn-docu">Continue</button>
29-
</form>
30-
23+
{% if clickwraps_data['clickwraps'] is undefined %}
24+
<p class="">
25+
Problem: You do not have clickwraps to activate. Go to example#1 and create one: <a
26+
href="{{ app_url ~ 'index.php?page=' }}ceg001">create clickwrap.</a> <br/>
27+
</p>
3128
{% else %}
32-
<p>Problem: please first create a clickwrap using <a href="eg001">example
33-
1.</a><br/>Thank you.</p>
3429

35-
<form class="eg" action="eg001" method="get">
36-
<button type="submit" class="btn btn-docu">Continue</button>
30+
<form class="eg" action="" method="post" data-busy="form-download">
31+
<div class="form-group">
32+
<label for="clickwrap_id">Clickwrap</label>
33+
<select class="custom-select" id="clickwrap_id"
34+
name="clickwrap_id">
35+
{% for clickwrap in clickwraps_data['clickwraps'] %}
36+
<option value="{{ clickwrap['clickwrap_id'] }}">{{ clickwrap['clickwrap_name'] }}</option>
37+
{% endfor %}
38+
</select>
39+
</div>
40+
<div class="form-group">
41+
<label for="clickwrap_name">New Name</label>
42+
<input type="text" class="form-control" id="clickwrap_name" name="clickwrap_name" required/>
43+
</div>
44+
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
45+
<button type="submit" class="btn btn-docu">Submit</button>
3746
</form>
3847
{% endif %}
3948

app/click/templates/eg005_clickwrap_responses.html

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,30 @@ <h4>5. Get clickwrap responses</h4>
1414

1515
{% include 'github_source.html' %}
1616

17-
{% if clickwrap_ok %}
18-
19-
<p>
20-
First, test your clickwrap:
21-
</p>
22-
23-
<ul>
24-
<li>Log in to your developer account and select the <strong>Manage</strong> page.
25-
<li>Select the <strong>Clickwraps</strong> tab.
26-
<li>
27-
In the list of active clickwraps, locate the one you want to test, then click
28-
the dropdown arrow to the right of <strong>COPY CODE</strong> and select <strong>Test Clickwrap</strong>.
29-
</li>
30-
<li>In the Test Clickwrap dialog box, click <strong>TEST CLICKWRAP</strong>.
31-
<li>In the Test Your Clickwrap browser page, in the <strong>Unique ID</strong> field, enter any string, then click <strong>Test Clickwrap</strong>.
32-
<li>Review your displayed clickwrap and click <strong>I AGREE</strong> (or the equivalent button you configured) to complete the test.
33-
</ul>
34-
35-
<p>
36-
Then enter the same string you used to test your clickwrap in the field below.
17+
{% if clickwraps_data['clickwraps'] is undefined %}
18+
<p class="">
19+
Problem: You do not have clickwraps to activate. Go to example#1 and create one: <a
20+
href="{{ app_url ~ 'index.php?page=' }}ceg001">create clickwrap.</a> <br/>
3721
</p>
22+
{% else %}
23+
<p>Please choose a clickwrap</p>
3824

39-
<form class="eg" action="" method="post" data-busy="form">
25+
<form class="eg" action="" method="post" data-busy="form-download">
4026
<div class="form-group">
41-
<label for="client_user_id">Unique ID</label>
42-
<input type="text" class="form-control" id="client_user_id"
43-
name="client_user_id" required>
27+
<label for="clickwrap_id">Clickwrap</label>
28+
<select class="custom-select" id="clickwrap_id"
29+
name="clickwrap_id">
30+
{% for clickwrap in clickwraps_data['clickwraps'] %}
31+
<option value="{{ clickwrap['clickwrap_id'] }}">{{ clickwrap['clickwrap_name'] }}</option>
32+
{% endfor %}
33+
</select>
4434
</div>
4535
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
46-
<button type="submit" class="btn btn-docu">Continue</button>
47-
</form>
48-
49-
{% else %}
50-
<p>Problem: please first create a clickwrap using <a href="eg001">example
51-
1.</a><br/>Thank you.</p>
52-
53-
<form class="eg" action="eg001" method="get">
54-
<button type="submit" class="btn btn-docu">Continue</button>
36+
<button type="submit" class="btn btn-docu">Submit</button>
5537
</form>
5638
{% endif %}
5739

40+
5841
</div>
5942

6043
{% endblock %}

app/click/views/eg002_activate_clickwrap.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def activate_clickwrap():
3030
# 2. Call the worker method to create a new clickwrap
3131
results = Eg002ActivateClickwrapController.worker(args)
3232
current_app.logger.info(
33-
f"""The clickwrap "{args['clickwrap_name']}" has been activated."""
33+
f"""The clickwrap has been activated."""
3434
)
3535
except ApiException as err:
3636
return process_error(err)
@@ -43,7 +43,7 @@ def activate_clickwrap():
4343
"example_done.html",
4444
title="Activate a clickwrap",
4545
h1="Activate a clickwrap",
46-
message=f"""The clickwrap "{args['clickwrap_name']}" has been activated!""",
46+
message=f"""The clickwrap has been activated!""",
4747
json=json.dumps(json.dumps(results.to_dict(), default=str))
4848
)
4949

@@ -56,7 +56,7 @@ def get_view():
5656
return render_template(
5757
"eg002_activate_clickwrap.html",
5858
title="Activating a clickwrap",
59-
clickwrapData=Eg002ActivateClickwrapController.get_inactive_clickwraps(),
59+
clickwraps_data=Eg002ActivateClickwrapController.get_inactive_clickwraps(args),
6060
source_file= "eg002_activate_clickwrap.py",
6161
source_url=DS_CONFIG["click_github_url"] + "eg002_activate_clickwrap.py",
6262
)

app/click/views/eg003_create_new_clickwrap_version.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from flask import render_template, current_app, Blueprint, session
88

99
from ..examples.eg003_create_new_clickwrap_version import Eg003CrateNewClickwrapVersionController
10+
from ..examples.eg004_list_clickwraps import Eg004ListClickwrapsController
1011
from app.docusign import authenticate
1112
from app.ds_config import DS_CONFIG
1213
from app.error_handlers import process_error
@@ -50,10 +51,11 @@ def create_new_clickwrap_version():
5051
@authenticate(eg=eg)
5152
def get_view():
5253
"""responds with the form for the example"""
54+
args = Eg004ListClickwrapsController.get_args()
5355
return render_template(
5456
"eg003_create_new_clickwrap_version.html",
5557
title="Creating a new clickwrap version",
56-
clickwrap_ok="clickwrap_id" in session,
58+
clickwraps_data=Eg004ListClickwrapsController.worker(args),
5759
source_file= "eg003_create_new_clickwrap_version.py",
5860
source_url=DS_CONFIG["click_github_url"] + "eg003_create_new_clickwrap_version.py",
5961
)

app/click/views/eg005_clickwrap_responses.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from flask import render_template, current_app, Blueprint, session
88

99
from ..examples.eg005_clickwrap_responses import Eg005ClickwrapResponsesController
10+
from ..examples.eg004_list_clickwraps import Eg004ListClickwrapsController
1011
from app.docusign import authenticate
1112
from app.ds_config import DS_CONFIG
1213
from app.error_handlers import process_error
@@ -46,10 +47,11 @@ def clickwrap_responses():
4647
@authenticate(eg=eg)
4748
def get_view():
4849
"""Responds with the form for the example"""
50+
args = Eg004ListClickwrapsController.get_args()
4951
return render_template(
5052
"eg005_clickwrap_responses.html",
5153
title="Getting clickwrap responses",
52-
clickwrap_ok="clickwrap_id" in session,
54+
clickwraps_data=Eg004ListClickwrapsController.worker(args),
5355
source_file= "eg005_clickwrap_responses.py",
5456
source_url=DS_CONFIG["click_github_url"] + "eg005_clickwrap_responses.py",
5557
)

0 commit comments

Comments
 (0)