File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,6 +14,26 @@ def get_args():
1414 "clickwrap_id" : session .get ("clickwrap_id" ),
1515 "clickwrap_name" : session .get ("clickwrap_name" ),
1616 }
17+
18+ @staticmethod
19+ def get_inactive_clickwraps (args ):
20+ """
21+ 1. Create an API client with hheaders
22+ 2. Get a list of inactive clickwraps
23+ """
24+ # Step 1. Create an API client with headers
25+ api_client = create_click_api_client (
26+ access_token = args ["access_token" ]
27+ )
28+
29+ # Step 2. Get a list of inactive clickwraps
30+ accounts_api = AccountsApi (api_client )
31+ response = accounts_api .get_clickwraps (
32+ account_id = args ["account_id" ],
33+ status = "inactive"
34+ )
35+
36+ return response
1737
1838 @staticmethod
1939 def worker (args ):
Original file line number Diff line number Diff line change @@ -15,20 +15,26 @@ <h4>2. Activate a clickwrap</h4>
1515
1616{% include 'github_source.html' %}
1717
18- {% if clickwrap_ok %}
19- < p > The clickwrap you created via example 1 will be queried.</ p >
20-
21- < form class ="eg " action ="" method ="post " data-busy ="form ">
22- < input type ="hidden " name ="csrf_token " value ="{{ csrf_token() }} "/>
23- < button type ="submit " class ="btn btn-docu "> Continue</ button >
24- </ form >
25-
18+ {% if args['clickwraps'] is empty %}
19+ < p class ="">
20+ Problem: You do not have clickwraps to activate. Go to example#1 and create one: < a
21+ href ="{{ app_url ~ 'index.php?page=' }}ceg001 "> create clickwrap.</ a > < br />
22+ </ p >
2623{% else %}
27- < p > Problem: please first create a clickwrap using < a href ="eg001 "> example
28- 1.</ a > < br /> Thank you.</ p >
29-
30- < form class ="eg " action ="eg001 " method ="get ">
31- < button type ="submit " class ="btn btn-docu "> Continue</ button >
24+ < p > Please choose a clickwrap to activate</ p >
25+
26+ < form class ="eg " action ="" method ="post " data-busy ="form-download ">
27+ < div class ="form-group ">
28+ < label for ="clickwrap_id "> Clickwrap</ label >
29+ < select class ="custom-select " id ="clickwrap_id "
30+ name ="clickwrap_id ">
31+ {% for clickwrap in args['clickwraps'] %}
32+ < option value ="{{ clickwrap['clickwrap_id'] }} "> {{ clickwrap['clickwrap_name'] }}</ option >
33+ {% endfor %}
34+ </ select >
35+ </ div >
36+ < input type ="hidden " name ="csrf_token " value ="{{ csrf_token() }} "/>
37+ < button type ="submit " class ="btn btn-docu "> Submit</ button >
3238</ form >
3339{% endif %}
3440
Original file line number Diff line number Diff line change @@ -52,10 +52,11 @@ def activate_clickwrap():
5252@authenticate (eg = eg )
5353def get_view ():
5454 """responds with the form for the example"""
55+ args = Eg002ActivateClickwrapController .get_args ()
5556 return render_template (
5657 "eg002_activate_clickwrap.html" ,
5758 title = "Activating a clickwrap" ,
58- clickwrap_ok = "clickwrap_id" in session ,
59+ clickwrapData = Eg002ActivateClickwrapController . get_inactive_clickwraps () ,
5960 source_file = "eg002_activate_clickwrap.py" ,
6061 source_url = DS_CONFIG ["click_github_url" ] + "eg002_activate_clickwrap.py" ,
6162 )
You can’t perform that action at this time.
0 commit comments