Browse Source

Patch old event colors to hex

version-14
Faris Ansari 8 years ago
parent
commit
73aa0a35c4
2 changed files with 22 additions and 0 deletions
  1. +1
    -0
      frappe/patches.txt
  2. +21
    -0
      frappe/patches/v8_5/patch_event_colors.py

+ 1
- 0
frappe/patches.txt View File

@@ -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_1.delete_custom_docperm_if_doctype_not_exists
frappe.patches.v8_5.delete_email_group_member_with_invalid_emails frappe.patches.v8_5.delete_email_group_member_with_invalid_emails
frappe.patches.v8_x.update_user_permission frappe.patches.v8_x.update_user_permission
frappe.patches.v8_5.patch_event_colors

+ 21
- 0
frappe/patches/v8_5/patch_event_colors.py View File

@@ -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()

Loading…
Cancel
Save