From b96813d0e9e163f61966616bcdab2f37df223f74 Mon Sep 17 00:00:00 2001 From: Luke Gessler Date: Tue, 15 Jan 2019 18:36:26 -0500 Subject: [PATCH 1/3] don't overwrite text content if it exists already when saving --- editor.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/editor.py b/editor.py index 47e03f9..14b64ef 100755 --- a/editor.py +++ b/editor.py @@ -308,10 +308,9 @@ def load_page(user,admin,theform): # In the case of reloading after hitting 'save', either create new doc into db, or update db # CodeMirror sends the form with its code content in it before 'save' so we just display it again if theform.getvalue('code'): - text_content = theform.getvalue('code') + text_content = text_content or theform.getvalue('code') text_content = text_content.replace("\r","") text_content = re.sub(r'&(?!amp;)',r'&',text_content) # Escape unescaped XML & - text_content = unicode(text_content.decode("utf8")) if user != "demo": if int(doc_id)>int(max_id): create_document(doc_id, docname,corpus,status,assignee,repo_name,text_content) From 11cbc23015b89d0c4dc62f7e247724617fbb1636 Mon Sep 17 00:00:00 2001 From: Luke Gessler Date: Tue, 15 Jan 2019 19:46:49 -0500 Subject: [PATCH 2/3] Revert "don't overwrite text content if it exists already when saving" This reverts commit b96813d0e9e163f61966616bcdab2f37df223f74. --- editor.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/editor.py b/editor.py index 14b64ef..47e03f9 100755 --- a/editor.py +++ b/editor.py @@ -308,9 +308,10 @@ def load_page(user,admin,theform): # In the case of reloading after hitting 'save', either create new doc into db, or update db # CodeMirror sends the form with its code content in it before 'save' so we just display it again if theform.getvalue('code'): - text_content = text_content or theform.getvalue('code') + text_content = theform.getvalue('code') text_content = text_content.replace("\r","") text_content = re.sub(r'&(?!amp;)',r'&',text_content) # Escape unescaped XML & + text_content = unicode(text_content.decode("utf8")) if user != "demo": if int(doc_id)>int(max_id): create_document(doc_id, docname,corpus,status,assignee,repo_name,text_content) From e8a28b17dfa82455a767182b36330e5c6a8ecae7 Mon Sep 17 00:00:00 2001 From: Luke Gessler Date: Tue, 15 Jan 2019 19:46:57 -0500 Subject: [PATCH 3/3] Revert "only save doc after any text content changes have been made" This reverts commit 508551373ae6a4861922cd51ac3e0abb02413145. --- editor.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/editor.py b/editor.py index 47e03f9..154f89b 100755 --- a/editor.py +++ b/editor.py @@ -249,6 +249,19 @@ def load_page(user,admin,theform): text_content = generic_query("SELECT content FROM docs WHERE id=?",(doc_id,))[0][0] + # In the case of reloading after hitting 'save', either create new doc into db, or update db + # CodeMirror sends the form with its code content in it before 'save' so we just display it again + if theform.getvalue('code'): + text_content = theform.getvalue('code') + text_content = text_content.replace("\r","") + text_content = re.sub(r'&(?!amp;)',r'&',text_content) # Escape unescaped XML & + text_content = unicode(text_content.decode("utf8")) + if user != "demo": + if int(doc_id)>int(max_id): + create_document(doc_id, docname,corpus,status,assignee,repo_name,text_content) + else: + save_changes(doc_id,text_content) + git_status=False commit_message = "" @@ -305,19 +318,6 @@ def load_page(user,admin,theform): resp = requests.post(api_call, data, auth=HTTPBasicAuth(nlp_user,nlp_password)) text_content=resp.text - # In the case of reloading after hitting 'save', either create new doc into db, or update db - # CodeMirror sends the form with its code content in it before 'save' so we just display it again - if theform.getvalue('code'): - text_content = theform.getvalue('code') - text_content = text_content.replace("\r","") - text_content = re.sub(r'&(?!amp;)',r'&',text_content) # Escape unescaped XML & - text_content = unicode(text_content.decode("utf8")) - if user != "demo": - if int(doc_id)>int(max_id): - create_document(doc_id, docname,corpus,status,assignee,repo_name,text_content) - else: - save_changes(doc_id,text_content) - # Editing options # Docname # Filename