Skip to content

Commit 63db9c5

Browse files
committed
using separate config file
1 parent c914a1b commit 63db9c5

6 files changed

Lines changed: 24 additions & 12 deletions

File tree

app/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from .ds_config import DS_CONFIG
77
from .eSignature import examples
88
from .docusign.views import ds
9-
from .ds_config import EXAMPLES_API_TYPE
9+
from .api_type import EXAMPLES_API_TYPE
1010
from .rooms import examples as rooms_examples
1111
from .click import examples as click_examples
1212
from .monitor import examples as monitor_examples

app/api_type.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
EXAMPLES_API_TYPE ={'Rooms': False, 'ESignature': False, 'Click': False, 'Monitor': False, 'Admin': True}

app/docusign/ds_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
from docusign_esign import ApiClient
99
from docusign_esign.client.api_exception import ApiException
1010

11-
from ..ds_config import DS_CONFIG, DS_JWT, EXAMPLES_API_TYPE
11+
from ..ds_config import DS_CONFIG, DS_JWT
12+
from ..api_type import EXAMPLES_API_TYPE
1213
from ..error_handlers import process_error
1314

1415
SCOPES = [

app/docusign/views.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
from flask import redirect, request, url_for, flash, render_template, Blueprint, session, current_app as app
44

5+
import json
56
from .ds_client import DSClient
67
from .utils import ds_logout_internal
78
from ..consts import base_uri_suffix
89
from ..ds_config import DS_CONFIG
9-
from ..ds_config import EXAMPLES_API_TYPE
10+
from ..api_type import EXAMPLES_API_TYPE
1011

1112
ds = Blueprint("ds", __name__, url_prefix="/ds")
1213

@@ -36,19 +37,28 @@ def choose_api():
3637
def api_selected():
3738
chosen_api = request.form.get("chosen_api")
3839

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
3948
if chosen_api == "ESignature":
40-
EXAMPLES_API_TYPE["ESignature"] = True
49+
new_api_type["ESignature"] = True
4150
elif chosen_api == "Rooms":
42-
EXAMPLES_API_TYPE["Rooms"] = True
51+
new_api_type["Rooms"] = True
4352
elif chosen_api == "Admin":
44-
EXAMPLES_API_TYPE["Admin"] = True
53+
new_api_type["Admin"] = True
4554
elif chosen_api == "Monitor":
46-
EXAMPLES_API_TYPE["Monitor"] = True
55+
new_api_type["Monitor"] = True
4756
elif chosen_api == "Click":
48-
EXAMPLES_API_TYPE["Click"] = True
57+
new_api_type["Click"] = True
4958

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))
5262

5363
ds_logout_internal()
5464
flash("You have logged out from DocuSign.")

app/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
)
1111

1212
from .ds_config import DS_CONFIG
13-
from .ds_config import EXAMPLES_API_TYPE
13+
from .api_type import EXAMPLES_API_TYPE
1414

1515
core = Blueprint("core", __name__)
1616

run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
port = int(os.environ.get("PORT", 5000))
88
app.run(host="0.0.0.0", port=port, debug=True)
99
else:
10-
app.run(extra_files="ds_config.py")
10+
app.run(extra_files="api_type.py")
1111

0 commit comments

Comments
 (0)