From 70b2d7fe6816be108c8344a4d72d8d699a6aeefe Mon Sep 17 00:00:00 2001 From: Ebuka Date: Fri, 25 Aug 2023 17:06:34 +0100 Subject: [PATCH 1/4] Minor Update --- one_wiki/hooks.py | 1 + 1 file changed, 1 insertion(+) diff --git a/one_wiki/hooks.py b/one_wiki/hooks.py index d9a7724..9206212 100644 --- a/one_wiki/hooks.py +++ b/one_wiki/hooks.py @@ -198,6 +198,7 @@ # Authentication and authorization # -------------------------------- + # auth_hooks = [ # "one_wiki.auth.validate" # ] From 6b8400f50869b610d904c0ded2eee869e763bcf0 Mon Sep 17 00:00:00 2001 From: Ebuka Date: Sat, 26 Aug 2023 00:24:45 +0100 Subject: [PATCH 2/4] Fix for new wiki creation --- one_wiki/overrides/wiki_page.py | 2 +- one_wiki/public/js/editor.js | 6 ++++- .../wiki_page/templates/wiki_doc.html | 23 +++++++++++-------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/one_wiki/overrides/wiki_page.py b/one_wiki/overrides/wiki_page.py index 0b8e985..4c29835 100644 --- a/one_wiki/overrides/wiki_page.py +++ b/one_wiki/overrides/wiki_page.py @@ -68,7 +68,7 @@ def update( if frappe.has_permission(doctype="Wiki Page Patch", ptype="submit", throw=False) and not draft: patch.approved_by = frappe.session.user - patch.status = "Approved" if rejected=='false' else "Rejected" + patch.status = "Approved" if rejected in ['false',False] else "Rejected" patch.submit() out.approved = True diff --git a/one_wiki/public/js/editor.js b/one_wiki/public/js/editor.js index 3e8fe5c..a447505 100644 --- a/one_wiki/public/js/editor.js +++ b/one_wiki/public/js/editor.js @@ -43,6 +43,7 @@ const getContent = () => { }; const saveWikiPage = (draft = false) => { + console.log("INSIDE FUNC") const urlParams = new URLSearchParams(window.location.search); const isEmptyEditor = !!urlParams.get("newWiki"); @@ -385,11 +386,14 @@ buttons.deleteTable.addEventListener("click", () => { }); buttons.saveWikiPage.addEventListener("click", () => { - + if(window.is_wiki_manager){ + console.log("CALLED HERE11111") saveWikiPage(draft = true); } else{ + console.log("CALLED HERE222222") + console.log(window.is_wiki_manager) saveWikiPage(); } diff --git a/one_wiki/templates/wiki_page/templates/wiki_doc.html b/one_wiki/templates/wiki_page/templates/wiki_doc.html index 4447abf..6235f49 100644 --- a/one_wiki/templates/wiki_page/templates/wiki_doc.html +++ b/one_wiki/templates/wiki_page/templates/wiki_doc.html @@ -89,14 +89,7 @@
On this page
$("#ar_lang").click(()=>{ change_lang($("#ar_lang").html()) }) - if('{{lang}}'=='en'){ - ; - - } - else{ - - ; - } + function is_editable_page(){ let value = window.location.search ? true : false @@ -115,7 +108,16 @@
On this page
$('.btn.btn-primary.save-wiki-page-btn.btn-sm').attr('data-tiptap-button', 'draftWikiPage') $('.btn.btn-primary.btn-sm.dropdown-toggle.dropdown-toggle-split').hide() } - + if(('{{is_wiki_manager}}'=='1')&& '{{can_approve}}' != "True"){ + $('.btn.btn-primary.save-wiki-page-btn.btn-sm').html("Submit") + $('.btn.btn-primary.save-wiki-page-btn.btn-sm').attr('data-tiptap-button', 'draftWikiPage'); + $('.btn.btn-primary.save-wiki-page-btn.btn-sm').off('click', 'saveWikiPage'); + $('[data-tiptap-button="saveWikiPage"]').hide() + $('.btn.btn-primary.save-wiki-page-btn.btn-sm').click(()=>{ + saveWikiPage(draft=false) + }) + + } if('{{can_approve}}' == "True"){ $('.btn.btn-primary.save-wiki-page-btn.btn-sm').hide() @@ -175,6 +177,9 @@
On this page
} const saveWikiPage = (draft = false,rejected = false) => { + console.log("CLICKED OOO") + console.log(draft) + console.log(rejected) const urlParams = new URLSearchParams(window.location.search); const isEmptyEditor = !!urlParams.get("newWiki"); From f5002719a3dc247ac74af3eb65ffdfc8a007c3b3 Mon Sep 17 00:00:00 2001 From: Ebuka Date: Sun, 27 Aug 2023 07:33:58 +0100 Subject: [PATCH 3/4] updated staging yml to clear cache --- .github/workflows/staging.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index a1fef5e..401dc4d 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -28,7 +28,9 @@ jobs: cd /home/frappe/frappe-bench bench restart ${{secrets.PASSKEY}} # bench setup requirements - bench build + bench build --app one_wiki + bench clear-cache + bench clear-website-cache bench migrate # sync database # we remove any unused dependencies bench doctor From 8e8381d5f40a3430bf7b31183d9f690adf7b0540 Mon Sep 17 00:00:00 2001 From: Ebuka Date: Tue, 29 Aug 2023 10:18:27 +0100 Subject: [PATCH 4/4] Update Wiki Sidebar --- one_wiki/overrides/wiki_page.py | 46 ++++++++++++++++----------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/one_wiki/overrides/wiki_page.py b/one_wiki/overrides/wiki_page.py index 4c29835..cfdfbc5 100644 --- a/one_wiki/overrides/wiki_page.py +++ b/one_wiki/overrides/wiki_page.py @@ -95,30 +95,28 @@ def get_sidebar_items_(self): for sidebar_item in wiki_sidebar: wiki_page = frappe.get_doc("Wiki Page", sidebar_item.wiki_page) - wiki_language = frappe.cache().get_value(f'wiki_language_{frappe.session.user}') - if wiki_language in ['en','ar']: - wiki_language_dict = {'en':'English','ar':'عربي'} - if wiki_page.language == wiki_language_dict[wiki_language]: - if sidebar_item.parent_label not in sidebar: - sidebar[sidebar_item.parent_label] = [ - { - "name": wiki_page.name, - "type": "Wiki Page", - "title": wiki_page.title, - "route": wiki_page.route, - "group_name": sidebar_item.parent_label, - } - ] - else: - sidebar[sidebar_item.parent_label] += [ - { - "name": wiki_page.name, - "type": "Wiki Page", - "title": wiki_page.title, - "route": wiki_page.route, - "group_name": sidebar_item.parent_label, - } - ] + wiki_language = self.language or 'English' + if wiki_page.language == wiki_language: + if sidebar_item.parent_label not in sidebar: + sidebar[sidebar_item.parent_label] = [ + { + "name": wiki_page.name, + "type": "Wiki Page", + "title": wiki_page.title, + "route": wiki_page.route, + "group_name": sidebar_item.parent_label, + } + ] + else: + sidebar[sidebar_item.parent_label] += [ + { + "name": wiki_page.name, + "type": "Wiki Page", + "title": wiki_page.title, + "route": wiki_page.route, + "group_name": sidebar_item.parent_label, + } + ] return self.get_items(sidebar)