diff --git a/commit/commit/doctype/commit_docs/commit_docs.py b/commit/commit/doctype/commit_docs/commit_docs.py
index 152e3bd..ddcfb68 100644
--- a/commit/commit/doctype/commit_docs/commit_docs.py
+++ b/commit/commit/doctype/commit_docs/commit_docs.py
@@ -88,19 +88,21 @@ def get_commit_docs_details(route:str):
# 4. Get The Sidebar Items for the Commit Docs
# 5. Return the Sidebar Items
'''
-
+ user = frappe.session.user
# Check if the Commit Docs Document Exists
if frappe.db.exists('Commit Docs',{'route':route}):
- # Check if the document is published
- if frappe.db.get_value('Commit Docs',{'route':route},'published'):
- # Get the Commit Docs Document
+ if user == "Guest":
+ if frappe.db.get_value('Commit Docs',{'route':route},'published'):
+ commit_docs = frappe.get_doc('Commit Docs',{'route':route}).as_dict()
+
+ return parse_commit_docs(commit_docs)
+ else:
+ return frappe.throw('Docs Not Published')
+ else:
commit_docs = frappe.get_doc('Commit Docs',{'route':route}).as_dict()
return parse_commit_docs(commit_docs)
-
- else:
- return frappe.throw('Docs Not Published')
else:
return frappe.throw('Docs Not Found')
@@ -231,7 +233,7 @@ def get_group_items(commit_docs_page):
# Check permissions and publication status
permitted = group_commit_docs_page.allow_guest or frappe.session.user != 'Guest'
- published = group_commit_docs_page.published
+ published = group_commit_docs_page.published or frappe.session.user != 'Guest'
if not permitted or not published:
continue
@@ -252,7 +254,8 @@ def get_group_items(commit_docs_page):
'icon': group_commit_docs_page.icon,
'parent_name': commit_docs_page.name,
'is_group_page': True,
- 'group_items': nested_group_items
+ 'group_items': nested_group_items,
+ "published":group_commit_docs_page.published
})
else:
# If it's a regular Docs Page, add it directly
@@ -264,7 +267,8 @@ def get_group_items(commit_docs_page):
'badge': group_commit_docs_page.badge,
'badge_color': group_commit_docs_page.badge_color,
'icon': group_commit_docs_page.icon,
- 'parent_name': commit_docs_page.name
+ 'parent_name': commit_docs_page.name,
+ "published":group_commit_docs_page.published
})
# Add route to route_map
route_map[group_commit_docs_page.route] = group_commit_docs_page.name
@@ -278,7 +282,7 @@ def get_group_items(commit_docs_page):
commit_docs_page = frappe.get_doc('Commit Docs Page', sidebar_item.docs_page)
permitted = commit_docs_page.allow_guest or frappe.session.user != 'Guest'
- published = commit_docs_page.published
+ published = commit_docs_page.published or frappe.session.user != 'Guest'
is_group_page = commit_docs_page.is_group_page
if not permitted or not published:
@@ -298,7 +302,8 @@ def get_group_items(commit_docs_page):
'icon': commit_docs_page.icon,
'group_name': sidebar_item.parent_label,
'is_group_page': is_group_page,
- 'group_items': group_items if is_group_page else None
+ 'group_items': group_items if is_group_page else None,
+ 'published': commit_docs_page.published
}
# Add sidebar entry to the parent label
diff --git a/commit/commit/doctype/commit_docs_page/commit_docs_page.py b/commit/commit/doctype/commit_docs_page/commit_docs_page.py
index 3726f55..25ff59f 100644
--- a/commit/commit/doctype/commit_docs_page/commit_docs_page.py
+++ b/commit/commit/doctype/commit_docs_page/commit_docs_page.py
@@ -98,8 +98,13 @@ def get_commit_docs_page(name):
'''
Get the Commit Docs Page
'''
+ user = frappe.session.user
+
doc = frappe.get_doc('Commit Docs Page', name).as_dict()
+ if user == "Guest" and not doc.allow_guest and not doc.published:
+ frappe.throw("You are not allowed to view this page")
+
# Get the content as HTML
html = frappe.utils.md_to_html(doc.content)
diff --git a/dashboard/src/pages/features/docs/Sidebar.tsx b/dashboard/src/pages/features/docs/Sidebar.tsx
index 51f661a..5774e5e 100644
--- a/dashboard/src/pages/features/docs/Sidebar.tsx
+++ b/dashboard/src/pages/features/docs/Sidebar.tsx
@@ -25,6 +25,11 @@ export const Sidebar = ({ ID }: { ID: string }) => {
)}
{commit_docs.header &&