Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6821 from pratu16x7/explore-2.0
feat(explore_page): Modules and Module Detail views
- Loading branch information
Showing
60 changed files
with
850 additions
and
1,252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
from __future__ import unicode_literals | ||
from frappe import _ | ||
import frappe | ||
from frappe.desk.moduleview import get_data | ||
from six import iteritems | ||
|
||
def get_modules_from_all_apps_for_user(user=None): | ||
if not user: | ||
user = frappe.session.user | ||
|
||
all_modules = get_modules_from_all_apps() | ||
user_blocked_modules = frappe.get_doc('User', user).get_blocked_modules() | ||
|
||
allowed_modules_list = [m for m in all_modules if m.get("module_name") not in user_blocked_modules] | ||
|
||
return allowed_modules_list | ||
|
||
def get_modules_from_all_apps(): | ||
modules_list = [] | ||
for app in frappe.get_installed_apps(): | ||
modules_list += get_modules_from_app(app) | ||
return modules_list | ||
|
||
def get_modules_from_app(app): | ||
try: | ||
modules = frappe.get_attr(app + '.config.desktop.get_data')() or {} | ||
except ImportError: | ||
return [] | ||
|
||
# Only newly formatted modules that have a category to be shown on desk | ||
modules = [m for m in modules if m.get("category")] | ||
|
||
active_domains = frappe.get_active_domains() | ||
|
||
if isinstance(modules, dict): | ||
active_modules_list = [] | ||
for m, module in iteritems(modules): | ||
module['module_name'] = m | ||
active_modules_list.append(module) | ||
else: | ||
active_modules_list = [] | ||
for m in modules: | ||
to_add = True | ||
module_name = m.get("module_name") | ||
|
||
# Check Domain | ||
if is_domain(m): | ||
if module_name not in active_domains: | ||
to_add = False | ||
|
||
if "condition" in m and not m["condition"]: | ||
to_add = False | ||
|
||
if to_add: | ||
onboard_present = is_onboard_present(m) if show_onboard(m) else False | ||
m["onboard_present"] = onboard_present | ||
active_modules_list.append(m) | ||
|
||
return active_modules_list | ||
|
||
def show_onboard(module): | ||
return module.get("type") == "module" and module.get("category") in ["Modules", "Domains"] | ||
|
||
def is_onboard_present(module): | ||
print(module["module_name"]) | ||
exists_cache = {} | ||
def exists(name, link_type): | ||
exists = exists_cache.get(name) | ||
if not exists: | ||
if link_type == "doctype" and not frappe.db.get_value('DocType', name, 'issingle'): | ||
exists = frappe.db.count(name) | ||
else: | ||
exists = True | ||
exists_cache[name] = exists | ||
return exists | ||
|
||
sections = get_data(module["module_name"], False) | ||
for section in sections: | ||
for item in section["items"]: | ||
if exists(item.get("name"), item.get("type")): | ||
return True | ||
return False | ||
|
||
def is_domain(module): | ||
return module.get("category") == "Domains" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,87 @@ | ||
from __future__ import unicode_literals | ||
import frappe | ||
from frappe import _ | ||
|
||
def get_data(): | ||
return [ | ||
# Administration | ||
{ | ||
"module_name": "Desk", | ||
"category": "Administration", | ||
"label": _("Tools"), | ||
"color": "#FFF5A7", | ||
"reverse": 1, | ||
"icon": "octicon octicon-calendar", | ||
"type": "module" | ||
}, | ||
{ | ||
"module_name": "File Manager", | ||
"color": "#AA784D", | ||
"doctype": "File", | ||
"icon": "octicon octicon-file-directory", | ||
"label": _("File Manager"), | ||
"link": "List/File", | ||
"type": "list", | ||
"hidden": 1 | ||
"type": "module", | ||
"description": "Todos, Notes and other basic tools to help you track your work." | ||
}, | ||
{ | ||
"module_name": "Website", | ||
"color": "#16a085", | ||
"icon": "octicon octicon-globe", | ||
"module_name": "Settings", | ||
"category": "Administration", | ||
"label": _("Settings"), | ||
"color": "#bdc3c7", | ||
"reverse": 1, | ||
"icon": "octicon octicon-settings", | ||
"type": "module", | ||
"hidden": 1 | ||
"hidden": 1, | ||
"description": "Configure your ERPNext account." | ||
}, | ||
{ | ||
"module_name": "Integrations", | ||
"category": "Administration", | ||
"label": _("Integrations"), | ||
"color": "#16a085", | ||
"icon": "octicon octicon-globe", | ||
"type": "module", | ||
"hidden": 1 | ||
}, | ||
{ | ||
"module_name": "Setup", | ||
"color": "#bdc3c7", | ||
"reverse": 1, | ||
"icon": "octicon octicon-settings", | ||
"type": "module", | ||
"hidden": 1 | ||
"hidden": 1, | ||
"description": "DropBox, Woocomerce, AWS, Shopify and GoCardless." | ||
}, | ||
{ | ||
"module_name": 'Email Inbox', | ||
"type": 'list', | ||
"label": 'Email Inbox', | ||
"_label": _('Email Inbox'), | ||
"_id": 'Email Inbox', | ||
"_doctype": 'Communication', | ||
"icon": 'fa fa-envelope-o', | ||
"color": '#589494', | ||
"link": 'List/Communication/Inbox' | ||
"module_name": 'Contacts', | ||
"category": "Administration", | ||
"label": _("Contacts"), | ||
"type": 'module', | ||
"icon": "octicon octicon-book", | ||
"color": '#ffaedb', | ||
"hidden": 1, | ||
"description": "People Contacts and Address Book." | ||
}, | ||
{ | ||
"module_name": "Core", | ||
"label": "Developer", | ||
"category": "Administration", | ||
"_label": _("Developer"), | ||
"label": "Developer", | ||
"color": "#589494", | ||
"icon": "octicon octicon-circuit-board", | ||
"type": "module", | ||
"system_manager": 1, | ||
"hidden": 1 | ||
"condition": getattr(frappe.local.conf, 'developer_mode', 0), | ||
"hidden": 1, | ||
"description": "The Frappe innards of ERPNext. (Only active when developer mode is enabled)" | ||
}, | ||
|
||
# Places | ||
{ | ||
"module_name": 'Contacts', | ||
"type": 'module', | ||
"icon": "octicon octicon-book", | ||
"color": '#FFAEDB', | ||
"module_name": "Website", | ||
"category": "Places", | ||
"label": _("Website"), | ||
"_label": _("Website"), | ||
"color": "#16a085", | ||
"icon": "octicon octicon-globe", | ||
"type": "module", | ||
"hidden": 1, | ||
"description": "Webpages and the Portal Side of Things." | ||
}, | ||
{ | ||
"module_name": 'Social', | ||
"category": "Places", | ||
"label": _('Social'), | ||
"icon": "octicon octicon-heart", | ||
"type": 'link', | ||
"link": 'social/home', | ||
"link": '#social/home', | ||
"color": '#FF4136', | ||
'standard': 1, | ||
'idx': 15 | ||
'idx': 15, | ||
"description": "Build your profile and share posts on the feed with other users." | ||
}, | ||
{ | ||
"module_name": 'Settings', | ||
"color": "#bdc3c7", | ||
"reverse": 1, | ||
"icon": "octicon octicon-settings", | ||
"type": "module" | ||
} | ||
] |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.