Skip to content

Commit

Permalink
Merge pull request #19496 from barredterra/workspace-perms
Browse files Browse the repository at this point in the history
  • Loading branch information
shariquerik committed Jan 7, 2023
2 parents 4654db6 + 033c6b3 commit 0a8591f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
11 changes: 1 addition & 10 deletions frappe/desk/doctype/workspace/workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
],
"in_create": 1,
"links": [],
"modified": "2022-08-16 18:01:42.632238",
"modified": "2023-01-05 16:22:42.593601",
"modified_by": "Administrator",
"module": "Desk",
"name": "Workspace",
Expand All @@ -195,15 +195,6 @@
"role": "Workspace Manager",
"share": 1,
"write": 1
},
{
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "All",
"share": 1
}
],
"sort_field": "modified",
Expand Down
13 changes: 6 additions & 7 deletions frappe/desk/doctype/workspace/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def save_page(title, public, new_widgets, blocks):

if not public:
filters = {"for_user": frappe.session.user, "label": title + "-" + frappe.session.user}
pages = frappe.get_list("Workspace", filters=filters)
pages = frappe.get_all("Workspace", filters=filters)
if pages:
doc = frappe.get_doc("Workspace", pages[0])

Expand All @@ -209,12 +209,8 @@ def save_page(title, public, new_widgets, blocks):
@frappe.whitelist()
def update_page(name, title, icon, parent, public):
public = frappe.parse_json(public)

doc = frappe.get_doc("Workspace", name)

filters = {"parent_page": doc.title, "public": doc.public}
child_docs = frappe.get_list("Workspace", filters=filters)

if doc:
doc.title = title
doc.icon = icon
Expand All @@ -230,6 +226,9 @@ def update_page(name, title, icon, parent, public):
rename_doc("Workspace", name, new_name, force=True, ignore_permissions=True)

# update new name and public in child pages
child_docs = frappe.get_all(
"Workspace", filters={"parent_page": doc.title, "public": doc.public}
)
if child_docs:
for child in child_docs:
child_doc = frappe.get_doc("Workspace", child.name)
Expand Down Expand Up @@ -338,7 +337,7 @@ def last_sequence_id(doc):
if not doc_exists:
return 0

return frappe.db.get_list(
return frappe.get_all(
"Workspace",
fields=["sequence_id"],
filters={"public": doc.public, "for_user": doc.for_user},
Expand All @@ -347,7 +346,7 @@ def last_sequence_id(doc):


def get_page_list(fields, filters):
return frappe.get_list("Workspace", fields=fields, filters=filters, order_by="sequence_id asc")
return frappe.get_all("Workspace", fields=fields, filters=filters, order_by="sequence_id asc")


def is_workspace_manager():
Expand Down
3 changes: 2 additions & 1 deletion frappe/public/js/frappe/views/workspace/workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,11 @@ frappe.views.Workspace = class Workspace {
frappe.show_alert({ message: __("Customizations Discarded"), indicator: "info" });
});

page.name &&
if (page.name && frappe.perm.has_perm("Workspace", 0, "read")) {
this.page.add_inner_button(__("Settings"), () => {
frappe.set_route(`workspace/${page.name}`);
});
}
}

show_sidebar_actions() {
Expand Down

0 comments on commit 0a8591f

Please sign in to comment.