diff --git a/frappe/__init__.py b/frappe/__init__.py index 88ced27699..8199ba7a1c 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -243,7 +243,7 @@ def msgprint(msg, small=0, raise_exception=0, as_table=False): if as_table and type(msg) in (list, tuple): msg = '' + ''.join([''+''.join(['' % c for c in r])+'' for r in msg]) + '
%s
' - if flags.print_messages: + if flags.print_messages or not request or (not "cmd" in local.form_dict): print "Message: " + repr(msg).encode("utf-8") message_log.append((small and '__small:' or '')+cstr(msg or '')) diff --git a/frappe/core/doctype/async_task/async_task.json b/frappe/core/doctype/async_task/async_task.json index 330596ccd2..ed99be8fe8 100644 --- a/frappe/core/doctype/async_task/async_task.json +++ b/frappe/core/doctype/async_task/async_task.json @@ -20,6 +20,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Status", + "length": 20, "no_copy": 0, "options": "\nQueued\nRunning\nSucceeded\nFailed\n", "permlevel": 0, @@ -195,7 +196,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-09-07 08:08:22.193911", + "modified": "2015-10-02 07:38:38.658939", "modified_by": "Administrator", "module": "Core", "name": "Async Task", diff --git a/frappe/core/doctype/block_module/block_module.json b/frappe/core/doctype/block_module/block_module.json index af1648a2b5..3473e6fe88 100644 --- a/frappe/core/doctype/block_module/block_module.json +++ b/frappe/core/doctype/block_module/block_module.json @@ -39,7 +39,7 @@ "is_submittable": 0, "issingle": 0, "istable": 1, - "modified": "2015-03-24 16:03:52.359042", + "modified": "2015-10-02 07:38:39.485971", "modified_by": "Administrator", "module": "Core", "name": "Block Module", diff --git a/frappe/core/doctype/comment/comment.json b/frappe/core/doctype/comment/comment.json index d928532acd..f03c3cec89 100644 --- a/frappe/core/doctype/comment/comment.json +++ b/frappe/core/doctype/comment/comment.json @@ -292,7 +292,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-06-08 12:31:15.122312", + "modified": "2015-10-02 07:38:41.308408", "modified_by": "Administrator", "module": "Core", "name": "Comment", diff --git a/frappe/core/doctype/communication/communication.json b/frappe/core/doctype/communication/communication.json index 77ddb28d51..f2ab2d06b7 100644 --- a/frappe/core/doctype/communication/communication.json +++ b/frappe/core/doctype/communication/communication.json @@ -22,6 +22,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Series", + "length": 20, "no_copy": 0, "options": "COMM-", "permlevel": 0, @@ -45,6 +46,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Communication Medium", + "length": 20, "no_copy": 0, "options": "\nChat\nPhone\nEmail\nSMS\nVisit\nOther", "permlevel": 0, @@ -154,6 +156,7 @@ "in_filter": 0, "in_list_view": 1, "label": "Status", + "length": 20, "no_copy": 0, "options": "Open\nReplied\nClosed\nLinked", "permlevel": 0, @@ -177,6 +180,7 @@ "in_filter": 0, "in_list_view": 1, "label": "Sent or Received", + "length": 20, "no_copy": 0, "options": "Sent\nReceived", "permlevel": 0, @@ -200,6 +204,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Delivery Status", + "length": 30, "no_copy": 0, "options": "\nSent\nBounced\nOpened\nMarked As Spam\nRejected\nDelayed\nSoft-Bounced\nClicked\nRecipient Unsubscribed", "permlevel": 0, @@ -573,7 +578,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-09-24 02:27:43.536919", + "modified": "2015-10-02 07:38:41.472917", "modified_by": "Administrator", "module": "Core", "name": "Communication", diff --git a/frappe/core/doctype/defaultvalue/defaultvalue.json b/frappe/core/doctype/defaultvalue/defaultvalue.json index e6c4c66998..5bf6b116d0 100644 --- a/frappe/core/doctype/defaultvalue/defaultvalue.json +++ b/frappe/core/doctype/defaultvalue/defaultvalue.json @@ -67,7 +67,7 @@ "is_submittable": 0, "issingle": 0, "istable": 1, - "modified": "2015-02-19 01:06:59.622792", + "modified": "2015-10-02 07:38:44.346115", "modified_by": "Administrator", "module": "Core", "name": "DefaultValue", diff --git a/frappe/core/doctype/docfield/docfield.json b/frappe/core/doctype/docfield/docfield.json index c88952f5f0..c44ef416e5 100644 --- a/frappe/core/doctype/docfield/docfield.json +++ b/frappe/core/doctype/docfield/docfield.json @@ -66,6 +66,7 @@ "in_filter": 0, "in_list_view": 1, "label": "Type", + "length": 20, "no_copy": 0, "oldfieldname": "fieldtype", "oldfieldtype": "Select", @@ -140,6 +141,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Precision", + "length": 20, "no_copy": 0, "options": "\n1\n2\n3\n4\n5\n6\n7\n8\n9", "permlevel": 0, @@ -151,6 +153,29 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "depends_on": "eval:in_list(['Data', 'Link', 'Dynamic Link', 'Password', 'Select', 'Read Only', 'Attach', 'Attach Image'], doc.fieldtype)", + "fieldname": "length", + "fieldtype": "Int", + "hidden": 0, + "ignore_user_permissions": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Length", + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_on_submit": 0, "bold": 0, @@ -256,6 +281,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Collapsible Depends On", + "length": 255, "no_copy": 0, "permlevel": 0, "precision": "", @@ -366,6 +392,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Depends On", + "length": 255, "no_copy": 0, "oldfieldname": "depends_on", "oldfieldtype": "Data", @@ -828,7 +855,7 @@ "is_submittable": 0, "issingle": 0, "istable": 1, - "modified": "2015-08-20 16:05:15.274200", + "modified": "2015-10-02 07:38:45.729926", "modified_by": "Administrator", "module": "Core", "name": "DocField", diff --git a/frappe/core/doctype/docperm/docperm.json b/frappe/core/doctype/docperm/docperm.json index d21abfaaa8..dbb9e4d53c 100644 --- a/frappe/core/doctype/docperm/docperm.json +++ b/frappe/core/doctype/docperm/docperm.json @@ -591,7 +591,7 @@ "is_submittable": 0, "issingle": 0, "istable": 1, - "modified": "2015-07-22 07:39:40.471092", + "modified": "2015-10-02 07:38:46.740536", "modified_by": "Administrator", "module": "Core", "name": "DocPerm", diff --git a/frappe/core/doctype/docshare/docshare.json b/frappe/core/doctype/docshare/docshare.json index 3a7846cce1..f06857213d 100644 --- a/frappe/core/doctype/docshare/docshare.json +++ b/frappe/core/doctype/docshare/docshare.json @@ -178,7 +178,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-07-17 07:02:10.632582", + "modified": "2015-10-02 07:38:47.029636", "modified_by": "Administrator", "module": "Core", "name": "DocShare", diff --git a/frappe/core/doctype/doctype/doctype.json b/frappe/core/doctype/doctype/doctype.json index 620e4234d6..b9f78769df 100644 --- a/frappe/core/doctype/doctype/doctype.json +++ b/frappe/core/doctype/doctype/doctype.json @@ -135,6 +135,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Document Type", + "length": 20, "no_copy": 0, "oldfieldname": "document_type", "oldfieldtype": "Select", @@ -313,6 +314,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Name Case", + "length": 20, "no_copy": 0, "oldfieldname": "name_case", "oldfieldtype": "Select", @@ -449,6 +451,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Sort Order", + "length": 20, "no_copy": 0, "options": "ASC\nDESC", "permlevel": 0, @@ -851,7 +854,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-07-28 16:18:11.925264", + "modified": "2015-10-02 07:38:47.199387", "modified_by": "Administrator", "module": "Core", "name": "DocType", diff --git a/frappe/core/doctype/doctype/test_doctype.py b/frappe/core/doctype/doctype/test_doctype.py new file mode 100644 index 0000000000..2419f0c7d1 --- /dev/null +++ b/frappe/core/doctype/doctype/test_doctype.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt +from __future__ import unicode_literals + +import frappe +import unittest + +# test_records = frappe.get_test_records('DocType') + +class TestDocType(unittest.TestCase): + pass diff --git a/frappe/core/doctype/file/file.json b/frappe/core/doctype/file/file.json index 69ae60e181..d773e524c0 100644 --- a/frappe/core/doctype/file/file.json +++ b/frappe/core/doctype/file/file.json @@ -455,7 +455,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-10-07 05:52:52.922698", + "modified": "2015-10-08 05:52:52.922698", "modified_by": "Administrator", "module": "Core", "name": "File", diff --git a/frappe/core/doctype/module_def/module_def.json b/frappe/core/doctype/module_def/module_def.json index 464b966280..a74ccc1241 100644 --- a/frappe/core/doctype/module_def/module_def.json +++ b/frappe/core/doctype/module_def/module_def.json @@ -62,7 +62,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-02-05 05:11:41.388856", + "modified": "2015-10-02 07:38:57.452736", "modified_by": "Administrator", "module": "Core", "name": "Module Def", diff --git a/frappe/core/doctype/module_def/test_module_def.py b/frappe/core/doctype/module_def/test_module_def.py new file mode 100644 index 0000000000..1f9bea4768 --- /dev/null +++ b/frappe/core/doctype/module_def/test_module_def.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt +from __future__ import unicode_literals + +import frappe +import unittest + +# test_records = frappe.get_test_records('Module Def') + +class TestModuleDef(unittest.TestCase): + pass diff --git a/frappe/core/doctype/page/page.json b/frappe/core/doctype/page/page.json index 67aa6e62a4..374976d68c 100644 --- a/frappe/core/doctype/page/page.json +++ b/frappe/core/doctype/page/page.json @@ -150,6 +150,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Standard", + "length": 20, "no_copy": 0, "oldfieldname": "standard", "oldfieldtype": "Select", @@ -217,7 +218,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-09-11 12:19:55.121822", + "modified": "2015-10-02 07:38:59.403028", "modified_by": "Administrator", "module": "Core", "name": "Page", diff --git a/frappe/core/doctype/page_role/page_role.json b/frappe/core/doctype/page_role/page_role.json index 3e9375deb5..270d0ae2f5 100644 --- a/frappe/core/doctype/page_role/page_role.json +++ b/frappe/core/doctype/page_role/page_role.json @@ -41,7 +41,7 @@ "is_submittable": 0, "issingle": 0, "istable": 1, - "modified": "2015-02-19 01:07:00.897854", + "modified": "2015-10-02 07:38:59.530013", "modified_by": "Administrator", "module": "Core", "name": "Page Role", diff --git a/frappe/core/doctype/patch_log/patch_log.json b/frappe/core/doctype/patch_log/patch_log.json index af0cff107f..9ae4e9f40e 100644 --- a/frappe/core/doctype/patch_log/patch_log.json +++ b/frappe/core/doctype/patch_log/patch_log.json @@ -15,7 +15,7 @@ "bold": 0, "collapsible": 0, "fieldname": "patch", - "fieldtype": "Data", + "fieldtype": "Small Text", "hidden": 0, "ignore_user_permissions": 0, "in_filter": 0, @@ -41,7 +41,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2013-12-20 19:24:15", + "modified": "2015-10-02 07:38:59.666628", "modified_by": "Administrator", "module": "Core", "name": "Patch Log", diff --git a/frappe/core/doctype/patch_log/test_patch_log.py b/frappe/core/doctype/patch_log/test_patch_log.py new file mode 100644 index 0000000000..0a7f22a78b --- /dev/null +++ b/frappe/core/doctype/patch_log/test_patch_log.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt +from __future__ import unicode_literals + +import frappe +import unittest + +# test_records = frappe.get_test_records('Patch Log') + +class TestPatchLog(unittest.TestCase): + pass diff --git a/frappe/core/doctype/report/report.json b/frappe/core/doctype/report/report.json index 562cdba6e4..5791fb6c4d 100644 --- a/frappe/core/doctype/report/report.json +++ b/frappe/core/doctype/report/report.json @@ -63,6 +63,7 @@ "in_filter": 0, "in_list_view": 1, "label": "Is Standard", + "length": 20, "no_copy": 0, "options": "No\nYes", "permlevel": 0, @@ -148,6 +149,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Report Type", + "length": 20, "no_copy": 0, "options": "Report Builder\nQuery Report\nScript Report", "permlevel": 0, @@ -300,7 +302,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-09-07 15:51:26", + "modified": "2015-10-02 07:39:07.933259", "modified_by": "Administrator", "module": "Core", "name": "Report", diff --git a/frappe/core/doctype/role/role.json b/frappe/core/doctype/role/role.json index fb4b299077..bc14d18aa1 100644 --- a/frappe/core/doctype/role/role.json +++ b/frappe/core/doctype/role/role.json @@ -41,7 +41,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-09-07 15:51:26", + "modified": "2015-10-02 07:39:08.074305", "modified_by": "Administrator", "module": "Core", "name": "Role", diff --git a/frappe/core/doctype/scheduler_log/scheduler_log.json b/frappe/core/doctype/scheduler_log/scheduler_log.json index 3056d93b9e..86a900ba37 100644 --- a/frappe/core/doctype/scheduler_log/scheduler_log.json +++ b/frappe/core/doctype/scheduler_log/scheduler_log.json @@ -85,7 +85,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-05-28 02:49:12.819934", + "modified": "2015-10-02 07:39:12.348067", "modified_by": "Administrator", "module": "Core", "name": "Scheduler Log", diff --git a/frappe/core/doctype/user/user.json b/frappe/core/doctype/user/user.json index 1e631b288b..d5e5d62504 100644 --- a/frappe/core/doctype/user/user.json +++ b/frappe/core/doctype/user/user.json @@ -575,6 +575,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Background Style", + "length": 20, "no_copy": 0, "options": "Fill Screen\nTile", "permlevel": 0, @@ -619,6 +620,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Gender", + "length": 20, "no_copy": 0, "oldfieldname": "gender", "oldfieldtype": "Select", @@ -934,6 +936,7 @@ "in_filter": 0, "in_list_view": 1, "label": "User Type", + "length": 20, "no_copy": 0, "oldfieldname": "user_type", "oldfieldtype": "Select", @@ -1263,7 +1266,7 @@ "issingle": 0, "istable": 0, "max_attachments": 5, - "modified": "2015-08-18 11:58:00.000691", + "modified": "2015-10-02 07:39:17.752070", "modified_by": "Administrator", "module": "Core", "name": "User", diff --git a/frappe/core/doctype/userrole/userrole.json b/frappe/core/doctype/userrole/userrole.json index f7d0442721..1bf512f135 100644 --- a/frappe/core/doctype/userrole/userrole.json +++ b/frappe/core/doctype/userrole/userrole.json @@ -43,7 +43,7 @@ "is_submittable": 0, "issingle": 0, "istable": 1, - "modified": "2015-02-19 01:07:02.561834", + "modified": "2015-10-02 07:39:18.179539", "modified_by": "Administrator", "module": "Core", "name": "UserRole", diff --git a/frappe/core/doctype/version/version.json b/frappe/core/doctype/version/version.json index d4df6c8d2c..608c4db77b 100644 --- a/frappe/core/doctype/version/version.json +++ b/frappe/core/doctype/version/version.json @@ -83,7 +83,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-07-28 16:18:12.706419", + "modified": "2015-10-02 07:39:18.235343", "modified_by": "Administrator", "module": "Core", "name": "Version", diff --git a/frappe/custom/doctype/custom_field/custom_field.json b/frappe/custom/doctype/custom_field/custom_field.json index 1e0ac687d1..a847d42844 100644 --- a/frappe/custom/doctype/custom_field/custom_field.json +++ b/frappe/custom/doctype/custom_field/custom_field.json @@ -113,6 +113,7 @@ "in_filter": 1, "in_list_view": 1, "label": "Field Type", + "length": 20, "no_copy": 0, "oldfieldname": "fieldtype", "oldfieldtype": "Select", @@ -139,6 +140,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Precision", + "length": 20, "no_copy": 0, "options": "\n1\n2\n3\n4\n5\n6\n7\n8\n9", "permlevel": 0, @@ -656,7 +658,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-02-25 03:39:23.573928", + "modified": "2015-10-02 07:38:43.093000", "modified_by": "Administrator", "module": "Custom", "name": "Custom Field", diff --git a/frappe/custom/doctype/custom_script/custom_script.json b/frappe/custom/doctype/custom_script/custom_script.json index 3b6b2438e7..5f61db3026 100644 --- a/frappe/custom/doctype/custom_script/custom_script.json +++ b/frappe/custom/doctype/custom_script/custom_script.json @@ -45,6 +45,7 @@ "in_filter": 0, "in_list_view": 1, "label": "Script Type", + "length": 20, "no_copy": 0, "oldfieldname": "script_type", "oldfieldtype": "Select", @@ -114,7 +115,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-08-27 06:36:20.439949", + "modified": "2015-10-02 07:38:43.345211", "modified_by": "Administrator", "module": "Custom", "name": "Custom Script", diff --git a/frappe/custom/doctype/custom_script/test_custom_script.py b/frappe/custom/doctype/custom_script/test_custom_script.py new file mode 100644 index 0000000000..6947e6060d --- /dev/null +++ b/frappe/custom/doctype/custom_script/test_custom_script.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt +from __future__ import unicode_literals + +import frappe +import unittest + +# test_records = frappe.get_test_records('Custom Script') + +class TestCustomScript(unittest.TestCase): + pass diff --git a/frappe/custom/doctype/customize_form/customize_form.json b/frappe/custom/doctype/customize_form/customize_form.json index ced2f73f64..7be6335a8f 100644 --- a/frappe/custom/doctype/customize_form/customize_form.json +++ b/frappe/custom/doctype/customize_form/customize_form.json @@ -235,6 +235,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Sort Order", + "length": 4, "no_copy": 0, "options": "ASC\nDESC", "permlevel": 0, @@ -301,7 +302,7 @@ "is_submittable": 0, "issingle": 1, "istable": 0, - "modified": "2015-07-27 01:00:32.901851", + "modified": "2015-10-02 07:17:18.939161", "modified_by": "Administrator", "module": "Custom", "name": "Customize Form", diff --git a/frappe/custom/doctype/customize_form/customize_form.py b/frappe/custom/doctype/customize_form/customize_form.py index 72e5c34bc6..4a2427cf68 100644 --- a/frappe/custom/doctype/customize_form/customize_form.py +++ b/frappe/custom/doctype/customize_form/customize_form.py @@ -47,7 +47,8 @@ class CustomizeForm(Document): 'description': 'Text', 'default': 'Text', 'precision': 'Select', - 'read_only': 'Check' + 'read_only': 'Check', + 'length': 'Int' } allowed_fieldtype_change = (('Currency', 'Float', 'Percent'), ('Small Text', 'Data'), diff --git a/frappe/custom/doctype/customize_form_field/customize_form_field.json b/frappe/custom/doctype/customize_form_field/customize_form_field.json index 60cd527a24..510217e181 100644 --- a/frappe/custom/doctype/customize_form_field/customize_form_field.json +++ b/frappe/custom/doctype/customize_form_field/customize_form_field.json @@ -65,10 +65,11 @@ "in_filter": 0, "in_list_view": 1, "label": "Type", + "length": 20, "no_copy": 0, "oldfieldname": "fieldtype", "oldfieldtype": "Select", - "options": "Attach\nButton\nCheck\nCode\nColumn Break\nCurrency\nData\nDate\nDatetime\nDynamic Link\nFloat\nFold\nHTML\nImage\nInt\nLink\nLong Text\nPassword\nPercent\nRead Only\nSection Break\nSelect\nSmall Text\nTable\nText\nText Editor\nTime", + "options": "Attach\nAttach Image\nButton\nCheck\nCode\nColumn Break\nCurrency\nData\nDate\nDatetime\nDynamic Link\nFloat\nFold\nHeading\nHTML\nImage\nInt\nLink\nLong Text\nPassword\nPercent\nRead Only\nSection Break\nSelect\nSmall Text\nTable\nText\nText Editor\nTime", "permlevel": 0, "print_hide": 0, "read_only": 0, @@ -203,6 +204,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Precision", + "length": 20, "no_copy": 0, "options": "\n1\n2\n3\n4\n5\n6\n7\n8\n9", "permlevel": 0, @@ -215,6 +217,29 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "depends_on": "eval:in_list(['Data', 'Link', 'Dynamic Link', 'Password', 'Select', 'Read Only', 'Attach', 'Attach Image'], doc.fieldtype)", + "fieldname": "length", + "fieldtype": "Int", + "hidden": 0, + "ignore_user_permissions": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Length", + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_on_submit": 0, "bold": 0, @@ -709,7 +734,7 @@ "is_submittable": 0, "issingle": 0, "istable": 1, - "modified": "2015-10-01 07:59:15.490247", + "modified": "2015-10-03 07:38:44.026280", "modified_by": "Administrator", "module": "Custom", "name": "Customize Form Field", diff --git a/frappe/custom/doctype/property_setter/property_setter.json b/frappe/custom/doctype/property_setter/property_setter.json index 6fa56076af..08ed0f2b31 100644 --- a/frappe/custom/doctype/property_setter/property_setter.json +++ b/frappe/custom/doctype/property_setter/property_setter.json @@ -62,6 +62,7 @@ "in_filter": 0, "in_list_view": 1, "label": "DocType or Field", + "length": 20, "no_copy": 0, "options": "\nDocField\nDocType", "permlevel": 0, @@ -233,7 +234,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-02-05 05:11:43.216164", + "modified": "2015-10-02 07:39:02.618929", "modified_by": "Administrator", "module": "Custom", "name": "Property Setter", diff --git a/frappe/custom/doctype/property_setter/test_property_setter.py b/frappe/custom/doctype/property_setter/test_property_setter.py new file mode 100644 index 0000000000..33e7d288a4 --- /dev/null +++ b/frappe/custom/doctype/property_setter/test_property_setter.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt +from __future__ import unicode_literals + +import frappe +import unittest + +# test_records = frappe.get_test_records('Property Setter') + +class TestPropertySetter(unittest.TestCase): + pass diff --git a/frappe/data/Framework.sql b/frappe/data/Framework.sql index 624bea642d..3c5e5c020f 100644 --- a/frappe/data/Framework.sql +++ b/frappe/data/Framework.sql @@ -48,6 +48,7 @@ CREATE TABLE `tabDocField` ( `in_list_view` int(1) NOT NULL DEFAULT 0, `read_only` int(1) NOT NULL DEFAULT 0, `precision` varchar(255) DEFAULT NULL, + `length` int(11) DEFAULT NULL, PRIMARY KEY (`name`), KEY `parent` (`parent`), KEY `label` (`label`), diff --git a/frappe/desk/doctype/event/event.json b/frappe/desk/doctype/event/event.json index 33adad16c2..931f92cb3f 100644 --- a/frappe/desk/doctype/event/event.json +++ b/frappe/desk/doctype/event/event.json @@ -62,6 +62,7 @@ "in_filter": 0, "in_list_view": 1, "label": "Event Type", + "length": 20, "no_copy": 0, "oldfieldname": "event_type", "oldfieldtype": "Select", @@ -254,6 +255,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Repeat On", + "length": 20, "no_copy": 0, "options": "\nEvery Day\nEvery Week\nEvery Month\nEvery Year", "permlevel": 0, @@ -635,7 +637,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-09-07 15:51:26", + "modified": "2015-10-02 07:38:49.897665", "modified_by": "Administrator", "module": "Desk", "name": "Event", diff --git a/frappe/desk/doctype/event_role/event_role.json b/frappe/desk/doctype/event_role/event_role.json index e8a7613935..fe8f6ec94f 100644 --- a/frappe/desk/doctype/event_role/event_role.json +++ b/frappe/desk/doctype/event_role/event_role.json @@ -43,7 +43,7 @@ "is_submittable": 0, "issingle": 0, "istable": 1, - "modified": "2015-02-19 01:07:00.166770", + "modified": "2015-10-02 07:38:50.115057", "modified_by": "Administrator", "module": "Desk", "name": "Event Role", diff --git a/frappe/desk/doctype/feed/feed.json b/frappe/desk/doctype/feed/feed.json index 47f0c873a1..fa8f0a762d 100644 --- a/frappe/desk/doctype/feed/feed.json +++ b/frappe/desk/doctype/feed/feed.json @@ -19,6 +19,7 @@ "in_filter": 0, "in_list_view": 1, "label": "Feed Type", + "length": 20, "no_copy": 0, "options": "\nComment\nLogin\nLabel\nInfo", "permlevel": 0, @@ -77,7 +78,7 @@ "bold": 0, "collapsible": 0, "fieldname": "subject", - "fieldtype": "Data", + "fieldtype": "Small Text", "hidden": 0, "ignore_user_permissions": 0, "in_filter": 0, @@ -145,7 +146,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-09-07 15:51:26", + "modified": "2015-10-02 07:38:50.611929", "modified_by": "Administrator", "module": "Desk", "name": "Feed", diff --git a/frappe/desk/doctype/feed/test_feed.py b/frappe/desk/doctype/feed/test_feed.py new file mode 100644 index 0000000000..36adfa377c --- /dev/null +++ b/frappe/desk/doctype/feed/test_feed.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt +from __future__ import unicode_literals + +import frappe +import unittest + +# test_records = frappe.get_test_records('Feed') + +class TestFeed(unittest.TestCase): + pass diff --git a/frappe/desk/doctype/note/note.json b/frappe/desk/doctype/note/note.json index 11121a2434..6e62b9d432 100644 --- a/frappe/desk/doctype/note/note.json +++ b/frappe/desk/doctype/note/note.json @@ -84,7 +84,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-09-11 12:20:04.912891", + "modified": "2015-10-02 07:38:57.968895", "modified_by": "Administrator", "module": "Desk", "name": "Note", diff --git a/frappe/desk/doctype/todo/todo.json b/frappe/desk/doctype/todo/todo.json index 144a4d1165..33703663a9 100644 --- a/frappe/desk/doctype/todo/todo.json +++ b/frappe/desk/doctype/todo/todo.json @@ -86,6 +86,7 @@ "in_filter": 0, "in_list_view": 1, "label": "Status", + "length": 20, "no_copy": 0, "options": "Open\nClosed", "permlevel": 0, @@ -109,6 +110,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Priority", + "length": 20, "no_copy": 0, "oldfieldname": "priority", "oldfieldtype": "Data", @@ -335,7 +337,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2015-09-07 15:51:26", + "modified": "2015-10-02 07:39:17.248993", "modified_by": "Administrator", "module": "Desk", "name": "ToDo", diff --git a/frappe/email/doctype/bulk_email/bulk_email.json b/frappe/email/doctype/bulk_email/bulk_email.json index 99d2b01a82..61d6284a3a 100644 --- a/frappe/email/doctype/bulk_email/bulk_email.json +++ b/frappe/email/doctype/bulk_email/bulk_email.json @@ -85,6 +85,7 @@ "in_filter": 0, "in_list_view": 1, "label": "Status", + "length": 20, "no_copy": 0, "options": "\nNot Sent\nSending\nSent\nError", "permlevel": 0, @@ -215,7 +216,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-09-29 05:16:31.857121", + "modified": "2015-10-02 07:38:40.795371", "modified_by": "Administrator", "module": "Email", "name": "Bulk Email", diff --git a/frappe/email/doctype/email_account/email_account.json b/frappe/email/doctype/email_account/email_account.json index 753bee092b..817eadb1f9 100644 --- a/frappe/email/doctype/email_account/email_account.json +++ b/frappe/email/doctype/email_account/email_account.json @@ -42,6 +42,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Service", + "length": 20, "no_copy": 0, "options": "\nGMail\nYahoo Mail\nOutlook.com", "permlevel": 0, @@ -780,7 +781,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-09-18 01:34:31.784444", + "modified": "2015-10-02 07:38:47.651995", "modified_by": "Administrator", "module": "Email", "name": "Email Account", diff --git a/frappe/email/doctype/email_alert/email_alert.json b/frappe/email/doctype/email_alert/email_alert.json index b4496355c5..70b34d0d2a 100644 --- a/frappe/email/doctype/email_alert/email_alert.json +++ b/frappe/email/doctype/email_alert/email_alert.json @@ -106,6 +106,7 @@ "in_filter": 0, "in_list_view": 1, "label": "Send Alert On", + "length": 20, "no_copy": 0, "options": "\nNew\nSave\nSubmit\nCancel\nDays After\nDays Before\nValue Change", "permlevel": 0, @@ -411,7 +412,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-07-09 00:27:00.169741", + "modified": "2015-10-02 07:38:47.925050", "modified_by": "Administrator", "module": "Email", "name": "Email Alert", diff --git a/frappe/email/doctype/email_alert_recipient/email_alert_recipient.json b/frappe/email/doctype/email_alert_recipient/email_alert_recipient.json index 29c90a1e8d..9ed1d1fcad 100644 --- a/frappe/email/doctype/email_alert_recipient/email_alert_recipient.json +++ b/frappe/email/doctype/email_alert_recipient/email_alert_recipient.json @@ -82,7 +82,7 @@ "is_submittable": 0, "issingle": 0, "istable": 1, - "modified": "2014-07-11 17:54:53.298536", + "modified": "2015-10-02 07:38:48.185785", "modified_by": "Administrator", "module": "Email", "name": "Email Alert Recipient", diff --git a/frappe/email/doctype/email_unsubscribe/email_unsubscribe.json b/frappe/email/doctype/email_unsubscribe/email_unsubscribe.json index c4210ee009..f93379d5c3 100644 --- a/frappe/email/doctype/email_unsubscribe/email_unsubscribe.json +++ b/frappe/email/doctype/email_unsubscribe/email_unsubscribe.json @@ -106,7 +106,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-08-05 06:02:12.805282", + "modified": "2015-10-02 07:38:48.744583", "modified_by": "Administrator", "module": "Email", "name": "Email Unsubscribe", diff --git a/frappe/email/doctype/standard_reply/standard_reply.json b/frappe/email/doctype/standard_reply/standard_reply.json index 049c724a9e..314f8bdb81 100644 --- a/frappe/email/doctype/standard_reply/standard_reply.json +++ b/frappe/email/doctype/standard_reply/standard_reply.json @@ -83,7 +83,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-09-07 15:51:26", + "modified": "2015-10-02 07:39:13.407883", "modified_by": "Administrator", "module": "Email", "name": "Standard Reply", diff --git a/frappe/email/doctype/standard_reply/test_standard_reply.py b/frappe/email/doctype/standard_reply/test_standard_reply.py new file mode 100644 index 0000000000..9255716b12 --- /dev/null +++ b/frappe/email/doctype/standard_reply/test_standard_reply.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt +from __future__ import unicode_literals + +import frappe +import unittest + +# test_records = frappe.get_test_records('Standard Reply') + +class TestStandardReply(unittest.TestCase): + pass diff --git a/frappe/exceptions.py b/frappe/exceptions.py index 17c12d2c36..49e1515c0b 100644 --- a/frappe/exceptions.py +++ b/frappe/exceptions.py @@ -47,6 +47,7 @@ class MandatoryError(ValidationError): pass class InvalidSignatureError(ValidationError): pass class RateLimitExceededError(ValidationError): pass class CannotChangeConstantError(ValidationError): pass +class CharacterLengthExceededError(ValidationError): pass class UpdateAfterSubmitError(ValidationError): pass class LinkValidationError(ValidationError): pass class CancelledLinkError(LinkValidationError): pass diff --git a/frappe/geo/doctype/country/country.json b/frappe/geo/doctype/country/country.json index 165695d7f5..04e111f0aa 100644 --- a/frappe/geo/doctype/country/country.json +++ b/frappe/geo/doctype/country/country.json @@ -105,7 +105,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-09-07 15:51:26", + "modified": "2015-10-02 07:38:42.770807", "modified_by": "Administrator", "module": "Geo", "name": "Country", diff --git a/frappe/geo/doctype/currency/currency.json b/frappe/geo/doctype/currency/currency.json index b42a53da67..8b1c4c0d08 100644 --- a/frappe/geo/doctype/currency/currency.json +++ b/frappe/geo/doctype/currency/currency.json @@ -132,6 +132,7 @@ "in_filter": 0, "in_list_view": 1, "label": "Number Format", + "length": 20, "no_copy": 0, "options": "\n#,###.##\n#.###,##\n# ###.##\n# ###,##\n#'###.##\n#, ###.##\n#,##,###.##\n#,###.###\n#.###\n#,###", "permlevel": 0, @@ -153,7 +154,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-09-14 03:17:04.837607", + "modified": "2015-10-02 07:38:42.863135", "modified_by": "Administrator", "module": "Geo", "name": "Currency", diff --git a/frappe/model/base_document.py b/frappe/model/base_document.py index a4ad9e35db..22b75a0596 100644 --- a/frappe/model/base_document.py +++ b/frappe/model/base_document.py @@ -9,6 +9,7 @@ from frappe.model import default_fields from frappe.model.naming import set_new_name from frappe.modules import load_doctype_module from frappe.model import display_fieldtypes +from frappe.model.db_schema import type_map, varchar_len _classes = {} @@ -444,6 +445,25 @@ class BaseDocument(object): frappe.throw(_("Value cannot be changed for {0}").format(self.meta.get_label(fieldname)), frappe.CannotChangeConstantError) + def _validate_length(self): + if frappe.flags.in_install: + return + + for fieldname, value in self.get_valid_dict().iteritems(): + df = self.meta.get_field(fieldname) + if df and df.fieldtype in type_map and type_map[df.fieldtype][0]=="varchar": + max_length = cint(df.get("length")) or cint(varchar_len) + + if len(cstr(value)) > max_length: + if self.parentfield and self.idx: + reference = _("{0}, Row {1}").format(_(self.doctype), self.idx) + + else: + reference = "{0} {1}".format(_(self.doctype), self.name) + + frappe.throw(_("{0}: '{1}' will get truncated, as max characters allowed is {2}")\ + .format(reference, _(df.label), max_length), frappe.CharacterLengthExceededError) + def _validate_update_after_submit(self): # get the full doc with children db_values = frappe.get_doc(self.doctype, self.name).as_dict() diff --git a/frappe/model/db_schema.py b/frappe/model/db_schema.py index deb27d7eda..230900eec1 100644 --- a/frappe/model/db_schema.py +++ b/frappe/model/db_schema.py @@ -13,9 +13,13 @@ import os import frappe from frappe import _ from frappe.utils import cstr, cint +import MySQLdb class InvalidColumnName(frappe.ValidationError): pass +varchar_len = '140' +standard_varchar_columns = ('name', 'owner', 'modified_by', 'parent', 'parentfield', 'parenttype') + type_map = { 'Currency': ('decimal', '18,6') ,'Int': ('int', '11') @@ -30,14 +34,14 @@ type_map = { ,'Datetime': ('datetime', '6') ,'Time': ('time', '6') ,'Text': ('text', '') - ,'Data': ('varchar', '255') - ,'Link': ('varchar', '255') - ,'Dynamic Link':('varchar', '255') - ,'Password': ('varchar', '255') - ,'Select': ('varchar', '255') - ,'Read Only': ('varchar', '255') - ,'Attach': ('varchar', '255') - ,'Attach Image':('varchar', '255') + ,'Data': ('varchar', varchar_len) + ,'Link': ('varchar', varchar_len) + ,'Dynamic Link':('varchar', varchar_len) + ,'Password': ('varchar', varchar_len) + ,'Select': ('varchar', varchar_len) + ,'Read Only': ('varchar', varchar_len) + ,'Attach': ('varchar', varchar_len) + ,'Attach Image':('varchar', varchar_len) } default_columns = ['name', 'creation', 'modified', 'modified_by', 'owner', @@ -57,8 +61,10 @@ def updatedb(dt): raise Exception, 'Wrong doctype "%s" in updatedb' % dt if not res[0][0]: - frappe.db.commit() tab = DbTable(dt, 'tab') + tab.validate() + + frappe.db.commit() tab.sync() frappe.db.begin() @@ -80,12 +86,57 @@ class DbTable: # load self.get_columns_from_docfields() + def validate(self): + """Check if change in varchar length isn't truncating the columns""" + if self.is_new(): + return + + self.get_columns_from_db() + + columns = [frappe._dict({"fieldname": f, "fieldtype": "Data"}) for f in standard_varchar_columns] + columns += self.columns.values() + + for col in columns: + if col.fieldtype in type_map and type_map[col.fieldtype][0]=="varchar": + + # validate length range + new_length = cint(col.length) or cint(varchar_len) + if not (1 <= new_length <= 255): + frappe.throw(_("Length of {0} should be between 1 and 255").format(col.fieldname)) + + try: + # check for truncation + max_length = frappe.db.sql("""select max(length(`{fieldname}`)) from `tab{doctype}`"""\ + .format(fieldname=col.fieldname, doctype=self.doctype)) + + except MySQLdb.OperationalError, e: + if e.args[0]==1054: + # Unknown column 'column_name' in 'field list' + continue + + else: + raise + + if max_length and max_length[0][0] > new_length: + current_type = self.current_columns[col.fieldname]["type"] + current_length = re.findall('varchar\(([\d]+)\)', current_type)[0] + + if col.fieldname in self.columns: + self.columns[col.fieldname].length = current_length + + frappe.msgprint(_("Reverting length to {0} for '{1}' in '{2}'; Setting the length as {3} will cause truncation of data.")\ + .format(current_length, col.fieldname, self.doctype, new_length)) + + def sync(self): - if not self.name in DbManager(frappe.db).get_tables_list(frappe.db.cur_db_name): + if self.is_new(): self.create() else: self.alter() + def is_new(self): + return self.name not in DbManager(frappe.db).get_tables_list(frappe.db.cur_db_name) + def create(self): add_text = '' @@ -99,21 +150,21 @@ class DbTable: # create table frappe.db.sql("""create table `%s` ( - name varchar(255) not null primary key, + name varchar({varchar_len}) not null primary key, creation datetime(6), modified datetime(6), - modified_by varchar(255), - owner varchar(255), + modified_by varchar({varchar_len}), + owner varchar({varchar_len}), docstatus int(1) default '0', - parent varchar(255), - parentfield varchar(255), - parenttype varchar(255), + parent varchar({varchar_len}), + parentfield varchar({varchar_len}), + parenttype varchar({varchar_len}), idx int(8), %sindex parent(parent)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED CHARACTER SET=utf8mb4 - COLLATE=utf8mb4_unicode_ci""" % (self.name, add_text)) + COLLATE=utf8mb4_unicode_ci""".format(varchar_len=varchar_len) % (self.name, add_text)) def get_column_definitions(self): column_list = [] + default_columns @@ -139,6 +190,7 @@ class DbTable: get columns from docfields and custom fields """ fl = frappe.db.sql("SELECT * FROM tabDocField WHERE parent = %s", self.doctype, as_dict = 1) + lengths = {} precisions = {} uniques = {} @@ -148,19 +200,26 @@ class DbTable: WHERE dt = %s AND docstatus < 2""", (self.doctype,), as_dict=1) if custom_fl: fl += custom_fl - # get precision from property setters - for ps in frappe.get_all("Property Setter", fields=["field_name", "value"], - filters={"doc_type": self.doctype, "doctype_or_field": "DocField", "property": "precision"}): - precisions[ps.field_name] = ps.value + # apply length, precision and unique from property setters + for ps in frappe.get_all("Property Setter", fields=["field_name", "property", "value"], + filters={ + "doc_type": self.doctype, + "doctype_or_field": "DocField", + "property": ["in", ["precision", "length", "unique"]] + }): - # apply unique from property setters - for ps in frappe.get_all("Property Setter", fields=["field_name", "value"], - filters={"doc_type": self.doctype, "doctype_or_field": "DocField", "property": "unique"}): + if ps.property=="length": + lengths[ps.field_name] = cint(ps.value) + + elif ps.property=="precision": + precisions[ps.field_name] = cint(ps.value) + + elif ps.property=="unique": uniques[ps.field_name] = cint(ps.value) for f in fl: self.columns[f['fieldname']] = DbColumn(self, f['fieldname'], - f['fieldtype'], f.get('length'), f.get('default'), f.get('search_index'), + f['fieldtype'], lengths.get(f["fieldname"]) or f.get('length'), f.get('default'), f.get('search_index'), f.get('options'), uniques.get(f["fieldname"], f.get('unique')), precisions.get(f['fieldname']) or f.get('precision')) def get_columns_from_db(self): @@ -201,7 +260,6 @@ class DbTable: frappe.db.sql("set foreign_key_checks=1") def alter(self): - self.get_columns_from_db() for col in self.columns.values(): col.build_for_alter_table(self.current_columns.get(col.fieldname, None)) @@ -268,7 +326,7 @@ class DbColumn: self.precision = precision def get_definition(self, with_default=1): - column_def = get_definition(self.fieldtype, self.precision) + column_def = get_definition(self.fieldtype, precision=self.precision, length=self.length) if not column_def: return column_def @@ -287,7 +345,7 @@ class DbColumn: return column_def def build_for_alter_table(self, current_def): - column_def = get_definition(self.fieldtype) + column_def = get_definition(self.fieldtype, self.precision, self.length) # no columns if not column_def: @@ -471,20 +529,28 @@ def remove_all_foreign_keys(): for f in fklist: frappe.db.sql("alter table `tab%s` drop foreign key `%s`" % (t[0], f[1])) -def get_definition(fieldtype, precision=None): +def get_definition(fieldtype, precision=None, length=None): d = type_map.get(fieldtype) if not d: return - ret = d[0] + coltype = d[0] + size = None if d[1]: - length = d[1] + size = d[1] + + if size: if fieldtype in ["Float", "Currency", "Percent"] and cint(precision) > 6: - length = '18,9' - ret += '(' + length + ')' + size = '18,9' + + if coltype == "varchar" and length: + size = length + + if size is not None: + coltype = "{coltype}({size})".format(coltype=coltype, size=size) - return ret + return coltype def add_column(doctype, column_name, fieldtype, precision=None): frappe.db.commit() diff --git a/frappe/model/document.py b/frappe/model/document.py index f2d965cc2d..674d10b941 100644 --- a/frappe/model/document.py +++ b/frappe/model/document.py @@ -337,11 +337,13 @@ class Document(BaseDocument): self._validate_links() self._validate_selects() self._validate_constants() + self._validate_length() children = self.get_all_children() for d in children: d._validate_selects() d._validate_constants() + d._validate_length() # extract images after validations to save processing if some validation error is raised self._extract_images_from_text_editor() diff --git a/frappe/patches.txt b/frappe/patches.txt index c9dbc01117..b68592044e 100644 --- a/frappe/patches.txt +++ b/frappe/patches.txt @@ -2,7 +2,7 @@ execute:frappe.db.sql("""update `tabPatch Log` set patch=replace(patch, '.4_0.', frappe.patches.v5_0.convert_to_barracuda_and_utf8mb4 frappe.patches.v6_1.rename_file_data execute:frappe.reload_doc('core', 'doctype', 'doctype', force=True) #2014-01-24 -execute:frappe.reload_doc('core', 'doctype', 'docfield', force=True) #2015-08-20 +execute:frappe.reload_doc('core', 'doctype', 'docfield', force=True) #2015-10-14 execute:frappe.reload_doc('core', 'doctype', 'docperm') #2014-06-24 execute:frappe.reload_doc('core', 'doctype', 'page') #2013-13-26 execute:frappe.reload_doc('core', 'doctype', 'report') #2014-06-03 @@ -94,3 +94,4 @@ frappe.patches.v6_2.ignore_user_permissions_if_missing execute:frappe.db.sql("delete from tabSessions where user is null") frappe.patches.v6_2.rename_backup_manager execute:frappe.delete_doc("DocType", "Backup Manager") +frappe.patches.v6_4.reduce_varchar_length diff --git a/frappe/patches/v6_4/__init__.py b/frappe/patches/v6_4/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/frappe/patches/v6_4/reduce_varchar_length.py b/frappe/patches/v6_4/reduce_varchar_length.py new file mode 100644 index 0000000000..45229769cc --- /dev/null +++ b/frappe/patches/v6_4/reduce_varchar_length.py @@ -0,0 +1,33 @@ +from __future__ import unicode_literals +import frappe + +def execute(): + for doctype in frappe.get_all("DocType", filters={"issingle": 0}): + doctype = doctype.name + + for column in frappe.db.sql("desc `tab{doctype}`".format(doctype=doctype), as_dict=True): + fieldname = column["Field"] + column_type = column["Type"] + + if not column_type.startswith("varchar"): + continue + + max_length = frappe.db.sql("""select max(length(`{fieldname}`)) from `tab{doctype}`"""\ + .format(fieldname=fieldname, doctype=doctype)) + + max_length = max_length[0][0] if max_length else None + + if max_length and max_length > 140: + print "setting length of '{fieldname}' in '{doctype}' as {length}".format( + fieldname=fieldname, doctype=doctype, length=max_length) + + # create property setter for length + frappe.make_property_setter({ + "doctype": doctype, + "fieldname": fieldname, + "property": "length", + "value": max_length, + "property_type": "Int" + }) + + frappe.clear_cache(doctype=doctype) diff --git a/frappe/print/doctype/letter_head/letter_head.json b/frappe/print/doctype/letter_head/letter_head.json index b70dd49587..81e3f9132e 100644 --- a/frappe/print/doctype/letter_head/letter_head.json +++ b/frappe/print/doctype/letter_head/letter_head.json @@ -116,7 +116,7 @@ "issingle": 0, "istable": 0, "max_attachments": 3, - "modified": "2015-09-07 15:51:26", + "modified": "2015-10-02 07:38:56.001216", "modified_by": "Administrator", "module": "Print", "name": "Letter Head", diff --git a/frappe/print/doctype/print_format/print_format.json b/frappe/print/doctype/print_format/print_format.json index 019091a016..e50b610395 100644 --- a/frappe/print/doctype/print_format/print_format.json +++ b/frappe/print/doctype/print_format/print_format.json @@ -84,6 +84,7 @@ "in_filter": 1, "in_list_view": 0, "label": "Standard", + "length": 20, "no_copy": 1, "oldfieldname": "standard", "oldfieldtype": "Select", @@ -154,6 +155,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Print Format Type", + "length": 20, "no_copy": 0, "options": "Server\nClient", "permlevel": 0, @@ -269,6 +271,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Font", + "length": 20, "no_copy": 0, "options": "Default\nArial\nHelvetica\nVerdana\nMonospace", "permlevel": 0, @@ -447,7 +450,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2015-09-09 05:46:11.025962", + "modified": "2015-10-02 07:39:00.918464", "modified_by": "Administrator", "module": "Print", "name": "Print Format", diff --git a/frappe/public/js/frappe/form/control.js b/frappe/public/js/frappe/form/control.js index 011d854fed..39a90e914e 100644 --- a/frappe/public/js/frappe/form/control.js +++ b/frappe/public/js/frappe/form/control.js @@ -353,6 +353,11 @@ frappe.ui.form.ControlData = frappe.ui.form.ControlInput.extend({ .addClass("input-with-feedback form-control") .prependTo(this.input_area) + if (in_list(['Data', 'Link', 'Dynamic Link', 'Password', 'Select', 'Read Only', 'Attach', 'Attach Image'], + this.df.fieldtype)) { + this.$input.attr("maxlength", this.df.length || 140); + } + this.set_input_attributes(); this.input = this.$input.get(0); this.has_input = true; diff --git a/frappe/tests/test_document.py b/frappe/tests/test_document.py index 7a33026e4a..995103376a 100644 --- a/frappe/tests/test_document.py +++ b/frappe/tests/test_document.py @@ -150,3 +150,9 @@ class TestDocument(unittest.TestCase): d.load_from_db() d.starts_on = "2014-01-01" d.validate_update_after_submit() + + def test_varchar_length(self): + d = self.test_insert() + d.subject = "abcde"*100 + self.assertRaises(frappe.CharacterLengthExceededError, d.save) + diff --git a/frappe/website/doctype/about_us_team_member/about_us_team_member.json b/frappe/website/doctype/about_us_team_member/about_us_team_member.json index f1bc781c7e..2670387f30 100644 --- a/frappe/website/doctype/about_us_team_member/about_us_team_member.json +++ b/frappe/website/doctype/about_us_team_member/about_us_team_member.json @@ -83,7 +83,7 @@ "is_submittable": 0, "issingle": 0, "istable": 1, - "modified": "2015-02-19 09:29:46.804175", + "modified": "2015-10-02 07:38:37.354149", "modified_by": "Administrator", "module": "Website", "name": "About Us Team Member", diff --git a/frappe/website/doctype/blog_category/blog_category.json b/frappe/website/doctype/blog_category/blog_category.json index 5d442ec67b..06c51c2945 100644 --- a/frappe/website/doctype/blog_category/blog_category.json +++ b/frappe/website/doctype/blog_category/blog_category.json @@ -126,7 +126,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-09-11 12:20:05.555186", + "modified": "2015-10-02 07:38:39.540340", "modified_by": "Administrator", "module": "Website", "name": "Blog Category", diff --git a/frappe/website/doctype/blog_post/blog_post.json b/frappe/website/doctype/blog_post/blog_post.json index f166fc076f..b409d68141 100644 --- a/frappe/website/doctype/blog_post/blog_post.json +++ b/frappe/website/doctype/blog_post/blog_post.json @@ -272,7 +272,7 @@ "issingle": 0, "istable": 0, "max_attachments": 5, - "modified": "2015-09-11 12:19:54.226902", + "modified": "2015-10-02 07:38:39.632512", "modified_by": "Administrator", "module": "Website", "name": "Blog Post", diff --git a/frappe/website/doctype/blogger/blogger.json b/frappe/website/doctype/blogger/blogger.json index a862f754e6..980334f756 100644 --- a/frappe/website/doctype/blogger/blogger.json +++ b/frappe/website/doctype/blogger/blogger.json @@ -171,7 +171,7 @@ "issingle": 0, "istable": 0, "max_attachments": 1, - "modified": "2015-09-07 15:51:26", + "modified": "2015-10-02 07:38:39.773633", "modified_by": "Administrator", "module": "Website", "name": "Blogger", diff --git a/frappe/website/doctype/company_history/company_history.json b/frappe/website/doctype/company_history/company_history.json index f93ababa76..210801bd63 100644 --- a/frappe/website/doctype/company_history/company_history.json +++ b/frappe/website/doctype/company_history/company_history.json @@ -60,7 +60,7 @@ "is_submittable": 0, "issingle": 0, "istable": 1, - "modified": "2013-12-20 19:23:01", + "modified": "2015-10-02 07:38:42.281395", "modified_by": "Administrator", "module": "Website", "name": "Company History", diff --git a/frappe/website/doctype/top_bar_item/top_bar_item.json b/frappe/website/doctype/top_bar_item/top_bar_item.json index 6a2b4828a9..45a3b8e09a 100644 --- a/frappe/website/doctype/top_bar_item/top_bar_item.json +++ b/frappe/website/doctype/top_bar_item/top_bar_item.json @@ -88,6 +88,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Target", + "length": 20, "no_copy": 0, "options": "\ntarget = \"_blank\"", "permlevel": 0, @@ -130,7 +131,7 @@ "is_submittable": 0, "issingle": 0, "istable": 1, - "modified": "2015-07-07 07:06:26.632888", + "modified": "2015-10-02 07:39:17.448972", "modified_by": "Administrator", "module": "Website", "name": "Top Bar Item", diff --git a/frappe/website/doctype/web_form/web_form.json b/frappe/website/doctype/web_form/web_form.json index 1735313293..2b1d8f4727 100644 --- a/frappe/website/doctype/web_form/web_form.json +++ b/frappe/website/doctype/web_form/web_form.json @@ -431,7 +431,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-09-11 12:20:17.264419", + "modified": "2015-10-02 07:39:18.834336", "modified_by": "Administrator", "module": "Website", "name": "Web Form", diff --git a/frappe/website/doctype/web_form_field/web_form_field.json b/frappe/website/doctype/web_form_field/web_form_field.json index dcf14d258c..fa4b31678b 100644 --- a/frappe/website/doctype/web_form_field/web_form_field.json +++ b/frappe/website/doctype/web_form_field/web_form_field.json @@ -40,6 +40,7 @@ "in_filter": 0, "in_list_view": 1, "label": "Fieldtype", + "length": 20, "no_copy": 0, "options": "Attach\nCheck\nData\nDate\nDatetime\nHTML\nSelect\nText\nSection Break\nColumn Break", "permlevel": 0, @@ -266,7 +267,7 @@ "is_submittable": 0, "issingle": 0, "istable": 1, - "modified": "2015-06-03 06:45:30.240450", + "modified": "2015-10-02 07:39:19.006591", "modified_by": "Administrator", "module": "Website", "name": "Web Form Field", diff --git a/frappe/website/doctype/web_page/web_page.json b/frappe/website/doctype/web_page/web_page.json index 17ea6333fd..f476b5a6ce 100644 --- a/frappe/website/doctype/web_page/web_page.json +++ b/frappe/website/doctype/web_page/web_page.json @@ -411,6 +411,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Text Align", + "length": 20, "no_copy": 0, "options": "Left\nCenter\nRight", "permlevel": 0, @@ -608,7 +609,7 @@ "issingle": 0, "istable": 0, "max_attachments": 20, - "modified": "2015-09-11 12:19:37.342904", + "modified": "2015-10-02 07:39:19.171402", "modified_by": "Administrator", "module": "Website", "name": "Web Page", diff --git a/frappe/website/doctype/website_slideshow/test_website_slideshow.py b/frappe/website/doctype/website_slideshow/test_website_slideshow.py new file mode 100644 index 0000000000..9eccc71ad3 --- /dev/null +++ b/frappe/website/doctype/website_slideshow/test_website_slideshow.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt +from __future__ import unicode_literals + +import frappe +import unittest + +# test_records = frappe.get_test_records('Website Slideshow') + +class TestWebsiteSlideshow(unittest.TestCase): + pass diff --git a/frappe/website/doctype/website_slideshow/website_slideshow.json b/frappe/website/doctype/website_slideshow/website_slideshow.json index 47fca929ca..67c9048b9d 100644 --- a/frappe/website/doctype/website_slideshow/website_slideshow.json +++ b/frappe/website/doctype/website_slideshow/website_slideshow.json @@ -111,7 +111,7 @@ "issingle": 0, "istable": 0, "max_attachments": 10, - "modified": "2015-07-28 16:18:13.013029", + "modified": "2015-10-02 07:39:19.477260", "modified_by": "Administrator", "module": "Website", "name": "Website Slideshow", diff --git a/frappe/website/doctype/website_slideshow_item/website_slideshow_item.json b/frappe/website/doctype/website_slideshow_item/website_slideshow_item.json index ac3714bb8d..f1f2e218bb 100644 --- a/frappe/website/doctype/website_slideshow_item/website_slideshow_item.json +++ b/frappe/website/doctype/website_slideshow_item/website_slideshow_item.json @@ -85,7 +85,7 @@ "issingle": 0, "istable": 1, "max_attachments": 10, - "modified": "2015-02-19 09:27:05.003437", + "modified": "2015-10-02 07:39:19.556319", "modified_by": "Administrator", "module": "Website", "name": "Website Slideshow Item", diff --git a/frappe/website/doctype/website_theme/website_theme.json b/frappe/website/doctype/website_theme/website_theme.json index f84e20972e..966cd3447b 100644 --- a/frappe/website/doctype/website_theme/website_theme.json +++ b/frappe/website/doctype/website_theme/website_theme.json @@ -180,6 +180,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Font Size", + "length": 20, "no_copy": 0, "options": "\n12px\n13px\n14px\n15px\n16px\n17px\n18px", "permlevel": 0, @@ -314,6 +315,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Heading Style", + "length": 20, "no_copy": 0, "options": "\nUPPERCASE\nTitle Case\nlowercase", "permlevel": 0, @@ -643,7 +645,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-09-14 02:56:01.143058", + "modified": "2015-10-02 07:39:19.663446", "modified_by": "Administrator", "module": "Website", "name": "Website Theme", diff --git a/frappe/workflow/doctype/workflow/workflow.json b/frappe/workflow/doctype/workflow/workflow.json index 52f53ca4fd..e3c9198750 100644 --- a/frappe/workflow/doctype/workflow/workflow.json +++ b/frappe/workflow/doctype/workflow/workflow.json @@ -199,7 +199,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-09-14 02:56:01.362929", + "modified": "2015-10-02 07:39:19.926848", "modified_by": "Administrator", "module": "Workflow", "name": "Workflow", diff --git a/frappe/workflow/doctype/workflow_action/test_workflow_action.py b/frappe/workflow/doctype/workflow_action/test_workflow_action.py new file mode 100644 index 0000000000..d70ee9151b --- /dev/null +++ b/frappe/workflow/doctype/workflow_action/test_workflow_action.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt +from __future__ import unicode_literals + +import frappe +import unittest + +# test_records = frappe.get_test_records('Workflow Action') + +class TestWorkflowAction(unittest.TestCase): + pass diff --git a/frappe/workflow/doctype/workflow_action/workflow_action.json b/frappe/workflow/doctype/workflow_action/workflow_action.json index c6509435c2..6463bd4a9e 100644 --- a/frappe/workflow/doctype/workflow_action/workflow_action.json +++ b/frappe/workflow/doctype/workflow_action/workflow_action.json @@ -40,7 +40,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-02-05 05:12:45.535606", + "modified": "2015-10-02 07:39:20.028302", "modified_by": "Administrator", "module": "Workflow", "name": "Workflow Action", diff --git a/frappe/workflow/doctype/workflow_document_state/workflow_document_state.json b/frappe/workflow/doctype/workflow_document_state/workflow_document_state.json index c9ca6a3cd5..9e125b4a06 100644 --- a/frappe/workflow/doctype/workflow_document_state/workflow_document_state.json +++ b/frappe/workflow/doctype/workflow_document_state/workflow_document_state.json @@ -45,6 +45,7 @@ "in_filter": 0, "in_list_view": 1, "label": "Doc Status", + "length": 20, "no_copy": 0, "options": "0\n1\n2", "permlevel": 0, @@ -156,7 +157,7 @@ "is_submittable": 0, "issingle": 0, "istable": 1, - "modified": "2015-07-28 16:18:13.257862", + "modified": "2015-10-02 07:39:20.102069", "modified_by": "Administrator", "module": "Workflow", "name": "Workflow Document State", diff --git a/frappe/workflow/doctype/workflow_state/workflow_state.json b/frappe/workflow/doctype/workflow_state/workflow_state.json index a464da250b..93875945c4 100644 --- a/frappe/workflow/doctype/workflow_state/workflow_state.json +++ b/frappe/workflow/doctype/workflow_state/workflow_state.json @@ -43,6 +43,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Icon", + "length": 20, "no_copy": 0, "options": "\nglass\nmusic\nsearch\nenvelope\nheart\nstar\nstar-empty\nuser\nfilm\nth-large\nth\nth-list\nok\nremove\nzoom-in\nzoom-out\noff\nsignal\ncog\ntrash\nhome\nfile\ntime\nroad\ndownload-alt\ndownload\nupload\ninbox\nplay-circle\nrepeat\nrefresh\nlist-alt\nlock\nflag\nheadphones\nvolume-off\nvolume-down\nvolume-up\nqrcode\nbarcode\ntag\ntags\nbook\nbookmark\nprint\ncamera\nfont\nbold\nitalic\ntext-height\ntext-width\nalign-left\nalign-center\nalign-right\nalign-justify\nlist\nindent-left\nindent-right\nfacetime-video\npicture\npencil\nmap-marker\nadjust\ntint\nedit\nshare\ncheck\nmove\nstep-backward\nfast-backward\nbackward\nplay\npause\nstop\nforward\nfast-forward\nstep-forward\neject\nchevron-left\nchevron-right\nplus-sign\nminus-sign\nremove-sign\nok-sign\nquestion-sign\ninfo-sign\nscreenshot\nremove-circle\nok-circle\nban-circle\narrow-left\narrow-right\narrow-up\narrow-down\nshare-alt\nresize-full\nresize-small\nplus\nminus\nasterisk\nexclamation-sign\ngift\nleaf\nfire\neye-open\neye-close\nwarning-sign\nplane\ncalendar\nrandom\ncomment\nmagnet\nchevron-up\nchevron-down\nretweet\nshopping-cart\nfolder-close\nfolder-open\nresize-vertical\nresize-horizontal\nhdd\nbullhorn\nbell\ncertificate\nthumbs-up\nthumbs-down\nhand-right\nhand-left\nhand-up\nhand-down\ncircle-arrow-right\ncircle-arrow-left\ncircle-arrow-up\ncircle-arrow-down\nglobe\nwrench\ntasks\nfilter\nbriefcase\nfullscreen", "permlevel": 0, @@ -66,6 +67,7 @@ "in_filter": 0, "in_list_view": 0, "label": "Style", + "length": 20, "no_copy": 0, "options": "\nPrimary\nInfo\nSuccess\nWarning\nDanger\nInverse", "permlevel": 0, @@ -87,7 +89,7 @@ "is_submittable": 0, "issingle": 0, "istable": 0, - "modified": "2015-07-28 16:18:13.320514", + "modified": "2015-10-02 07:39:20.222387", "modified_by": "Administrator", "module": "Workflow", "name": "Workflow State", diff --git a/frappe/workflow/doctype/workflow_transition/workflow_transition.json b/frappe/workflow/doctype/workflow_transition/workflow_transition.json index bcbce218b1..bd694ec74e 100644 --- a/frappe/workflow/doctype/workflow_transition/workflow_transition.json +++ b/frappe/workflow/doctype/workflow_transition/workflow_transition.json @@ -113,7 +113,7 @@ "is_submittable": 0, "issingle": 0, "istable": 1, - "modified": "2013-12-20 19:21:55.000001", + "modified": "2015-10-02 07:39:20.308052", "modified_by": "Administrator", "module": "Workflow", "name": "Workflow Transition",