Merge branch 'hotfix'

This commit is contained in:
Frappe Bot 2019-03-08 09:00:40 +00:00
commit 37fa2dc7f6
26 changed files with 2935 additions and 2527 deletions

View file

@ -5,7 +5,7 @@
"es6": true
},
"parserOptions": {
"ecmaVersion": 6,
"ecmaVersion": 8,
"sourceType": "module"
},
"extends": "eslint:recommended",

View file

@ -24,7 +24,7 @@ if sys.version[0] == '2':
reload(sys)
sys.setdefaultencoding("utf-8")
__version__ = '11.1.13'
__version__ = '11.1.14'
__title__ = "Frappe Framework"
local = Local()

View file

@ -48,29 +48,31 @@ def authenticate(user):
@frappe.whitelist()
def get(user, fields = None):
duser = frappe.get_doc('User', user)
dprof = frappe.get_doc('Chat Profile', user)
# If you're adding something here, make sure the client recieves it.
profile = dict(
# User
name = duser.name,
email = duser.email,
first_name = duser.first_name,
last_name = duser.last_name,
username = duser.username,
avatar = duser.user_image,
bio = duser.bio,
# Chat Profile
status = dprof.status,
chat_background = dprof.chat_background,
message_preview = bool(dprof.message_preview),
notification_tones = bool(dprof.notification_tones),
conversation_tones = bool(dprof.conversation_tones),
enable_chat = bool(dprof.enable_chat)
)
profile = filter_dict(profile, fields)
if frappe.db.exists('Chat Profile', user):
dprof = frappe.get_doc('Chat Profile', user)
return dictify(profile)
# If you're adding something here, make sure the client recieves it.
profile = dict(
# User
name = duser.name,
email = duser.email,
first_name = duser.first_name,
last_name = duser.last_name,
username = duser.username,
avatar = duser.user_image,
bio = duser.bio,
# Chat Profile
status = dprof.status,
chat_background = dprof.chat_background,
message_preview = bool(dprof.message_preview),
notification_tones = bool(dprof.notification_tones),
conversation_tones = bool(dprof.conversation_tones),
enable_chat = bool(dprof.enable_chat)
)
profile = filter_dict(profile, fields)
return dictify(profile)
@frappe.whitelist()
def create(user, exists_ok = False, fields = None):

View file

@ -1,5 +1,6 @@
{
"allow_copy": 0,
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
@ -15,6 +16,7 @@
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -40,10 +42,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 1,
"collapsible": 0,
@ -72,11 +76,13 @@
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"unique": 0,
"width": "163"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 1,
"collapsible": 0,
@ -106,10 +112,12 @@
"reqd": 1,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 1,
"collapsible": 0,
@ -137,10 +145,12 @@
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -169,11 +179,13 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0,
"width": "50px"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -202,10 +214,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -233,10 +247,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -265,11 +281,13 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0,
"width": "50px"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -296,11 +314,13 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0,
"width": "70px"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -327,10 +347,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -352,7 +374,6 @@
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"allow_in_quick_entry": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
@ -364,6 +385,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -384,7 +406,6 @@
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"allow_in_quick_entry": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
@ -396,6 +417,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -416,7 +438,6 @@
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"allow_in_quick_entry": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
@ -428,6 +449,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -450,7 +472,6 @@
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"allow_in_quick_entry": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
@ -462,6 +483,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -489,10 +511,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -520,10 +544,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -548,10 +574,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -580,10 +608,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -611,42 +641,77 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "fetch_from",
"fieldtype": "Small Text",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Fetch From",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "fetch_from",
"fieldtype": "Small Text",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Fetch From",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"description": "If checked, this field will be not overwritten based on Fetch From if a value already exists.",
"fieldname": "fetch_if_empty",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Fetch If Empty",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -666,7 +731,6 @@
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"allow_in_quick_entry": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
@ -678,6 +742,7 @@
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -705,10 +770,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -737,11 +804,13 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0,
"width": "50px"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -768,11 +837,13 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0,
"width": "50px"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -799,10 +870,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -829,10 +902,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -860,10 +935,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -888,10 +965,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -921,11 +1000,13 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0,
"width": "50px"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -952,10 +1033,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -985,11 +1068,13 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0,
"width": "50px"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1018,11 +1103,13 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0,
"width": "50px"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1050,10 +1137,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1081,10 +1170,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1110,10 +1201,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1142,11 +1235,13 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0,
"width": "50px"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1175,11 +1270,13 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0,
"width": "50px"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1208,11 +1305,13 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0,
"width": "50px"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1240,10 +1339,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1269,10 +1370,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1301,11 +1404,13 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0,
"width": "50px"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1334,10 +1439,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1362,10 +1469,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1394,11 +1503,13 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0,
"width": "300px"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1425,10 +1536,12 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@ -1455,6 +1568,7 @@
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}
],
@ -1468,7 +1582,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2018-10-10 15:09:39.059467",
"modified": "2019-02-26 21:49:13.665322",
"modified_by": "Administrator",
"module": "Core",
"name": "DocField",
@ -1480,5 +1594,6 @@
"show_name_in_global_search": 0,
"sort_order": "ASC",
"track_changes": 0,
"track_seen": 0
}
"track_seen": 0,
"track_views": 0
}

View file

@ -66,7 +66,9 @@ class RolePermissionforPageandReport(Document):
def update_disable_prepared_report(self):
if self.report:
frappe.db.set_value('Report', self.report, 'disable_prepared_report', self.disable_prepared_report)
# intentionally written update query in frappe.db.sql instead of frappe.db.set_value
frappe.db.sql(""" update `tabReport` set disable_prepared_report = %s
where name = %s""", (self.disable_prepared_report, self.report))
def get_args(self, row=None):
name = self.page if self.set_role_for == 'Page' else self.report
@ -75,7 +77,7 @@ class RolePermissionforPageandReport(Document):
return {
check_for_field: name
}
def get_roles(self):
roles = []
for data in self.roles:

View file

@ -1047,7 +1047,7 @@ def update_roles(role_profile):
user.set('roles', [])
user.add_roles(*roles)
def create_contact(user, ignore_links=False):
def create_contact(user, ignore_links=False, ignore_mandatory=False):
if user.name in ["Administrator", "Guest"]: return
if not frappe.db.get_value("Contact", {"email_id": user.email}):
@ -1060,7 +1060,7 @@ def create_contact(user, ignore_links=False):
"gender": user.gender,
"phone": user.phone,
"mobile_no": user.mobile_no
}).insert(ignore_permissions=True, ignore_links=ignore_links)
}).insert(ignore_permissions=True, ignore_links=ignore_links, ignore_mandatory=ignore_mandatory)
@frappe.whitelist()

File diff suppressed because it is too large Load diff

View file

@ -38,6 +38,7 @@ docfield_properties = {
'fieldtype': 'Select',
'options': 'Text',
'fetch_from': 'Small Text',
'fetch_if_empty': 'Check',
'permlevel': 'Int',
'width': 'Data',
'print_width': 'Data',
@ -189,7 +190,7 @@ class CustomizeForm(Document):
continue
elif property == "reqd" and \
((frappe.db.get_value("DocField",
((frappe.db.get_value("DocField",
{"parent":self.doc_type,"fieldname":df.fieldname}, "reqd") == 1) \
and (df.get(property) == 0)):
frappe.msgprint(_("Row {0}: Not allowed to disable Mandatory for standard fields")\

View file

@ -46,3 +46,31 @@ class TestToDo(unittest.TestCase):
self.assertEqual(todo.assigned_by_full_name,
frappe.db.get_value('User', todo.assigned_by, 'full_name'))
def test_fetch_if_empty(self):
frappe.db.sql('delete from tabToDo')
# Allow user changes
todo_meta = frappe.get_doc('DocType', 'ToDo')
field = todo_meta.get('fields', dict(fieldname='assigned_by_full_name'))[0]
field.fetch_from = 'assigned_by.full_name'
field.fetch_if_empty = 1
todo_meta.save()
frappe.clear_cache(doctype='ToDo')
todo = frappe.get_doc(dict(doctype='ToDo', description='test todo',
assigned_by='Administrator', assigned_by_full_name='Admin')).insert()
self.assertEqual(todo.assigned_by_full_name, 'Admin')
# Overwrite user changes
todo_meta = frappe.get_doc('DocType', 'ToDo')
todo_meta.get('fields', dict(fieldname='assigned_by_full_name'))[0].fetch_if_empty = 0
todo_meta.save()
todo.reload()
todo.save()
self.assertEqual(todo.assigned_by_full_name,
frappe.db.get_value('User', todo.assigned_by, 'full_name'))

View file

@ -451,9 +451,12 @@ class BaseDocument(object):
# that are mapped as link_fieldname.source_fieldname in Options of
# Readonly or Data or Text type fields
# NOTE: All fields will be replaced, if you want manual changes to stay
# use `frm.add_fetch`
fields_to_fetch = self.meta.get_fields_to_fetch(df.fieldname)
fields_to_fetch = [
_df for _df in self.meta.get_fields_to_fetch(df.fieldname)
if
not _df.get('fetch_if_empty')
or (_df.get('fetch_if_empty') and not self.get(_df.fieldname))
]
if not fields_to_fetch:
# cache a single value type

View file

@ -172,6 +172,9 @@ class DatabaseQuery(object):
except ValueError:
self.fields = [f.strip() for f in self.fields.split(",")]
# remove empty strings / nulls in fields
self.fields = [f for f in self.fields if f]
for filter_name in ["filters", "or_filters"]:
filters = getattr(self, filter_name)
if isinstance(filters, string_types):

View file

@ -1216,7 +1216,7 @@ class Document(BaseDocument):
if file_lock.lock_exists(self.get_signature()):
frappe.throw(_('This document is currently queued for execution. Please try again'),
title=_('Document Queued'), indicator='red')
title=_('Document Queued'))
self.lock()
enqueue('frappe.model.document.execute_action', doctype=self.doctype, name=self.name,

View file

@ -233,7 +233,7 @@ class Meta(Document):
are to be fetched and updated for a particular link field
These fields are of type Data, Link, Text, Readonly and their
options property is set as `link_fieldname`.`source_fieldname`'''
fetch_from property is set as `link_fieldname`.`source_fieldname`'''
out = []

View file

@ -13,4 +13,4 @@ def execute():
user.first_name = re.sub("[<>]+", '', frappe.safe_decode(user.first_name))
if user.last_name:
user.last_name = re.sub("[<>]+", '', frappe.safe_decode(user.last_name))
create_contact(user, ignore_links=True)
create_contact(user, ignore_links=True, ignore_mandatory=True)

View file

@ -20,6 +20,25 @@ Table.create = (value) => {
}
Quill.register(Table, true);
// link without href
var Link = Quill.import('formats/link');
class MyLink extends Link {
static create(value) {
let node = super.create(value);
value = this.sanitize(value);
node.setAttribute('href', value);
if(value.startsWith('/') || value.indexOf(window.location.host)) {
// no href if internal link
node.removeAttribute('target');
}
return node;
}
}
Quill.register(MyLink);
// hidden blot
class HiddenBlock extends Block {
static create(value) {
@ -44,13 +63,11 @@ Uploader.DEFAULTS.mimetypes.push('image/gif');
// inline style
const BackgroundStyle = Quill.import('attributors/style/background');
const ColorStyle = Quill.import('attributors/style/color');
const SizeStyle = Quill.import('attributors/style/size');
const FontStyle = Quill.import('attributors/style/font');
const AlignStyle = Quill.import('attributors/style/align');
const DirectionStyle = Quill.import('attributors/style/direction');
Quill.register(BackgroundStyle, true);
Quill.register(ColorStyle, true);
Quill.register(SizeStyle, true);
Quill.register(FontStyle, true);
Quill.register(AlignStyle, true);
Quill.register(DirectionStyle, true);
@ -140,6 +157,7 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({
return [
[{ 'header': [1, 2, 3, false] }],
['bold', 'italic', 'underline'],
[{ 'color': [] }, { 'background': [] }],
['blockquote', 'code-block'],
['link', 'image'],
[{ 'list': 'ordered' }, { 'list': 'bullet' }],

View file

@ -301,7 +301,7 @@ frappe.ui.form.Timeline = class Timeline {
}
prepare_timeline_item(c) {
if(!c.sender) c.sender = c.owner;
if(!c.sender) c.sender = c.owner || 'Guest';
if(c.sender && c.sender.indexOf("<")!==-1) {
c.sender = c.sender.split("<")[1].split(">")[0];

View file

@ -90,7 +90,7 @@ $.extend(frappe.model, {
for(var fid=0;fid<docfields.length;fid++) {
var f = docfields[fid];
if(!in_list(frappe.model.no_value_type, f.fieldtype) && doc[f.fieldname]==null) {
var v = frappe.model.get_default_value(f, doc, parent_doc);
var v = !f.depends_on || doc[f.depends_on] ? frappe.model.get_default_value(f, doc, parent_doc) : null;
if(v) {
if(in_list(["Int", "Check"], f.fieldtype))
v = cint(v);

View file

@ -77,13 +77,9 @@ frappe.ui.Tags = class {
}
removeTag(label) {
label = frappe.utils.xss_sanitise(label);
if(this.tagsList.includes(label)) {
let $tag = this.$ul.find(`.frappe-tag[data-tag-label="${label}"]`);
// Just don't remove tag, but also the li DOM.
$tag.parent('.tags-list-item').remove();
this.tagsList.splice(this.tagsList.indexOf(label), 1);
this.onTagRemove && this.onTagRemove(label);
}
}
@ -119,6 +115,7 @@ frappe.ui.Tags = class {
$removeTag.on("click", () => {
this.removeTag($removeTag.attr('data-tag-label'));
$removeTag.closest('.tags-list-item').remove();
});
if(this.onTagClick) {

View file

@ -52,10 +52,7 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
this.secondary_action = {
label: __('Refresh'),
action: () => {
if(this.execution_time > 2) {
this.setup_progress_bar();
}
this.setup_progress_bar();
this.refresh();
}
};
@ -171,8 +168,9 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
setup_progress_bar() {
let seconds_elapsed = 0;
const execution_time = this.report_settings.execution_time < 10
? 10 : this.report_settings.execution_time;
const execution_time = this.report_settings.execution_time || 0;
if (execution_time < 5) return;
this.interval = setInterval(function() {
seconds_elapsed += 1;

View file

@ -9,6 +9,9 @@
}
.ql-editor {
font-family: @font-stack;
line-height: 1.6;
h1, h2, h3, h4, h5 {
margin-top: 0.5em;
margin-bottom: 0.25em;

View file

@ -429,7 +429,7 @@ def get_random_filename(extn=None, content_type=None):
return random_string(7) + (extn or "")
@frappe.whitelist()
@frappe.whitelist(allow_guest=True)
def validate_filename(filename):
from frappe.utils import now_datetime
timestamp = now_datetime().strftime(" %Y-%m-%d %H:%M:%S")
@ -450,4 +450,4 @@ def add_attachments(doctype, name, attachments):
f = save_url(attach.file_url, attach.file_name, doctype, name, "Home/Attachments", attach.is_private)
files.append(f)
return files
return files

View file

@ -61,10 +61,17 @@ def handle_html(data):
obj = HTML2Text()
obj.ignore_links = True
obj.body_width = 0
value = obj.handle(h)
try:
value = obj.handle(h)
except Exception:
# unable to parse html, send it raw
return value
value = ", ".join(value.split(' \n'))
value = " ".join(value.split('\n'))
value = ", ".join(value.split('# '))
return value
def read_xlsx_file_from_attached_file(file_id=None, fcontent=None, filepath=None):

View file

@ -151,7 +151,7 @@
<!-- save/next button -->
{% if (loop.index == layout|len or frappe.form_dict.new) %}
{% if not read_only %}
<button type="submit" class="btn btn-primary btn-sm btn-form-submit">
<button type="submit" class="btn btn-primary btn-sm btn-form-submit footer-button">
{{ _("Save") }}</button>
{% endif %}
{% elif layout|len > 1 %}

View file

@ -36,6 +36,11 @@ frappe.ready(function() {
setTimeout(() => {
$('body').css('display', 'block');
// remove footer save button if form height is less than window height
if($('.webform-wrapper').height() < window.innerHeight) {
$(".footer-button").addClass("hide");
}
if (frappe.init_client_script) {
frappe.init_client_script();

View file

@ -13,35 +13,34 @@ $.extend(frappe, {
lang: 'en'
},
_assets_loaded: [],
require: function(url, callback) {
let async = false;
if (callback) {
async = true;
require: async function(links, callback) {
if (typeof (links) === 'string') {
links = [links];
}
if(frappe._assets_loaded.indexOf(url)!==-1) {
callback && callback();
return;
for (let link of links) {
await this.add_asset_to_head(link);
}
return $.ajax({
url: url,
async: async,
dataType: "text",
success: function(data) {
var el;
if(url.split(".").splice(-1) == "js") {
el = document.createElement('script');
} else {
el = document.createElement('style');
}
el.appendChild(document.createTextNode(data));
document.getElementsByTagName('head')[0].appendChild(el);
frappe._assets_loaded.push(url);
callback && callback();
callback && callback();
},
add_asset_to_head(link) {
return new Promise(resolve => {
if (frappe._assets_loaded.includes(link)) return resolve();
let el;
if(link.split('.').pop() === 'js') {
el = document.createElement('script');
el.type = 'text/javascript';
el.src = link;
} else {
el = document.createElement('link');
el.type = 'text/css';
el.rel = 'stylesheet';
el.href = link;
}
document.getElementsByTagName('head')[0].appendChild(el);
el.onload = () => {
frappe._assets_loaded.push(link);
resolve();
};
});
},
hide_message: function() {