diff --git a/frappe/config/customization.py b/frappe/config/customization.py index 06eaa2ea00..3d587e6839 100644 --- a/frappe/config/customization.py +++ b/frappe/config/customization.py @@ -3,7 +3,7 @@ from frappe import _ def get_data(): return [ - { + { "label": _("Form Customization"), "icon": "fa fa-glass", "items": [ @@ -57,9 +57,9 @@ def get_data(): }, { "type": "doctype", - "label": _("Custom Tags"), - "name": "Tag Category", - "description": _("Add your own Tag Categories") + "label": _("Package"), + "name": "Package", + "description": _("Import and Export Packages.") } ] } diff --git a/frappe/custom/doctype/customization_export/__init__.py b/frappe/custom/doctype/package/__init__.py similarity index 100% rename from frappe/custom/doctype/customization_export/__init__.py rename to frappe/custom/doctype/package/__init__.py diff --git a/frappe/custom/doctype/manage_customization/manage_customization.js b/frappe/custom/doctype/package/package.js similarity index 56% rename from frappe/custom/doctype/manage_customization/manage_customization.js rename to frappe/custom/doctype/package/package.js index 4c86519dd8..c362c51b24 100644 --- a/frappe/custom/doctype/manage_customization/manage_customization.js +++ b/frappe/custom/doctype/package/package.js @@ -1,18 +1,18 @@ // Copyright (c) 2020, Frappe Technologies and contributors // For license information, please see license.txt -frappe.ui.form.on('Manage Customization', { +frappe.ui.form.on('Package', { refresh: function(frm) { - frappe.realtime.on("exporting_progress", (data) => { - if (data.progress !== data.total) { + frappe.realtime.on("exporting_package", (data) => { + if (data.progress !== (data.total-1)) { frm.dashboard.show_progress("Exporting", data.progress / data.total * 100, __("{0}", [data.message])); } else { frm.dashboard.hide_progress(); } }); - frappe.realtime.on("importing_progress", (data) => { - if (data.progress !== data.total) { + frappe.realtime.on("importing_package", (data) => { + if (data.progress !== (data.total-1)) { frm.dashboard.show_progress("Importing", data.progress / data.total * 100, __("{0}", [data.message])); } else { frm.dashboard.hide_progress(); @@ -21,11 +21,11 @@ frappe.ui.form.on('Manage Customization', { }, export: function(frm) { frappe.call({ - method: 'frappe.custom.doctype.manage_customization.manage_customization.export_customizations', + method: 'frappe.custom.doctype.package.package.export_package', callback: function(r) { if (r.message) { const args = { - cmd: 'frappe.custom.doctype.manage_customization.manage_customization.export_customizations', + cmd: 'frappe.custom.doctype.package.package.download_package', data: r.message.data }; open_url_post(frappe.request.url, args, true); @@ -35,9 +35,9 @@ frappe.ui.form.on('Manage Customization', { }, import: function(frm) { frappe.call({ - method: 'frappe.custom.doctype.manage_customization.manage_customization.import_customizations', + method: 'frappe.custom.doctype.package.package.import_package', callback: function() { - frappe.msgprint(__("Customizations Imported.")); + frappe.msgprint(__("Package Imported.")); } }); } diff --git a/frappe/custom/doctype/manage_customization/manage_customization.json b/frappe/custom/doctype/package/package.json similarity index 63% rename from frappe/custom/doctype/manage_customization/manage_customization.json rename to frappe/custom/doctype/package/package.json index 43c4596590..cad2ca6788 100644 --- a/frappe/custom/doctype/manage_customization/manage_customization.json +++ b/frappe/custom/doctype/package/package.json @@ -1,58 +1,58 @@ { "actions": [], - "creation": "2020-03-01 23:21:17.394500", + "creation": "2020-03-14 11:20:14.850552", "doctype": "DocType", "editable_grid": 1, "engine": "InnoDB", "field_order": [ "sb_00", - "export_customization", + "export_package", "export", "sb_01", - "import_customization", + "import_package", "import" ], "fields": [ - { - "fieldname": "export_customization", - "fieldtype": "Table", - "label": "Customizations to Export", - "options": "Customization Export" - }, { "fieldname": "sb_00", "fieldtype": "Section Break", - "label": "Export Customizations" + "label": "Export Package" }, { - "fieldname": "sb_01", - "fieldtype": "Section Break", - "label": "Import Customizations" - }, - { - "fieldname": "import_customization", - "fieldtype": "Attach", - "label": "Attach" - }, - { - "depends_on": "export_customization", + "depends_on": "export_package", "fieldname": "export", "fieldtype": "Button", "label": "Export" }, { - "depends_on": "import_customization", + "fieldname": "sb_01", + "fieldtype": "Section Break", + "label": "Import Package" + }, + { + "depends_on": "import_package", "fieldname": "import", "fieldtype": "Button", "label": "Import" + }, + { + "fieldname": "export_package", + "fieldtype": "Table", + "label": "Package", + "options": "Package DocType" + }, + { + "fieldname": "import_package", + "fieldtype": "Attach", + "label": "Attach" } ], "issingle": 1, "links": [], - "modified": "2020-03-13 17:14:00.382402", + "modified": "2020-03-14 11:52:58.221081", "modified_by": "Administrator", "module": "Custom", - "name": "Manage Customization", + "name": "Package", "owner": "Administrator", "permissions": [ { @@ -64,6 +64,16 @@ "role": "System Manager", "share": 1, "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "print": 1, + "read": 1, + "role": "All", + "share": 1, + "write": 1 } ], "quick_entry": 1, diff --git a/frappe/custom/doctype/manage_customization/manage_customization.py b/frappe/custom/doctype/package/package.py similarity index 55% rename from frappe/custom/doctype/manage_customization/manage_customization.py rename to frappe/custom/doctype/package/package.py index f3c18d5017..e3a29144d9 100644 --- a/frappe/custom/doctype/manage_customization/manage_customization.py +++ b/frappe/custom/doctype/package/package.py @@ -7,17 +7,17 @@ import frappe from frappe.model.document import Document import json -class ManageCustomization(Document): +class Package(Document): pass @frappe.whitelist() -def export_customizations(): - """Export fixtures as JSON""" +def export_package(): + """Export package as JSON""" - export_customizations_doc = frappe.get_single("Manage Customization") - customizations = [] + package_doc = frappe.get_single("Package") + package = [] - for doctype in export_customizations_doc.export_customization: + for doctype in package_doc.export_package: filters, or_filters = {}, {} if doctype.get("filters"): @@ -28,36 +28,36 @@ def export_customizations(): docs = frappe.get_all(doctype.get("document_type"), filters=filters, or_filters=or_filters) length = len(docs) for idx, doc in enumerate(docs): - frappe.publish_realtime("exporting_progress", dict(progress=idx, total=length, message=doctype.get("document_type")), user=frappe.session.user) - customizations.append(frappe.get_doc(doctype.get("document_type"), doc.name).as_dict()) + frappe.publish_realtime("exporting_package", dict(progress=idx, total=length, message=doctype.get("document_type")), user=frappe.session.user) + package.append(frappe.get_doc(doctype.get("document_type"), doc.name).as_dict()) return frappe._dict({ - "data": post_process(customizations) + "data": post_process(package) }) @frappe.whitelist() -def import_customizations(): - """Import fixtures as JSON""" +def import_package(): + """Import package from JSON""" - import_file = frappe.get_all("File", filters={ - "attached_to_doctype": "Manage Customization", - "attached_to_name": "Manage Customization" + package_file = frappe.get_all("File", filters={ + "attached_to_doctype": "Package", + "attached_to_name": "Package" }, limit=1, order_by="creation desc") - if not import_file: + if not package_file: return - content = json.loads(frappe.get_doc("File", import_file[0].name).get_content()) + content = json.loads(frappe.get_doc("File", package_file[0].name).get_content()) length = len(content) for idx, doc in enumerate(content.get("message").get("data")): - frappe.publish_realtime("exporting_progress", dict(progress=idx, total=length, message=doc.get("doctype")), user=frappe.session.user) + frappe.publish_realtime("importing_package", dict(progress=idx, total=length, message=doc.get("doctype")), user=frappe.session.user) frappe.get_doc(doc).insert(ignore_permissions=True, ignore_if_duplicate=True) -def post_process(customizations): +def post_process(package): del_keys = ('modified_by', 'creation', 'owner', 'idx', 'name', 'modified', 'docstatus') - for doc in customizations: + for doc in package: for key in del_keys: if key in doc: del doc[key] @@ -71,12 +71,12 @@ def post_process(customizations): if key in child: del child[key] - return customizations + return package @frappe.whitelist() -def download_customization_json(): +def download_package(): data = frappe._dict(frappe.local.form_dict) - frappe.response['filename'] = 'Customizations.json' + frappe.response['filename'] = 'Package.json' frappe.response['filecontent'] = data.get("data") frappe.response['content_type'] = 'application/json' frappe.response['type'] = 'download' \ No newline at end of file diff --git a/frappe/custom/doctype/manage_customization/test_manage_customization.py b/frappe/custom/doctype/package/test_package.py similarity index 78% rename from frappe/custom/doctype/manage_customization/test_manage_customization.py rename to frappe/custom/doctype/package/test_package.py index af1a332bb4..3a17d51260 100644 --- a/frappe/custom/doctype/manage_customization/test_manage_customization.py +++ b/frappe/custom/doctype/package/test_package.py @@ -6,5 +6,5 @@ from __future__ import unicode_literals # import frappe import unittest -class TestManageCustomization(unittest.TestCase): +class TestPackage(unittest.TestCase): pass diff --git a/frappe/custom/doctype/manage_customization/__init__.py b/frappe/custom/doctype/package_doctype/__init__.py similarity index 100% rename from frappe/custom/doctype/manage_customization/__init__.py rename to frappe/custom/doctype/package_doctype/__init__.py diff --git a/frappe/custom/doctype/customization_export/customization_export.json b/frappe/custom/doctype/package_doctype/package_doctype.json similarity index 88% rename from frappe/custom/doctype/customization_export/customization_export.json rename to frappe/custom/doctype/package_doctype/package_doctype.json index bc59a89f4f..cfc4cbbe8f 100644 --- a/frappe/custom/doctype/customization_export/customization_export.json +++ b/frappe/custom/doctype/package_doctype/package_doctype.json @@ -1,6 +1,6 @@ { "actions": [], - "creation": "2020-03-12 14:51:09.260025", + "creation": "2020-03-14 11:20:42.875446", "doctype": "DocType", "editable_grid": 1, "engine": "InnoDB", @@ -20,33 +20,33 @@ "options": "DocType", "reqd": 1 }, + { + "fieldname": "sb_00", + "fieldtype": "Section Break" + }, { "fieldname": "filters", "fieldtype": "Code", "in_list_view": 1, "label": "Filters" }, + { + "fieldname": "cb_00", + "fieldtype": "Column Break" + }, { "fieldname": "or_filters", "fieldtype": "Code", "in_list_view": 1, "label": "Or Filters" - }, - { - "fieldname": "sb_00", - "fieldtype": "Section Break" - }, - { - "fieldname": "cb_00", - "fieldtype": "Column Break" } ], "istable": 1, "links": [], - "modified": "2020-03-13 16:53:15.214275", + "modified": "2020-03-14 11:20:42.875446", "modified_by": "Administrator", "module": "Custom", - "name": "Customization Export", + "name": "Package DocType", "owner": "Administrator", "permissions": [], "quick_entry": 1, diff --git a/frappe/custom/doctype/customization_export/customization_export.py b/frappe/custom/doctype/package_doctype/package_doctype.py similarity index 86% rename from frappe/custom/doctype/customization_export/customization_export.py rename to frappe/custom/doctype/package_doctype/package_doctype.py index 70a7da3b08..c185395965 100644 --- a/frappe/custom/doctype/customization_export/customization_export.py +++ b/frappe/custom/doctype/package_doctype/package_doctype.py @@ -6,5 +6,5 @@ from __future__ import unicode_literals # import frappe from frappe.model.document import Document -class CustomizationExport(Document): +class PackageDocType(Document): pass