Unverified Commit 7a4787bb authored by Ameya Shenoy's avatar Ameya Shenoy
Browse files

Merge branch 'hotfix'

parents 67fcbaa0 9a32f55f
Showing with 57 additions and 12 deletions
+57 -12
......@@ -33,6 +33,7 @@ before_script:
- bench use test_site
- bench reinstall --yes
- bench setup-help
- bench setup-global-help --mariadb_root_password travis
- bench scheduler disable
- sed -i 's/9000/9001/g' sites/common_site_config.json
- bench start &
......
......@@ -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.32'
__version__ = '10.1.33'
__title__ = "Frappe Framework"
local = Local()
......
......@@ -5,8 +5,11 @@ frappe.ui.form.on("Address", {
refresh: function(frm) {
if(frm.doc.__islocal) {
var last_route = frappe.route_history.slice(-2, -1)[0];
let docname = last_route[2];
if (last_route.length > 3)
docname = last_route.slice(2).join("/");
if(frappe.dynamic_link && frappe.dynamic_link.doc
&& frappe.dynamic_link.doc.name==last_route[2]) {
&& frappe.dynamic_link.doc.name==docname) {
frm.add_child('links', {
link_doctype: frappe.dynamic_link.doctype,
link_name: frappe.dynamic_link.doc[frappe.dynamic_link.fieldname]
......
......@@ -7,8 +7,11 @@ frappe.ui.form.on("Contact", {
refresh: function(frm) {
if(frm.doc.__islocal) {
var last_route = frappe.route_history.slice(-2, -1)[0];
let docname = last_route[2];
if (last_route.length > 3)
docname = last_route.slice(2).join("/");
if(frappe.dynamic_link && frappe.dynamic_link.doc
&& frappe.dynamic_link.doc.name==last_route[2]) {
&& frappe.dynamic_link.doc.name==docname) {
frm.add_child('links', {
link_doctype: frappe.dynamic_link.doctype,
link_name: frappe.dynamic_link.doc[frappe.dynamic_link.fieldname]
......
......@@ -51,6 +51,18 @@ class Communication(Document):
frappe.throw(_("Cannot create a {0} against a child document: {1}")
.format(_(self.communication_type), _(self.reference_doctype)))
# Prevent circular linking of Communication DocTypes
if self.reference_doctype == "Communication":
circular_linking = False
doc = get_parent_doc(self)
while doc.reference_doctype == "Communication":
if get_parent_doc(doc).name==self.name:
circular_linking = True
break
doc = get_parent_doc(doc)
if circular_linking:
frappe.throw(_("Please make sure the Reference Communication Docs are not circularly linked."), frappe.CircularLinkingError)
if not self.user:
self.user = frappe.session.user
......@@ -293,4 +305,4 @@ def get_permission_query_conditions_for_communication(user):
email_accounts = [ '"%s"'%account.get("email_account") for account in accounts ]
return """tabCommunication.email_account in ({email_accounts})"""\
.format(email_accounts=','.join(email_accounts))
\ No newline at end of file
.format(email_accounts=','.join(email_accounts))
......@@ -43,3 +43,29 @@ class TestCommunication(unittest.TestCase):
for x in invalid_email_list:
self.assertFalse(frappe.utils.parse_addr(x)[0])
def test_circular_linking(self):
content = "This was created to test circular linking"
a = frappe.get_doc({
"doctype": "Communication",
"communication_type": "Communication",
"content": content,
}).insert()
b = frappe.get_doc({
"doctype": "Communication",
"communication_type": "Communication",
"content": content,
"reference_doctype": "Communication",
"reference_name": a.name
}).insert()
c = frappe.get_doc({
"doctype": "Communication",
"communication_type": "Communication",
"content": content,
"reference_doctype": "Communication",
"reference_name": b.name
}).insert()
a = frappe.get_doc("Communication", a.name)
a.reference_doctype = "Communication"
a.reference_name = c.name
self.assertRaises(frappe.CircularLinkingError, a.save)
......@@ -82,3 +82,5 @@ class IncorrectSitePath(NotFound): pass
class ImplicitCommitError(ValidationError): pass
class RetryBackgroundJobError(Exception): pass
class DocumentLockedError(ValidationError): pass
class CircularLinkingError(ValidationError): pass
......@@ -203,9 +203,6 @@ th {
a:visited {
text-decoration: underline;
}
a[href]:after {
content: " (" attr(href) ")";
}
abbr[title]:after {
content: " (" attr(title) ")";
}
......
......@@ -156,11 +156,12 @@ def get_allowed_functions_for_jenv():
"escape": frappe.db.escape,
}
# load jenv methods from hooks.py
for app in frappe.get_installed_apps():
for jenv_method in frappe.get_hooks(app_name=app).get('jenv', {"methods": []})["methods"]:
method_name, method_definition = jenv_method.split(":")
out[method_name] = frappe.get_attr(method_definition)
if getattr(frappe.local, "site", None):
# load jenv methods from hooks.py
for app in frappe.get_installed_apps():
for jenv_method in frappe.get_hooks(app_name=app).get('jenv', {"methods": []})["methods"]:
method_name, method_definition = jenv_method.split(":")
out[method_name] = frappe.get_attr(method_definition)
return out
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment