diff --git a/erpnext/patches/jan_mar_2012/website/getfile_rename.py b/erpnext/patches/jan_mar_2012/website/getfile_rename.py index 8f7cede659..15aa8157e6 100644 --- a/erpnext/patches/jan_mar_2012/website/getfile_rename.py +++ b/erpnext/patches/jan_mar_2012/website/getfile_rename.py @@ -23,17 +23,23 @@ def execute(): txt = get_file_id(txt) webnotes.conn.sql("""update `tab%s` set %s=%s where name=%s""" % \ - (table[0], table[1], '%s', '%s'), (txt, item[0]), debug=1) + (table[0], table[1], '%s', '%s'), (txt, item[0])) # control panel, client name txt = webnotes.conn.get_value('Control Panel',None,'client_name') - txt = get_file_id(txt) - webnotes.conn.set_value('Control Panel', None, 'client_name', txt.replace('index.cgi?cmd=get_file&fname=', 'files/')) - + if txt: + txt = get_file_id(txt) + webnotes.conn.set_value('Control Panel', None, 'client_name', txt.replace('index.cgi?cmd=get_file&fname=', 'files/')) + def get_file_id(txt): """old file links may be from fileid or filename""" import re match = re.search('files/([^"\']*)', txt) + + if not match: + print txt + return txt + fname = match.groups()[0] if not fname.startswith('FileData'): fid = webnotes.conn.sql("""select name from `tabFile Data` @@ -41,4 +47,4 @@ def get_file_id(txt): if fid: fid = fid[0][0].replace('/', '-') txt = txt.replace(fname, fid) - return txt \ No newline at end of file + return txt diff --git a/erpnext/startup/event_handlers.py b/erpnext/startup/event_handlers.py index b6b1f9f258..9740be4880 100644 --- a/erpnext/startup/event_handlers.py +++ b/erpnext/startup/event_handlers.py @@ -7,7 +7,7 @@ def on_login(login_manager): """ called from login manager, before login """ - if login_manager.user not in ('Guest', None, ''): + if login_manager.user not in ('Guest', None, '') and webnotes.conn.cur_db_name!='accounts' and webnotes.conn.get_value('Control Panel', 'Control Panel', 'account_id')!='s5u011': try: login_manager = login_as(login_manager) update_account_details() @@ -32,7 +32,7 @@ def on_login_post_session(login_manager): sid!=%s""", \ (webnotes.session['user'], webnotes.session['sid']), as_list=1) - if webnotes.session['user'] not in ('Guest'): + if webnotes.session['user'] not in ('Guest') and webnotes.conn.cur_db_name!='accounts': # create feed from webnotes.utils import nowtime home.make_feed('Login', 'Profile', login_manager.user, login_manager.user,