From c25fd1ba735dc3fb9b58279ab3b603991f99fd6e Mon Sep 17 00:00:00 2001 From: Aysha Date: Sat, 28 Sep 2024 11:53:47 +0530 Subject: [PATCH] fix: display private pages for logged in users --- wiki/wiki/doctype/wiki_page/wiki_page.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/wiki/wiki/doctype/wiki_page/wiki_page.py b/wiki/wiki/doctype/wiki_page/wiki_page.py index 7f12fd10..9e0b9032 100644 --- a/wiki/wiki/doctype/wiki_page/wiki_page.py +++ b/wiki/wiki/doctype/wiki_page/wiki_page.py @@ -148,14 +148,9 @@ def update_page(self, title, content, edit_message, raised_by=None): self.save() - def verify_permission(self, permtype): - if permtype == "read" and self.allow_guest: - return True - permitted = frappe.has_permission(self.doctype, permtype, self) + def verify_permission(self): + permitted = self.allow_guest or frappe.session.user != "Guest" if not permitted: - action = permtype - if action == "write": - action = "edit" frappe.local.response["type"] = "redirect" frappe.local.response["location"] = "/login?" + urlencode({"redirect-to": frappe.request.url}) raise frappe.Redirect @@ -205,7 +200,7 @@ def calculate_toc_html(self, html): return toc_html def get_context(self, context): - self.verify_permission("read") + self.verify_permission() self.set_breadcrumbs(context) wiki_settings = frappe.get_single("Wiki Settings") @@ -310,10 +305,9 @@ def get_sidebar_items(self): wiki_page = frappe.get_doc("Wiki Page", sidebar_item.wiki_page) - if not wiki_page.allow_guest: - permitted = frappe.has_permission(wiki_page.doctype, "read", wiki_page) - if not permitted: - continue + permitted = wiki_page.allow_guest or frappe.session.user != "Guest" + if not permitted: + continue if sidebar_item.parent_label not in sidebar: sidebar[sidebar_item.parent_label] = [