From 73aa0a35c48a0d25027ce6432da023d4216b0bbc Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Wed, 16 Aug 2017 15:50:20 +0530 Subject: [PATCH] Patch old event colors to hex --- frappe/patches.txt | 1 + frappe/patches/v8_5/patch_event_colors.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 frappe/patches/v8_5/patch_event_colors.py diff --git a/frappe/patches.txt b/frappe/patches.txt index 3347ae8287..a9a28d5f05 100644 --- a/frappe/patches.txt +++ b/frappe/patches.txt @@ -190,3 +190,4 @@ frappe.patches.v8_1.update_format_options_in_auto_email_report frappe.patches.v8_1.delete_custom_docperm_if_doctype_not_exists frappe.patches.v8_5.delete_email_group_member_with_invalid_emails frappe.patches.v8_x.update_user_permission +frappe.patches.v8_5.patch_event_colors diff --git a/frappe/patches/v8_5/patch_event_colors.py b/frappe/patches/v8_5/patch_event_colors.py new file mode 100644 index 0000000000..189f2a8f3f --- /dev/null +++ b/frappe/patches/v8_5/patch_event_colors.py @@ -0,0 +1,21 @@ +from __future__ import unicode_literals +import frappe + +def execute(): + colors = ['red', 'green', 'blue', 'yellow', 'skyblue', 'orange'] + hex = ['#ffc4c4', '#cef6d1', '#d2d2ff', '#fffacd', '#d2f1ff', '#ffd2c2'] + + def get_hex_for_color(color): + index = colors.index(color) + return hex[index] + + query = ''' + update tabEvent + set color='{hex}' + where color='{color}' + ''' + + for color in colors: + frappe.db.sql(query.format(color=color, hex=get_hex_for_color(color))) + + frappe.db.commit() \ No newline at end of file