|
2 | 2 |
|
3 | 3 | from flask import redirect, request, url_for, flash, render_template, Blueprint, session, current_app as app |
4 | 4 |
|
| 5 | +import json |
5 | 6 | from .ds_client import DSClient |
6 | 7 | from .utils import ds_logout_internal |
7 | 8 | from ..consts import base_uri_suffix |
8 | 9 | from ..ds_config import DS_CONFIG |
9 | | -from ..ds_config import EXAMPLES_API_TYPE |
| 10 | +from ..api_type import EXAMPLES_API_TYPE |
10 | 11 |
|
11 | 12 | ds = Blueprint("ds", __name__, url_prefix="/ds") |
12 | 13 |
|
@@ -36,19 +37,28 @@ def choose_api(): |
36 | 37 | def api_selected(): |
37 | 38 | chosen_api = request.form.get("chosen_api") |
38 | 39 |
|
| 40 | + new_api_type = EXAMPLES_API_TYPE |
| 41 | + |
| 42 | + # Set all values to False |
| 43 | + for api_type in new_api_type: |
| 44 | + if new_api_type[api_type] == True: |
| 45 | + new_api_type[api_type] = False |
| 46 | + |
| 47 | + # Update the new chosen API type to True |
39 | 48 | if chosen_api == "ESignature": |
40 | | - EXAMPLES_API_TYPE["ESignature"] = True |
| 49 | + new_api_type["ESignature"] = True |
41 | 50 | elif chosen_api == "Rooms": |
42 | | - EXAMPLES_API_TYPE["Rooms"] = True |
| 51 | + new_api_type["Rooms"] = True |
43 | 52 | elif chosen_api == "Admin": |
44 | | - EXAMPLES_API_TYPE["Admin"] = True |
| 53 | + new_api_type["Admin"] = True |
45 | 54 | elif chosen_api == "Monitor": |
46 | | - EXAMPLES_API_TYPE["Monitor"] = True |
| 55 | + new_api_type["Monitor"] = True |
47 | 56 | elif chosen_api == "Click": |
48 | | - EXAMPLES_API_TYPE["Click"] = True |
| 57 | + new_api_type["Click"] = True |
49 | 58 |
|
50 | | - session["chosen_api"] = False |
51 | | - session["chosen_api"] = chosen_api |
| 59 | + # Overwrite api_type.py file |
| 60 | + with open("app/api_type.py", "w") as api_type_file: |
| 61 | + api_type_file.write("EXAMPLES_API_TYPE =" + str(new_api_type)) |
52 | 62 |
|
53 | 63 | ds_logout_internal() |
54 | 64 | flash("You have logged out from DocuSign.") |
|
0 commit comments