Changeset 3814

Show
Ignore:
Timestamp:
06/10/08 09:38:16 (7 months ago)
Author:
e2jk
Message:

Conflicting tickets are not detected anymore for closed tickets.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ticketmodifiedfilesplugin/0.11/setup.py

    r3813 r3814  
    44    name='TicketModifiedFiles', 
    55    description='Trac plugin that lists the files that have been modified while resolving a ticket', 
    6     version='0.2', 
     6    version='0.3', 
    77    license='BSD', 
    88    author='Emilien Klein', 
  • ticketmodifiedfilesplugin/0.11/ticketmodifiedfiles/templates/ticketmodifiedfiles.html

    r3805 r3814  
    5555        <py:when test="len(files) > 0 or len(deletedfiles) > 0"> 
    5656          <py:choose> 
    57             <py:when test="len(conflictingtickets) > 0"> 
    58               <h3><span style="text-decoration: underline;">WARNING:</span> ${len(conflictingtickets)} conflicting ticket<py:choose><py:when test="len(conflictingtickets) > 1">s</py:when></py:choose> <py:choose><py:when test="len(conflictingtickets) > 1">have</py:when><py:otherwise>has</py:otherwise></py:choose> been detected:</h3> 
    59               <ul> 
    60                 <li py:for="relticketid, relticketdesc, relticketstatus, relticketowner in conflictingtickets"> 
    61                   <a href="${href.ticket(relticketid)}">#${relticketid}</a> (${relticketdesc}, <span style="text-decoration: underline;">status:</span> ${relticketstatus}, <span style="text-decoration: underline;">owner:</span> ${relticketowner}) 
    62                 </li> 
    63               </ul> 
     57            <py:when test="ticketisclosed == False"> 
     58              <py:choose> 
     59                <py:when test="len(conflictingtickets) > 0"> 
     60                  <h3><span style="text-decoration: underline;">WARNING:</span> ${len(conflictingtickets)} conflicting ticket<py:choose><py:when test="len(conflictingtickets) > 1">s</py:when></py:choose> <py:choose><py:when test="len(conflictingtickets) > 1">have</py:when><py:otherwise>has</py:otherwise></py:choose> been detected:</h3> 
     61                  <ul> 
     62                    <li py:for="relticketid, relticketdesc, relticketstatus, relticketowner in conflictingtickets"> 
     63                      <a href="${href.ticket(relticketid)}">#${relticketid}</a> (${relticketdesc}, <span style="text-decoration: underline;">status:</span> ${relticketstatus}, <span style="text-decoration: underline;">owner:</span> ${relticketowner}) 
     64                    </li> 
     65                  </ul> 
     66                </py:when> 
     67                <py:otherwise> 
     68                  <h3>No conflicting ticket has been detected.</h3> 
     69                </py:otherwise> 
     70              </py:choose> 
    6471            </py:when> 
    6572            <py:otherwise> 
    66               <h3>No conflicting ticket has been detected.</h3> 
     73              <h3>Conflicting tickets are not detected for closed tickets.</h3> 
    6774            </py:otherwise> 
    6875          </py:choose> 
  • ticketmodifiedfilesplugin/0.11/ticketmodifiedfiles/ticketmodifiedfiles.py

    r3812 r3814  
    2828     
    2929    def process_request(self, req): 
    30         (id, files, deletedfiles, ticketsperfile, filestatus, conflictingtickets) = self.__process_ticket_request(req) 
     30        (id, files, deletedfiles, ticketsperfile, filestatus, conflictingtickets, ticketisclosed) = self.__process_ticket_request(req) 
    3131        #Pack the information to send it to the html file 
    32         data = {'ticketid':id, 'files':files, 'deletedfiles':deletedfiles, 'ticketsperfile':ticketsperfile, 'filestatus':filestatus, 'conflictingtickets':conflictingtickets
     32        data = {'ticketid':id, 'files':files, 'deletedfiles':deletedfiles, 'ticketsperfile':ticketsperfile, 'filestatus':filestatus, 'conflictingtickets':conflictingtickets, 'ticketisclosed':ticketisclosed
    3333        add_stylesheet(req, 'tmf/css/ticketmodifiedfiles.css') 
    3434        return 'ticketmodifiedfiles.html', data, None 
     
    6767    def filter_stream(self, req, method, filename, stream, data): 
    6868        if 'modifiedfiles' in data: 
    69             numconflictingtickets = self.__process_ticket_request(req, True) 
    7069            #If there are conflicting tickets, display a warning message 
    71             if numconflictingtickets > 0: 
    72                 text = " There " 
    73                 if numconflictingtickets == 1: text += "is one ticket that is" 
    74                 else: text += "are " + str(numconflictingtickets) + " tickets that are" 
    75                 text += " in conflict with this one!" 
    76                 stream |= Transformer("//div[@id='content']/div[@id='changelog']").before(tag.p(tag.strong("Warning:"), text, style='background: #def; border: 2px solid #00d; padding: 3px;')) 
     70            #Only show the message when the current ticket is not closed 
     71            db = self.env.get_db_cnx() 
     72            cursor = db.cursor() 
     73            cursor.execute("SELECT status FROM ticket WHERE id=" + str(req.args.get('id'))) 
     74            for status, in cursor: 
     75                if status != "closed": 
     76                    numconflictingtickets = self.__process_ticket_request(req, True) 
     77                    if numconflictingtickets > 0: 
     78                        text = " There " 
     79                        if numconflictingtickets == 1: text += "is one ticket that is" 
     80                        else: text += "are " + str(numconflictingtickets) + " tickets that are" 
     81                        text += " in conflict with this one!" 
     82                        stream |= Transformer("//div[@id='content']/div[@id='changelog']").before(tag.p(tag.strong("Warning:"), text, style='background: #def; border: 2px solid #00d; padding: 3px;')) 
    7783             
    7884            #Display the link to this ticket's modifiedfiles page 
     
    154160         
    155161        #Get the global list of conflicting tickets 
     162        #Only if the ticket is not already closed 
    156163        conflictingtickets=[] 
    157         for fn, relticketids in ticketsperfile.items(): 
    158             for relticketid in relticketids: 
    159                 cursor.execute("SELECT summary, status, owner FROM ticket WHERE id=" + str(relticketid)) 
    160                 for summary, status, owner, in cursor: 
    161                     conflictingtickets.append((relticketid, summary, status, owner)) 
     164        cursor.execute("SELECT status FROM ticket WHERE id=" + str(req.args.get('id'))) 
     165        for status, in cursor: 
     166            if status != "closed": 
     167                ticketisclosed = False 
     168                for fn, relticketids in ticketsperfile.items(): 
     169                    for relticketid in relticketids: 
     170                        cursor.execute("SELECT summary, status, owner FROM ticket WHERE id=" + str(relticketid)) 
     171                        for summary, status, owner, in cursor: 
     172                            conflictingtickets.append((relticketid, summary, status, owner)) 
    162173         
    163         #Remove duplicated values 
    164         conflictingtickets = self.__remove_duplicated_elements_and_sort(conflictingtickets) 
     174                #Remove duplicated values 
     175                conflictingtickets = self.__remove_duplicated_elements_and_sort(conflictingtickets) 
     176            else: 
     177                ticketisclosed = True 
    165178         
    166179        #Separate the deleted files from the others 
     
    171184        for deletedfile in deletedfiles: 
    172185            files.remove(deletedfile) 
     186         
     187        #Return only the number of conflicting tickets (if asked for) 
    173188        if justnumconflictingtickets: 
    174189            return len(conflictingtickets) 
    175         return (id, files, deletedfiles, ticketsperfile, filestatus, conflictingtickets) 
     190         
     191        #Return all the needed information 
     192        return (id, files, deletedfiles, ticketsperfile, filestatus, conflictingtickets, ticketisclosed) 
    176193     
    177194    def __remove_duplicated_elements_and_sort(self, list):