From f27b67b474ca9ebbaf1e59970089a0f80d093cd7 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 15 Feb 2012 10:45:29 +0100 Subject: [PATCH 1/2] fix in change password --- erpnext/home/page/my_company/my_company.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/erpnext/home/page/my_company/my_company.py b/erpnext/home/page/my_company/my_company.py index 11404fbe33..fa77b6c6f5 100644 --- a/erpnext/home/page/my_company/my_company.py +++ b/erpnext/home/page/my_company/my_company.py @@ -172,8 +172,7 @@ def update_security(args=''): res = server_tools.gateway_utils.change_password('', args['new_password'], args['user'], args['sys_admin_pwd']) if 'Traceback' not in res['message']: webnotes.msgprint(res['message']) - else: - webnotes.conn.sql("update tabProfile set password=password(%s) where name=%s", (args['new_password'], args['user'])) + webnotes.conn.sql("update tabProfile set password=password(%s) where name=%s", (args['new_password'], args['user'])) else: webnotes.msgprint('Settings Updated') welcome_txt = """ From 65bc9db85e8daffd3a0f739d67a97fbc7c5ee3a9 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 15 Feb 2012 15:42:18 +0530 Subject: [PATCH 2/2] File Data rename --- erpnext/patches/jan_mar_2012/website/all.py | 1 + .../jan_mar_2012/website/file_data_rename.py | 56 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 erpnext/patches/jan_mar_2012/website/file_data_rename.py diff --git a/erpnext/patches/jan_mar_2012/website/all.py b/erpnext/patches/jan_mar_2012/website/all.py index d6ad3b11a4..2a55d72e47 100644 --- a/erpnext/patches/jan_mar_2012/website/all.py +++ b/erpnext/patches/jan_mar_2012/website/all.py @@ -10,3 +10,4 @@ def execute(): patches.jan_mar_2012.website.website.execute() patches.jan_mar_2012.website.cleanups.execute() patches.jan_mar_2012.website.domain_list.execute() + patches.jan_mar_2012.website.file_data_rename.execute() diff --git a/erpnext/patches/jan_mar_2012/website/file_data_rename.py b/erpnext/patches/jan_mar_2012/website/file_data_rename.py new file mode 100644 index 0000000000..aff25db702 --- /dev/null +++ b/erpnext/patches/jan_mar_2012/website/file_data_rename.py @@ -0,0 +1,56 @@ +import webnotes + +def execute(): + """ + * Replace / in names with - in tabFile Data + * Change autoname in DocType File Data to FileData-.##### + * Change FileData/ to FileData- in tabSeries + * In each table containing file_list column, replace / with - in the data of that column + """ + replace_name_in_file_data() + change_autoname_in_tabfile_data() + change_file_data_in_tabseries() + replace_file_list_column_entries() + + +def replace_name_in_file_data(): + """ + Change / to - in tabFile Data name column entries + """ + files = webnotes.conn.sql("SELECT name FROM `tabFile Data`") + for f in files: + if "/" in f[0]: + webnotes.conn.sql("UPDATE `tabFile Data` SET name=%s WHERE name=%s", (f[0].replace('/', '-'), f[0])) + + +def change_autoname_in_tabfile_data(): + """ + Change autoname in DocType File Data to FileData-.##### + """ + webnotes.conn.sql("UPDATE `tabDocType` SET autoname='FileData-.#####' WHERE name='File Data'") + + +def change_file_data_in_tabseries(): + """ + Change FileData/ to FileData- in tabSeries + """ + webnotes.conn.sql("UPDATE `tabSeries` SET name='FileData-' WHERE name='FileData/'") + + +def replace_file_list_column_entries(): + """ + In each table containing file_list column, replace / with - in the data of that column + """ + tables = webnotes.conn.sql("SHOW TABLES") + tab_list = [] + for tab in tables: + columns = webnotes.conn.sql("DESC `%s`" % tab[0]) + if 'file_list' in [c[0] for c in columns]: + tab_list.append(tab[0]) + + for tab in tab_list: + data = webnotes.conn.sql("SELECT name, file_list FROM `%s`" % tab) + for name, file_list in data: + if file_list and "/" in file_list: + webnotes.conn.sql("UPDATE `%s` SET file_list='%s' WHERE name='%s'" \ + % (tab, file_list.replace('/', '-'), name))