From 6207d0398454ff4bf43855a2eff4e900c4b76e2b Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 13 Nov 2023 09:29:11 +0300 Subject: [PATCH] python: saving formsdata --- .../python/src/utils/trackManager.py | 17 ++++++++++++++++- .../python/src/utils/users.py | 10 +++++++--- .../python/src/views/actions.py | 2 +- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/web/documentserver-example/python/src/utils/trackManager.py b/web/documentserver-example/python/src/utils/trackManager.py index 574daadf..6a6e12dd 100755 --- a/web/documentserver-example/python/src/utils/trackManager.py +++ b/web/documentserver-example/python/src/utils/trackManager.py @@ -159,12 +159,27 @@ def processForceSave(body, filename, usAddr): if forcesavePath == "": forcesavePath = docManager.getForcesavePath(filename, usAddr, True) - docManager.saveFile(download, forcesavePath) # save document file + docManager.saveFile(data, forcesavePath) # save document file if isSubmitForm: uid = body['actions'][0]['userid'] # get the user id historyManager.createMetaData(filename, uid, "Filling Form", usAddr) # create meta data for forcesaved file + forms_data_url = body.get('formsdataurl') + if forms_data_url: + data_name = docManager.getCorrectName(fileUtils.getFileNameWithoutExt(filename) + ".txt", usAddr) + data_path = docManager.getStoragePath(data_name, usAddr) + + forms_data = docManager.downloadFileFromUri(forms_data_url); + + if data is None: + raise Exception("Document editing service didn't return forms_data"); + else: + with open(data_path, 'w') as file: + file.write(forms_data.text) + else: + raise Exception('Document editing service did not return forms_data_url') + # create a command request def commandRequest(method, key, meta=None): diff --git a/web/documentserver-example/python/src/utils/users.py b/web/documentserver-example/python/src/utils/users.py index c390c930..354ce639 100644 --- a/web/documentserver-example/python/src/utils/users.py +++ b/web/documentserver-example/python/src/utils/users.py @@ -42,7 +42,8 @@ descr_user_1 = [ "Can perform all actions with comments", "The file favorite state is undefined", "Can create files from templates using data from the editor", - "Can see the information about all users" + "Can see the information about all users", + "Can submit forms" ] descr_user_2 = [ @@ -52,7 +53,8 @@ descr_user_2 = [ "Can remove his own comments only"), "This file is marked as favorite", "Can create new files from the editor", - "Can see the information about users from Group2 and users who don’t belong to any group" + "Can see the information about users from Group2 and users who don’t belong to any group", + "Can’t submit forms" ] descr_user_3 = [ @@ -64,7 +66,8 @@ descr_user_3 = [ "Can’t download the file", "Can’t print the file", "Can create new files from the editor", - "Can see the information about Group2 users" + "Can see the information about Group2 users", + "Can’t submit forms" ] descr_user_0 = [ @@ -80,6 +83,7 @@ descr_user_0 = [ "Can't view chat", "Can't protect file", "View file without collaboration", + "Can’t submit forms" ] USERS = [ diff --git a/web/documentserver-example/python/src/views/actions.py b/web/documentserver-example/python/src/views/actions.py index d4bc7eb6..c1a647ce 100755 --- a/web/documentserver-example/python/src/views/actions.py +++ b/web/documentserver-example/python/src/views/actions.py @@ -200,7 +200,7 @@ def edit(request): edMode = 'fillForms' canEdit = True # if the Submit form button is displayed or hidden - submitForm = edMode == 'fillForms' and user.id == 'uid-1' and False + submitForm = edMode == 'fillForms' and user.id == 'uid-1' mode = 'edit' if canEdit & (edMode != 'view') else 'view' # if the file can't be edited, the mode is view types = ['desktop', 'mobile', 'embedded']