Merge pull request #10572 from scmmishra/fix-does-not-exist
This commit is contained in:
commit
f5315a5753
1 changed files with 27 additions and 16 deletions
|
|
@ -8,12 +8,26 @@ from json import loads, dumps
|
|||
from frappe import _, DoesNotExistError, ValidationError, _dict
|
||||
from frappe.boot import get_allowed_pages, get_allowed_reports
|
||||
from six import string_types
|
||||
from functools import wraps
|
||||
from frappe.cache_manager import (
|
||||
build_domain_restriced_doctype_cache,
|
||||
build_domain_restriced_page_cache,
|
||||
build_table_count_cache
|
||||
)
|
||||
|
||||
def handle_not_exist(fn):
|
||||
@wraps(fn)
|
||||
def wrapper(*args, **kwargs):
|
||||
try:
|
||||
return fn(*args, **kwargs)
|
||||
except DoesNotExistError:
|
||||
if frappe.message_log:
|
||||
frappe.message_log.pop()
|
||||
return []
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
class Workspace:
|
||||
def __init__(self, page_name):
|
||||
self.page_name = page_name
|
||||
|
|
@ -157,7 +171,7 @@ class Workspace:
|
|||
'user_can_dismiss': self.onboarding_doc.user_can_dismiss,
|
||||
'items': self.get_onboarding_steps()
|
||||
}
|
||||
|
||||
@handle_not_exist
|
||||
def get_cards(self):
|
||||
cards = self.doc.cards
|
||||
if not self.doc.hide_custom:
|
||||
|
|
@ -227,6 +241,7 @@ class Workspace:
|
|||
|
||||
return new_data
|
||||
|
||||
@handle_not_exist
|
||||
def get_charts(self):
|
||||
all_charts = []
|
||||
if frappe.has_permission("Dashboard Chart", throw=False):
|
||||
|
|
@ -242,6 +257,7 @@ class Workspace:
|
|||
|
||||
return all_charts
|
||||
|
||||
@handle_not_exist
|
||||
def get_shortcuts(self):
|
||||
|
||||
def _in_active_domains(item):
|
||||
|
|
@ -272,6 +288,7 @@ class Workspace:
|
|||
|
||||
return items
|
||||
|
||||
@handle_not_exist
|
||||
def get_onboarding_steps(self):
|
||||
steps = []
|
||||
for doc in self.onboarding_doc.get_steps():
|
||||
|
|
@ -296,21 +313,15 @@ def get_desktop_page(page):
|
|||
Returns:
|
||||
dict: dictionary of cards, charts and shortcuts to be displayed on website
|
||||
"""
|
||||
try:
|
||||
wspace = Workspace(page)
|
||||
wspace.build_workspace()
|
||||
return {
|
||||
'charts': wspace.charts,
|
||||
'shortcuts': wspace.shortcuts,
|
||||
'cards': wspace.cards,
|
||||
'onboarding': wspace.onboarding,
|
||||
'allow_customization': not wspace.doc.disable_user_customization
|
||||
}
|
||||
|
||||
except DoesNotExistError:
|
||||
if frappe.message_log:
|
||||
frappe.message_log.pop()
|
||||
return None
|
||||
wspace = Workspace(page)
|
||||
wspace.build_workspace()
|
||||
return {
|
||||
'charts': wspace.charts,
|
||||
'shortcuts': wspace.shortcuts,
|
||||
'cards': wspace.cards,
|
||||
'onboarding': wspace.onboarding,
|
||||
'allow_customization': not wspace.doc.disable_user_customization
|
||||
}
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_desk_sidebar_items(flatten=False):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue