def test_desktop_icon_for_domainification(self):
		"""desktop icon should be hidden if doctype's restrict to domain is not in active domains"""

		test_doctype = self.new_doctype("Test Domainification")
		test_doctype.restrict_to_domain = "_Test Domain 2"
		test_doctype.insert()

		self.add_active_domain("_Test Domain 2")
		add_user_icon("Test Domainification")

		icons = get_desktop_icons()

		doctypes = [
			icon.get("_doctype")
			for icon in icons
			if icon.get("_doctype") == "Test Domainification" and icon.get("blocked") == 0
		]
		self.assertTrue("Test Domainification" in doctypes)

		# doctype should be hidden from the desk
		self.remove_from_active_domains("_Test Domain 2")
		clear_desktop_icons_cache()  # clear cache to fetch the desktop icon according to new active domains
		icons = get_desktop_icons()

		doctypes = [
			icon.get("_doctype")
			for icon in icons
			if icon.get("_doctype") == "Test Domainification" and icon.get("blocked") == 0
		]
		self.assertFalse("Test Domainification" in doctypes)
Example #2
0
	def test_re_order_desktop_icons(self):
		icons = [d.module_name for d in get_desktop_icons()]
		m0, m1 = icons[0], icons[1]
		set_order([m1, m0] + icons[2:], frappe.session.user)

		# reload
		icons = [d.module_name for d in get_desktop_icons()]

		# check switched order
		self.assertEqual(icons[0], m1)
		self.assertEqual(icons[1], m0)
Example #3
0
def get_user_icons(user):
	'''Get user icons for module setup page'''
	user_perms = UserPermissions(user)
	user_perms.build_permissions()

	from frappe.boot import get_allowed_pages

	allowed_pages = get_allowed_pages()

	icons = []
	for icon in get_desktop_icons(user):
		add = True
		if icon.hidden_in_standard:
			add = False

		if not icon.custom:
			if icon.module_name=='Learn':
				pass

			elif icon.type=="page" and icon.link not in allowed_pages:
				add = False

			elif icon.type=="module" and icon.module_name not in user_perms.allow_modules:
				add = False

		if add:
			icons.append(icon)

	return icons
def get_user_icons(user):
    '''Get user icons for module setup page'''
    user_perms = UserPermissions(user)
    user_perms.build_permissions()

    from frappe.boot import get_allowed_pages

    allowed_pages = get_allowed_pages()

    icons = []
    for icon in get_desktop_icons(user):
        add = True
        if icon.hidden_in_standard:
            add = False

        if not icon.custom:
            if icon.module_name == 'Learn':
                pass

            elif icon.type == "page" and icon.link not in allowed_pages:
                add = False

            elif icon.type == "module" and icon.module_name not in user_perms.allow_modules:
                add = False

        if add:
            icons.append(icon)

    return icons
def execute():
	'''hide new style icons if old ones are set'''
	sync_desktop_icons()

	for user in frappe.get_all('User', filters={'user_type': 'System User'}):
		desktop_icons = get_desktop_icons(user.name)
		icons_dict = {}
		for d in desktop_icons:
			if not d.hidden:
				icons_dict[d.module_name] = d

		for key in (('Selling', 'Customer'), ('Stock', 'Item'), ('Buying', 'Supplier'),
			('HR', 'Employee'), ('CRM', 'Lead'), ('Support', 'Issue'), ('Projects', 'Project')):
			if key[0] in icons_dict and key[1] in icons_dict:
				set_hidden(key[1], user.name, 1)
Example #6
0
	def test_desktop_icon_for_domainification(self):
		""" desktop icon should be hidden if doctype's restrict to domain is not in active domains """

		test_doctype = self.new_doctype("Test Domainification")
		test_doctype.restrict_to_domain = "_Test Domain 2"
		test_doctype.insert()

		self.add_active_domain("_Test Domain 2")
		add_user_icon('Test Domainification')

		icons = get_desktop_icons()

		doctypes = [icon.get("_doctype") for icon in icons if icon.get("_doctype") == "Test Domainification" \
			and icon.get("blocked") == 0]
		self.assertTrue("Test Domainification" in doctypes)

		# doctype should be hidden from the desk
		self.remove_from_active_domains("_Test Domain 2")
		clear_desktop_icons_cache()		# clear cache to fetch the desktop icon according to new active domains
		icons = get_desktop_icons()

		doctypes = [icon.get("_doctype") for icon in icons if icon.get("_doctype") == "Test Domainification" \
			and icon.get("blocked") == 0]
		self.assertFalse("Test Domainification" in doctypes)
Example #7
0
	def get_icon(self, module_name):
		for i in get_desktop_icons():
			if i.module_name == module_name:
				return i

		return None
Example #8
0
def load_desktop_icons(bootinfo):
    from frappe.desk.doctype.desktop_icon.desktop_icon import get_desktop_icons
    bootinfo.desktop_icons = get_desktop_icons()
Example #9
0
def load_desktop_icons(bootinfo):
	from frappe.desk.doctype.desktop_icon.desktop_icon import get_desktop_icons
	bootinfo.desktop_icons = get_desktop_icons()