<commit_before># -*- coding: utf-8 -*-
# Copyright (c) 2019, Frappe Technologies and contributors
# For license information, please see license.txt

from __future__ import unicode_literals
import frappe
from frappe import _
import datetime
import json
from frappe.core.page.dashboard.dashboard import cache_source, get_from_date_from_timespan
from frappe.utils import nowdate, add_to_date, getdate, get_last_day, formatdate, get_datetime
from frappe.model.naming import append_number_if_name_exists
from frappe.boot import get_allowed_reports
from frappe.model.document import Document


def get_permission_query_conditions(user):

	if not user:
		user = frappe.session.user

	if user == 'Administrator':
		return

	roles = frappe.get_roles(user)
	if "System Manager" in roles:
		return None

	allowed_doctypes = tuple(frappe.permissions.get_doctypes_with_read())
	allowed_reports = tuple([key.encode('UTF8') for key in get_allowed_reports()])

	return '''
			`tabDashboard Chart`.`document_type` in {allowed_doctypes}
			or `tabDashboard Chart`.`report_name` in {allowed_reports}
		'''.format(
			allowed_doctypes=allowed_doctypes,
			allowed_reports=allowed_reports<commit_msg>fix: only encode if type is not str while getting allowed reports<commit_after># -*- coding: utf-8 -*-
# Copyright (c) 2019, Frappe Technologies and contributors
# For license information, please see license.txt

from __future__ import unicode_literals
import frappe
from frappe import _
import datetime
import json
from frappe.core.page.dashboard.dashboard import cache_source, get_from_date_from_timespan
from frappe.utils import nowdate, add_to_date, getdate, get_last_day, formatdate, get_datetime
from frappe.model.naming import append_number_if_name_exists
from frappe.boot import get_allowed_reports
from frappe.model.document import Document


def get_permission_query_conditions(user):

	if not user:
		user = frappe.session.user

	if user == 'Administrator':
		return

	roles = frappe.get_roles(user)
	if "System Manager" in roles:
		return None

	allowed_doctypes = tuple(frappe.permissions.get_doctypes_with_read())
	allowed_reports = tuple([key if type(key) == str else key.encode('UTF8') for key in get_allowed_reports()])

	return '''
			`tabDashboard Chart`.`document_type` in {allowed_doctypes}
			or `tabDashboard Chart`.`report_name` in {allowed_reports}
		'''.format(
			allowed_doctypes=allowed_doctypes,
			allowed_reports=allowed_reports
{'fraction_non_alphanumeric': 0.08241082410824108, 'fraction_numerical': 0.004920049200492005, 'mean_word_length': 5.9714285714285715, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7483209', 'n_tokens_mistral': 808, 'n_tokens_neox': 783, 'n_words': 207}