Ticket #1547: qaowner-r1674.diff
| File qaowner-r1674.diff, 5.6 KB (added by pkou at ua.fm, 7 years ago) |
|---|
-
trac/db_default.py
21 21 22 22 23 23 # Database version identifier. Used for automatic upgrades. 24 db_version = 1 224 db_version = 13 25 25 26 26 def __mkreports(reports): 27 27 """Utility function used to create report data in same syntax as the … … 160 160 Table('component', key='name')[ 161 161 Column('name'), 162 162 Column('owner'), 163 Column('qaowner'), 163 164 Column('description')], 164 165 Table('milestone', key='name')[ 165 166 Column('name'), … … 355 356 # (table, (column1, column2), ((row1col1, row1col2), (row2col1, row2col2))) 356 357 data = (('component', 357 358 ('name', 'owner'), 358 (('component1', 'somebody' ),359 ('component2', 'somebody' ))),359 (('component1', 'somebody', 'qasomebody'), 360 ('component2', 'somebody', 'qasomebody'))), 360 361 ('milestone', 361 362 ('name', 'due', 'completed'), 362 363 (('milestone1', 0, 0), -
trac/scripts/admin.py
319 319 320 320 # ## Component 321 321 _help_component = [('component list', 'Show available components'), 322 ('component add <name> <owner> ', 'Add a new component'),322 ('component add <name> <owner> [<qaowner>]', 'Add a new component'), 323 323 ('component rename <name> <newname>', 'Rename a component'), 324 324 ('component remove <name>', 'Remove/uninstall component'), 325 ('component chown <name> <owner> ', 'Change component ownership')]325 ('component chown <name> <owner> [<qaowner>]', 'Change component ownership')] 326 326 327 327 def complete_component (self, text, line, begidx, endidx): 328 328 if begidx in [16,17]: … … 338 338 try: 339 339 if arg[0] == 'list': 340 340 self._do_component_list() 341 elif arg[0] == 'add' and len(arg) ==3:341 elif arg[0] == 'add' and len(arg) in [3,4]: 342 342 name = arg[1] 343 343 owner = arg[2] 344 self._do_component_add(name, owner) 344 if len(arg) == 4: 345 qaowner = arg[3] 346 else: 347 qaowner = owner 348 self._do_component_add(name, owner, qaowner) 345 349 elif arg[0] == 'rename' and len(arg)==3: 346 350 name = arg[1] 347 351 newname = arg[2] … … 349 353 elif arg[0] == 'remove' and len(arg)==2: 350 354 name = arg[1] 351 355 self._do_component_remove(name) 352 elif arg[0] == 'chown' and len(arg) ==3:356 elif arg[0] == 'chown' and len(arg) in [3,4]: 353 357 name = arg[1] 354 358 owner = arg[2] 355 self._do_component_set_owner(name, owner) 359 if len(arg) == 4: 360 qaowner = arg[3] 361 else: 362 qaowner = owner 363 self._do_component_set_owner(name, owner, qaowner) 356 364 else: 357 365 self.do_help ('component') 358 366 except Exception, e: 359 367 print 'Component %s failed:' % arg[0], e 360 368 361 369 def _do_component_list(self): 362 data = self.db_execsql('SELECT name, owner FROM component')363 self.print_listing(['Name', 'Owner' ], data)370 data = self.db_execsql('SELECT name, owner, qaowner FROM component') 371 self.print_listing(['Name', 'Owner', 'QA Owner'], data) 364 372 365 def _do_component_add(self, name, owner ):366 self.db_execsql("INSERT INTO component (name,owner) VALUES('%s','%s')"367 % (name,owner))373 def _do_component_add(self, name, owner, qaowner): 374 data = self.db_execsql("INSERT INTO component VALUES('%s', '%s', '%s')" 375 % (name,owner,qaowner)) 368 376 369 377 def _do_component_rename(self, name, newname): 370 378 cnx = self.db_open() … … 389 397 data = self.db_execsql("DELETE FROM component WHERE name='%s'" 390 398 % (name)) 391 399 392 def _do_component_set_owner(self, name, owner ):400 def _do_component_set_owner(self, name, owner, qaowner): 393 401 cnx = self.db_open() 394 402 cursor = cnx.cursor () 395 403 cursor.execute('SELECT name FROM component WHERE name=%s', name) 396 404 data = cursor.fetchone() 397 405 if not data: 398 406 raise Exception("No such component '%s'" % name) 399 data = self.db_execsql("UPDATE component SET owner='%s' WHERE name='%s'"400 % (owner, name))407 data = self.db_execsql("UPDATE component SET owner='%s', qaowner='%s' WHERE name='%s'" 408 % (owner,qaowner,name)) 401 409 402 410 403 411 ## Permission -
trac/upgrades/db13.py
1 sql = """ 2 -- Add QA Contact to 'component' 3 CREATE TEMPORARY TABLE component_backup AS SELECT * FROM component; 4 DROP TABLE component; 5 CREATE TABLE component ( 6 name text PRIMARY KEY, 7 owner text, 8 qaowner text, 9 description text 10 ); 11 INSERT INTO component 12 SELECT name, owner, owner AS qaowner, description 13 FROM component_backup; 14 DROP TABLE component_backup; 15 """ 16 17 def do_upgrade(env, ver, cursor): 18 cursor.execute(sql)
