User settings patch fixes
This commit is contained in:
parent
685803900e
commit
ba9d08fda3
5 changed files with 52 additions and 53 deletions
|
|
@ -43,7 +43,7 @@ def install_db(root_login="root", root_password=None, db_name=None, source_sql=N
|
|||
|
||||
create_auth_table()
|
||||
setup_global_search_table()
|
||||
create_list_settings_table()
|
||||
create_user_settings_table()
|
||||
|
||||
frappe.flags.in_install_db = False
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ def create_database_and_user(force, verbose):
|
|||
# close root connection
|
||||
frappe.db.close()
|
||||
|
||||
def create_list_settings_table():
|
||||
def create_user_settings_table():
|
||||
frappe.db.sql_ddl("""create table if not exists __UserSettings (
|
||||
`user` VARCHAR(180) NOT NULL,
|
||||
`doctype` VARCHAR(180) NOT NULL,
|
||||
|
|
|
|||
|
|
@ -143,7 +143,6 @@ frappe.patches.v7_0.set_user_fullname
|
|||
frappe.patches.v7_0.desktop_icons_hidden_by_admin_as_blocked
|
||||
frappe.patches.v7_0.add_communication_in_doc
|
||||
frappe.patches.v7_0.update_send_after_in_bulk_email
|
||||
frappe.patches.v7_0.setup_list_settings
|
||||
execute:frappe.db.sql('''delete from `tabSingles` where doctype="Email Settings"''') # 2016-06-13
|
||||
execute:frappe.db.sql("delete from `tabWeb Page` where ifnull(template_path, '')!=''")
|
||||
frappe.patches.v7_0.rename_newsletter_list_to_email_group
|
||||
|
|
@ -169,7 +168,7 @@ execute:frappe.rename_doc('Country', 'Macedonia, Republic of', 'Macedonia', igno
|
|||
execute:frappe.rename_doc('Country', 'Iran, Islamic Republic of', 'Iran', ignore_if_exists=True)
|
||||
execute:frappe.rename_doc('Country', 'Tanzania, United Republic of', 'Tanzania', ignore_if_exists=True)
|
||||
execute:frappe.rename_doc('Country', 'Syrian Arab Republic', 'Syria', ignore_if_exists=True)
|
||||
frappe.patches.v8_0.rename_listsettings_to_usersettings
|
||||
frappe.patches.v8_0.rename_listsettings_to_usersettings #1
|
||||
frappe.patches.v7_2.update_communications
|
||||
frappe.patches.v8_0.deprecate_integration_broker
|
||||
frappe.patches.v8_0.setup_email_inbox #2017-03-29
|
||||
|
|
|
|||
|
|
@ -1,20 +1,19 @@
|
|||
from frappe.installer import create_list_settings_table
|
||||
from frappe.model.utils.list_settings import update_list_settings
|
||||
import frappe, json
|
||||
|
||||
def execute():
|
||||
list_settings = frappe.db.sql("select user, doctype, data from __ListSettings", as_dict=1)
|
||||
for ls in list_settings:
|
||||
if ls and ls.data:
|
||||
data = json.loads(ls.data)
|
||||
if not data.has_key("fields"):
|
||||
continue
|
||||
fields = data["fields"]
|
||||
for field in fields:
|
||||
if "name as" in field:
|
||||
fields.remove(field)
|
||||
data["fields"] = fields
|
||||
if frappe.db.table_exists("__ListSettings"):
|
||||
list_settings = frappe.db.sql("select user, doctype, data from __ListSettings", as_dict=1)
|
||||
for ls in list_settings:
|
||||
if ls and ls.data:
|
||||
data = json.loads(ls.data)
|
||||
if not data.has_key("fields"):
|
||||
continue
|
||||
fields = data["fields"]
|
||||
for field in fields:
|
||||
if "name as" in field:
|
||||
fields.remove(field)
|
||||
data["fields"] = fields
|
||||
|
||||
frappe.db.sql("update __ListSettings set data = %s where user=%s and doctype=%s",
|
||||
(json.dumps(data), ls.user, ls.doctype))
|
||||
frappe.db.sql("update __ListSettings set data = %s where user=%s and doctype=%s",
|
||||
(json.dumps(data), ls.user, ls.doctype))
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
from frappe.installer import create_list_settings_table
|
||||
from frappe.model.utils.list_settings import update_list_settings
|
||||
import frappe, json
|
||||
|
||||
def execute():
|
||||
create_list_settings_table()
|
||||
|
||||
for user in frappe.db.get_all('User', {'user_type': 'System User'}):
|
||||
defaults = frappe.defaults.get_defaults_for(user.name)
|
||||
for key, value in defaults.iteritems():
|
||||
if key.startswith('_list_settings:'):
|
||||
doctype = key.replace('_list_settings:', '')
|
||||
columns = ['`tab{1}`.`{0}`'.format(*c) for c in json.loads(value)]
|
||||
|
||||
update_list_settings(doctype, {'fields': columns})
|
||||
|
||||
|
|
@ -1,26 +1,43 @@
|
|||
from frappe.installer import create_user_settings_table
|
||||
from frappe.model.utils.user_settings import update_user_settings
|
||||
import frappe, json
|
||||
|
||||
def execute():
|
||||
for us in frappe.db.sql('''select user, doctype, data from __ListSettings''', as_dict=True):
|
||||
try:
|
||||
data = json.loads(us.data)
|
||||
except:
|
||||
continue
|
||||
if frappe.db.table_exists("__ListSettings"):
|
||||
for us in frappe.db.sql('''select user, doctype, data from __ListSettings''', as_dict=True):
|
||||
try:
|
||||
data = json.loads(us.data)
|
||||
except:
|
||||
continue
|
||||
|
||||
if 'List' in data:
|
||||
continue
|
||||
if 'List' in data:
|
||||
continue
|
||||
|
||||
if 'limit' in data:
|
||||
data['page_length'] = data['limit']
|
||||
del data['limit']
|
||||
if 'limit' in data:
|
||||
data['page_length'] = data['limit']
|
||||
del data['limit']
|
||||
|
||||
new_data = dict(List=data)
|
||||
new_data = json.dumps(new_data)
|
||||
new_data = dict(List=data)
|
||||
new_data = json.dumps(new_data)
|
||||
|
||||
frappe.db.sql('''update __ListSettings
|
||||
set data=%(new_data)s
|
||||
where user=%(user)s
|
||||
and doctype=%(doctype)s''',
|
||||
{'new_data': new_data, 'user': us.user, 'doctype': us.doctype})
|
||||
frappe.db.sql('''update __ListSettings
|
||||
set data=%(new_data)s
|
||||
where user=%(user)s
|
||||
and doctype=%(doctype)s''',
|
||||
{'new_data': new_data, 'user': us.user, 'doctype': us.doctype})
|
||||
|
||||
frappe.db.sql("RENAME TABLE __ListSettings to __UserSettings")
|
||||
frappe.db.sql("RENAME TABLE __ListSettings to __UserSettings")
|
||||
elif not frappe.db.table_exists("__UserSettings"):
|
||||
create_user_settings_table()
|
||||
|
||||
for user in frappe.db.get_all('User', {'user_type': 'System User'}):
|
||||
defaults = frappe.defaults.get_defaults_for(user.name)
|
||||
for key, value in defaults.iteritems():
|
||||
if key.startswith('_list_settings:'):
|
||||
doctype = key.replace('_list_settings:', '')
|
||||
columns = ['`tab{1}`.`{0}`'.format(*c) for c in json.loads(value)]
|
||||
for col in columns:
|
||||
if "name as" in col:
|
||||
columns.remove(col)
|
||||
|
||||
update_user_settings(doctype, {'fields': columns})
|
||||
Loading…
Add table
Reference in a new issue