From cb339af3d075e92e87dade9e52087b7933dbbda9 Mon Sep 17 00:00:00 2001 From: annahileta Date: Tue, 15 Aug 2023 17:44:40 +0300 Subject: [PATCH 1/2] fixed bulk import and other minor issues --- .../eg004_add_users_via_bulk_import.py | 36 +++++++++++-------- app/click/examples/eg006_embed_clickwrap.py | 3 +- app/click/views/eg004_list_clickwraps.py | 2 +- .../views/eg001_get_monitoring_data.py | 2 +- .../eg004_add_users_via_bulk_import.html | 2 +- ...pdate_user_product_permission_profile.html | 7 ++-- 6 files changed, 30 insertions(+), 22 deletions(-) diff --git a/app/admin/examples/eg004_add_users_via_bulk_import.py b/app/admin/examples/eg004_add_users_via_bulk_import.py index 3d00fbd..1059750 100644 --- a/app/admin/examples/eg004_add_users_via_bulk_import.py +++ b/app/admin/examples/eg004_add_users_via_bulk_import.py @@ -8,6 +8,18 @@ class Eg004AddUsersViaBulkImportController: + @staticmethod + def get_example_csv(): + """ + Creates an example of a CSV file, such as that needs to be sent to the Docusign server + """ + + # Returns an example of a CSV file + return ( + "AccountID,UserName,UserEmail,PermissionSet\n" + f"{session['ds_account_id']},Example User1,exampleuser1@example.com,DS Admin\n" + f"{session['ds_account_id']},Example User2,exampleuser2@example.com,DS Admin\n" + ) @staticmethod def worker(self, request): @@ -35,7 +47,16 @@ def worker(self, request): uploaded_file = request.files['csv_file'] csv_folder_path = path.abspath(path.join(path.dirname(path.realpath(__file__)), "csv")) csv_file_path = path.join(csv_folder_path, "uploaded_file.csv") - uploaded_file.save(csv_file_path) + + if uploaded_file and not uploaded_file.filename == '': + uploaded_file.save(csv_file_path) + else: + content = Eg004AddUsersViaBulkImportController.get_example_csv() + + modified_content = content.replace("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", session["ds_account_id"]) + + with open(csv_file_path, "w") as file: + file.write(modified_content) # Creating an import API object import_api = BulkImportsApi(api_client=api_client) @@ -57,19 +78,6 @@ def worker(self, request): return response - @staticmethod - def get_example_csv(): - """ - Creates an example of a CSV file, such as that needs to be sent to the Docusign server - """ - - # Returns an example of a CSV file - return ( - "AccountID,UserName,UserEmail,PermissionSet\n" - f"{session['ds_account_id']},Example User1,exampleuser1@example.com,DS Admin\n" - f"{session['ds_account_id']},Example User2,exampleuser2@example.com,DS Admin\n" - ) - @staticmethod def check_status(): """Check request status""" diff --git a/app/click/examples/eg006_embed_clickwrap.py b/app/click/examples/eg006_embed_clickwrap.py index d5202f4..acd5a2e 100644 --- a/app/click/examples/eg006_embed_clickwrap.py +++ b/app/click/examples/eg006_embed_clickwrap.py @@ -17,7 +17,8 @@ def get_args(): "email": request.form.get("email"), "company": request.form.get("company"), "title": request.form.get("title"), - "date": request.form.get("date"), + "date": request.form.get("date"), + "statuses": ["inactive", "draft"] } @staticmethod diff --git a/app/click/views/eg004_list_clickwraps.py b/app/click/views/eg004_list_clickwraps.py index 63d82b9..10f7794 100644 --- a/app/click/views/eg004_list_clickwraps.py +++ b/app/click/views/eg004_list_clickwraps.py @@ -43,7 +43,7 @@ def clickwrap_list(): "example_done.html", title=example["ExampleName"], message="Results from the ClickWraps::getClickwraps method:", - json=json.dumps(json.dumps(results.to_dict(), default=str)) + json=json.dumps(json.dumps(results, default=str)) ) diff --git a/app/monitor/views/eg001_get_monitoring_data.py b/app/monitor/views/eg001_get_monitoring_data.py index 2326f7c..94e8e46 100644 --- a/app/monitor/views/eg001_get_monitoring_data.py +++ b/app/monitor/views/eg001_get_monitoring_data.py @@ -41,7 +41,7 @@ def get_monitoring_data(): "example_done.html", title=example["ExampleName"], message="Results from DataSet:getStream method:", - json=json.dumps(json.dumps(results, default=str)) + json=json.dumps(json.dumps(results, default=str).replace('\\"', '').replace("'", "")) ) @meg001.route(f"/{eg}", methods=["GET"]) diff --git a/app/templates/admin/eg004_add_users_via_bulk_import.html b/app/templates/admin/eg004_add_users_via_bulk_import.html index b506ae1..52fa51f 100644 --- a/app/templates/admin/eg004_add_users_via_bulk_import.html +++ b/app/templates/admin/eg004_add_users_via_bulk_import.html @@ -7,7 +7,7 @@
- +
diff --git a/app/templates/admin/eg008_update_user_product_permission_profile.html b/app/templates/admin/eg008_update_user_product_permission_profile.html index b4c670a..c3c7f76 100644 --- a/app/templates/admin/eg008_update_user_product_permission_profile.html +++ b/app/templates/admin/eg008_update_user_product_permission_profile.html @@ -4,8 +4,7 @@ {% set form_index = 0 %} {% set product_index = 0 %} -{% set esign_permission_index = 1 %} -{% set clm_permission_index = 2 %} +{% set permission_index = 1 %} {% set redirect_to2_index = 0 %} {% if email_ok %} @@ -29,7 +28,7 @@ {% if esign_permission_profiles_list %}