def test_rename(self): docfield.rename('Event', 'notes', 'notes1') # check in table tf = webnotes.conn.sql("""desc tabEvent""") self.assertTrue('notes' not in [d[0] for d in tf]) self.assertTrue('notes1' in [d[0] for d in tf]) docfield.rename('Event', 'notes1', 'notes')
def test_table_rename(self): docfield.rename('Event', 'event_individuals', 'event_users') self.assertFalse( webnotes.conn.sql( """select parent from `tabEvent User` where parentfield='event_individuals'""" )) self.assertTrue( webnotes.conn.sql( """select parent from `tabEvent User` where parentfield='event_users'""" ))
def review(): """review fields""" start = 0 flist = webnotes.conn.sql("""select t1.name, t1.parent, t1.fieldtype, t1.label, t1.fieldname, t1.options, t1.description from tabDocField t1, tabDocType t2 where t1.fieldtype not in ('Section Break', 'Column Break') and t1.fieldname not in ('address_display', 'contact_display') and t1.parent = t2.name and t2.module != 'Core' and replace(replace(replace(replace(lower(label), ' ', '_'), '-', '_'), ')', ''), '(', '') != fieldname order by parent, label""", as_dict=1) for f in flist[start:]: os.system('clear') print f['parent'] print 'Fieldname: ' + colored(f['fieldname'], 'red') print 'Label:' + f['label'] print 'Description: ' + str(f['description']) print 'Type: ' + str(f['fieldtype']) print 'Options: ' + str(f['options']) print str(start) + '/' + str(len(flist)) action = '' while action != 'n': print '-----------------' action = raw_input("""[n]ext, [f]ieldname, [l]abel, [d]escription, [r]emove, view [c]ode, [q]uit:""") if action=='l': old = f['label'] new = update_field_property(f, 'label') # replace code for search criteria replace_code(old, new) elif action=='d': update_field_property(f, 'description') elif action=='c': print colored('js:', 'green') os.system('grep -r --color --include=*.js "%s" ./' % f['fieldname']) print colored('py:', 'green') os.system('grep -r --color --include=*.py "%s" ./' % f['fieldname']) elif action=='f': old = f['fieldname'] new = update_field_property(f, 'fieldname') if new: # rename in table and parentfield from webnotes.model import docfield docfield.rename(f['parent'], f['fieldname'], new) # replace code replace_code(old, new) # write in fieldname patch file update_fieldname_patch_file([f['parent'], f['fieldname'], new]) elif action=='r': remove_field(f) action = 'n' elif action=='q': return start += 1
def test_table_rename(self): docfield.rename('Event', 'event_individuals', 'event_users') self.assertFalse(webnotes.conn.sql("""select parent from `tabEvent User` where parentfield='event_individuals'""")) self.assertTrue(webnotes.conn.sql("""select parent from `tabEvent User` where parentfield='event_users'"""))