Edgewall Software

Ticket #1547: qaowner-r1674.diff

File qaowner-r1674.diff, 5.6 KB (added by pkou at ua.fm, 7 years ago)

Patch for the changes

  • trac/db_default.py

     
    2121 
    2222 
    2323# Database version identifier. Used for automatic upgrades. 
    24 db_version = 12 
     24db_version = 13 
    2525 
    2626def __mkreports(reports): 
    2727    """Utility function used to create report data in same syntax as the 
     
    160160    Table('component', key='name')[ 
    161161        Column('name'), 
    162162        Column('owner'), 
     163        Column('qaowner'), 
    163164        Column('description')], 
    164165    Table('milestone', key='name')[ 
    165166        Column('name'), 
     
    355356# (table, (column1, column2), ((row1col1, row1col2), (row2col1, row2col2))) 
    356357data = (('component', 
    357358             ('name', 'owner'), 
    358                (('component1', 'somebody'), 
    359                 ('component2', 'somebody'))), 
     359               (('component1', 'somebody', 'qasomebody'), 
     360                ('component2', 'somebody', 'qasomebody'))), 
    360361           ('milestone', 
    361362             ('name', 'due', 'completed'), 
    362363               (('milestone1', 0, 0), 
  • trac/scripts/admin.py

     
    319319 
    320320#    ## Component 
    321321    _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'), 
    323323                       ('component rename <name> <newname>', 'Rename a component'), 
    324324                       ('component remove <name>', 'Remove/uninstall component'), 
    325                        ('component chown <name> <owner>', 'Change component ownership')] 
     325                       ('component chown <name> <owner> [<qaowner>]', 'Change component ownership')] 
    326326 
    327327    def complete_component (self, text, line, begidx, endidx): 
    328328        if begidx in [16,17]: 
     
    338338        try: 
    339339            if arg[0]  == 'list': 
    340340                self._do_component_list() 
    341             elif arg[0] == 'add' and len(arg)==3: 
     341            elif arg[0] == 'add' and len(arg) in [3,4]: 
    342342                name = arg[1] 
    343343                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) 
    345349            elif arg[0] == 'rename' and len(arg)==3: 
    346350                name = arg[1] 
    347351                newname = arg[2] 
     
    349353            elif arg[0] == 'remove'  and len(arg)==2: 
    350354                name = arg[1] 
    351355                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]: 
    353357                name = arg[1] 
    354358                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) 
    356364            else:     
    357365                self.do_help ('component') 
    358366        except Exception, e: 
    359367            print 'Component %s failed:' % arg[0], e 
    360368 
    361369    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) 
    364372 
    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)) 
    368376 
    369377    def _do_component_rename(self, name, newname): 
    370378        cnx = self.db_open() 
     
    389397        data = self.db_execsql("DELETE FROM component WHERE name='%s'" 
    390398                               % (name)) 
    391399 
    392     def _do_component_set_owner(self, name, owner): 
     400    def _do_component_set_owner(self, name, owner, qaowner): 
    393401        cnx = self.db_open() 
    394402        cursor = cnx.cursor () 
    395403        cursor.execute('SELECT name FROM component WHERE name=%s', name) 
    396404        data = cursor.fetchone() 
    397405        if not data: 
    398406            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)) 
    401409 
    402410 
    403411    ## Permission 
  • trac/upgrades/db13.py

     
     1sql = """ 
     2-- Add QA Contact to 'component' 
     3CREATE TEMPORARY TABLE component_backup AS SELECT * FROM component; 
     4DROP TABLE component; 
     5CREATE TABLE component ( 
     6         name            text PRIMARY KEY, 
     7         owner           text, 
     8         qaowner         text, 
     9         description     text 
     10); 
     11INSERT INTO component 
     12  SELECT name, owner, owner AS qaowner, description 
     13  FROM component_backup; 
     14DROP TABLE component_backup; 
     15""" 
     16 
     17def do_upgrade(env, ver, cursor): 
     18    cursor.execute(sql)