Merge branch 'hotfix'

This commit is contained in:
Frappe Bot 2018-12-19 06:19:04 +00:00
commit cd50fecea0
8 changed files with 45 additions and 5 deletions

View file

@ -14,7 +14,7 @@ import os, sys, importlib, inspect, json
from .exceptions import *
from .utils.jinja import get_jenv, get_template, render_template, get_email_from_template
__version__ = '10.1.67'
__version__ = '10.1.68'
__title__ = "Frappe Framework"
local = Local()

View file

@ -149,7 +149,7 @@ class Report(Document):
if params.get('sort_by'):
order_by = _format(params.get('sort_by').split('.')) + ' ' + params.get('sort_order')
else:
order_by = _format(self.ref_doctype, 'modified') + ' desc'
order_by = _format([self.ref_doctype, 'modified']) + ' desc'
if params.get('sort_by_next'):
order_by += ', ' + _format(params.get('sort_by_next').split('.')) + ' ' + params.get('sort_order_next')

View file

@ -53,3 +53,19 @@ class TestReport(unittest.TestCase):
report = frappe.get_doc('Report', 'Test Report')
self.assertNotEquals(report.is_permitted(), True)
# test for the `_format` method if report data doesn't have sort_by parameter
def test_format_method(self):
if frappe.db.exists('Report', 'User Activity Report Without Sort'):
frappe.delete_doc('Report', 'User Activity Report Without Sort')
with open(os.path.join(os.path.dirname(__file__), 'user_activity_report_without_sort.json'), 'r') as f:
frappe.get_doc(json.loads(f.read())).insert()
report = frappe.get_doc('Report', 'User Activity Report Without Sort')
# this would raise an error without the fix added along with this test case
columns, data = report.get_data()
self.assertEqual(columns[0].get('label'), 'ID')
self.assertEqual(columns[1].get('label'), 'User Type')
self.assertTrue('Administrator' in [d[0] for d in data])
frappe.delete_doc('Report', 'User Activity Report Without Sort')

View file

@ -0,0 +1,17 @@
{
"add_total_row": 0,
"apply_user_permissions": 1,
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"is_standard": "No",
"javascript": null,
"json": "{\"filters\":[],\"columns\":[[\"name\",\"User\"],[\"user_type\",\"User\"],[\"first_name\",\"User\"],[\"last_name\",\"User\"],[\"last_active\",\"User\"],[\"role\",\"Has Role\"]],\"sort_order\":\"desc\",\"sort_by_next\":null,\"sort_order_next\":\"desc\"}",
"modified": "2018-12-17 18:27:07.728890",
"module": "Core",
"name": "User Activity Report Without Sort",
"query": null,
"ref_doctype": "User",
"report_name": "User Activity Report Without Sort",
"report_type": "Report Builder"
}

View file

@ -266,3 +266,10 @@ class TestUser(unittest.TestCase):
self.assertEqual(extract_mentions(user_name)[0], "test-user")
user_name = "Testing comment, @test.user@example.com please check."
self.assertEqual(extract_mentions(user_name)[0], "test.user@example.com")
user_name = "<div>@test_user@example.com and @test.again@example1.com</div><div>This is a test.</div>"
self.assertEqual(extract_mentions(user_name)[0], "test_user@example.com")
self.assertEqual(extract_mentions(user_name)[1], "test.again@example1.com")
user_name = "<div>@user@example.com</a> Test @test-comment@xyz.com</div><div>Test for comment mentions @test@abc.com</div>"
self.assertEqual(extract_mentions(user_name)[0], "user@example.com")
self.assertEqual(extract_mentions(user_name)[1], "test-comment@xyz.com")
self.assertEqual(extract_mentions(user_name)[2], "test@abc.com")

View file

@ -901,7 +901,7 @@ def notify_admin_access_to_system_manager(login_manager=None):
def extract_mentions(txt):
"""Find all instances of @name in the string.
The mentions will be separated by non-word characters or may appear at the start of the string"""
txt = txt.replace("<br>", "<br> ")
txt = txt.replace("<div>", "<div> ")
txt = re.sub(r'(<[a-zA-Z\/][^>]*>)', '', txt)
return re.findall(r'(?:[^\w\.\-\@]|^)@([\w\.\-\@]*)', txt)

View file

@ -8,7 +8,7 @@
"space": 0.157,
"expiry": "2016-07-25",
"users": 1
}
},
"developer_mode": 1,
"auto_cache_clear": true,

View file

@ -12,7 +12,7 @@ from frappe.utils import now, global_date_format, format_time
from frappe.utils.xlsxutils import make_xlsx
from frappe.utils.csvutils import to_csv
max_reports_per_user = 3
max_reports_per_user = frappe.local.conf.max_reports_per_user or 3
class AutoEmailReport(Document):
def autoname(self):