Skip to content

Commit

Permalink
feat: hide custom workspaces (LAN-45) (#232)
Browse files Browse the repository at this point in the history
Co-authored-by: Raffael Meyer <14891507+barredterra@users.noreply.github.com>
  • Loading branch information
diePuppe and barredterra authored Jul 18, 2023
1 parent 9769ff0 commit 03864ec
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions landa/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@
"on_update": "landa.organization_management.user.user.on_update",
"on_trash": "landa.organization_management.user.user.on_trash",
},
"Workspace": {
"validate": "landa.workspace.validate",
},
}

# Scheduled Tasks
Expand Down
1 change: 1 addition & 0 deletions landa/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ landa.patches.delete_old_scheduled_job_logs
landa.patches.update_system_settings
landa.patches.delete_customized_workspaces # 2023-06-06
landa.patches.build_water_body_cache
landa.patches.set_hide_custom_in_user_workspaces
17 changes: 17 additions & 0 deletions landa/patches/set_hide_custom_in_user_workspaces.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import frappe

from landa.workspace import LANDA_WORKSPACES


def execute():
"""Hide custom reports in existing customized landa workspaces."""
for workspace in frappe.get_all(
"Workspace",
filters={
"for_user": ("is", "set"),
"hide_custom": 0,
"extends": ("in", LANDA_WORKSPACES),
},
pluck="name",
):
frappe.db.set_value("Workspace", workspace, "hide_custom", 1)
13 changes: 13 additions & 0 deletions landa/workspace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from frappe.desk.doctype.workspace.workspace import Workspace

LANDA_WORKSPACES = (
"Water Body Management",
"Organization Management",
"Order Management",
)


def validate(doc: Workspace, method=None) -> None:
# Custom reports (possibly of other users) should not be visible
if doc.for_user and doc.hide_custom == 0 and doc.extends in LANDA_WORKSPACES:
doc.hide_custom = 1

0 comments on commit 03864ec

Please sign in to comment.