[Cdd-commits] r1204 - in cdd/trunk/webtools: . templates

CDD Subversion Commit noreply at alioth.debian.org
Tue Nov 4 21:38:04 UTC 2008


Author: tille
Date: Tue Nov  4 21:38:04 2008
New Revision: 1204

Modified:
   cdd/trunk/webtools/bugs.py
   cdd/trunk/webtools/templates/bugs.xhtml
   cdd/trunk/webtools/templates/bugs_idx.xhtml
Log:
Sorting bugs according bug number; legend for index - a proper style.css will follow tomorrow


Modified: cdd/trunk/webtools/bugs.py
==============================================================================
--- cdd/trunk/webtools/bugs.py	(original)
+++ cdd/trunk/webtools/bugs.py	Tue Nov  4 21:38:04 2008
@@ -67,6 +67,34 @@
         return "---\npkgname: %s\nsource: %s\nbugs: %s\nnbugs = %i\nseverities = %s\n---" % \
 	    (self.pkgname, self.source, self.bugs, self.nbugs, self.severities)
 
+class BugEntry:
+    # Define a separate class for bug entries to be able to define a reasonably sorting mechanism
+    # It seems that Genshi templates are unable to handle bug objects and so the essential parts
+    # are taken over here in addition to a __cmp__ method to enable easy sorting of list of bugs
+    # Rationale: Calling methods inside the template does not
+    #            seem to work and has to be done in any case to
+    #            circumvent encoding problems
+
+    def __init__(self, bug):
+        self.bug      = bug.getBug()
+	self.summary  = bug.getSummary()
+	self.severity = bug.getSeverity()
+	self.tags     = ''
+
+	komma = ''
+	for t in bug.getTags():
+		self.tags += komma + t
+		komma = ', '
+
+    # sort these objects according to bug number
+    def __cmp__(self, other):
+        # Comparing with None object has to return something reasonable
+        if other == None:
+            return -2
+        # Sort according to package name
+        return cmp(self.bug, other.bug)
+
+
 class PackageBugsOpenAndDone:
     # Store list of bugs of a package
 
@@ -86,30 +114,20 @@
 
 	if bugs:
 		for bug in bugs:
-			# append a complete dictionary instead of a bug object
-			# Rationale: Calling methods inside the template does not
-			#            seem to work and has to be done in any case to
-			#            circumvent encoding problems
-			bugdict = {'bug':      bug.getBug(),
-                                   'summary':  bug.getSummary(),
-				   'severity': bug.getSeverity(),
-				   'tags':     '' 
-                                  }
-			komma = ''
-			for t in bug.getTags():
-				bugdict['tags'] += komma + t
-				komma = ', '
+			bugentry = BugEntry(bug)
 			if bug.getStatus() == 'done':
 				if self.done.pkgname == None:
 					self.done.pkgname = pkgname
-				self.done.bugs.append(bugdict)
+				self.done.bugs.append(bugentry)
 				self.done.nbugs += 1
 			else:
 				if self.open.pkgname == None:
 					self.open.pkgname = pkgname
-				self.open.bugs.append(bugdict)
+				self.open.bugs.append(bugentry)
 				self.open.nbugs += 1
-				self.open.severities[bugdict['severity']] += 1
+				self.open.severities[bugentry.severity] += 1
+		self.open.bugs.sort()
+		self.done.bugs.sort()
 		if source == None:
 			self.open.source = pkgname
 			self.done.source = pkgname
@@ -218,6 +236,14 @@
 else:
 	data['projectadvertising'] = None
 
+data['assessments']     = [ (EXCELLENT,    'excellent'),
+			    (VERYGOOD,     'verygood'),
+                            (GOOD,         'good'),
+                            (SATISFACTORY, 'satisfactory'),
+			    (PASS,         'pass'),
+			    (BAD,          'bad')
+                          ]
+
 nbugs           = {}
 ndone           = {}
 buglist         = {}
@@ -277,24 +303,24 @@
 				# calculate weighted severity for whole metapackage
 				wsev += fac * weight[s] * curbuglist.severities[s]
 			severitysummary[task][cat] = sevsum
-	if wsev < EXCELLENT:
+	if   wsev < data['assessments'][0][0]:
 		weightedsev[task]   = _('Metapackage is in excellent shape')
-		weightedclass[task] = 'excellent'
-	elif wsev < VERYGOOD:
+		weightedclass[task] = data['assessments'][0][1]
+	elif wsev < data['assessments'][1][0]:
 		weightedsev[task]   = _('Metapackage is in very good shape')
-		weightedclass[task] = 'verygood'
-	elif wsev < GOOD:
+		weightedclass[task] = data['assessments'][1][1]
+	elif wsev < data['assessments'][2][0]:
 		weightedsev[task]   = _('Metapackage is in good shape')
-		weightedclass[task] = 'good'
-	elif wsev < SATISFACTORY:
+		weightedclass[task] = data['assessments'][2][1]
+	elif wsev < data['assessments'][3][0]:
 		weightedsev[task]   = _('Consider looking into bugs of this metapackage')
-		weightedclass[task] = 'satisfactory'
-	elif wsev < PASS:
+		weightedclass[task] = data['assessments'][3][1]
+	elif wsev < data['assessments'][4][0]:
 		weightedsev[task]   = _('Looking into bugs of this metapackage is recommended')
-		weightedclass[task] = 'pass'
+		weightedclass[task] = data['assessments'][4][1]
 	else:
 		weightedsev[task]   = _('Immediately looking into bugs of the dependencies of this metapackage is advised')
-		weightedclass[task] = 'bad'
+		weightedclass[task] = data['assessments'][5][1]
 	weightedsev[task] += ' (%i)' % wsev
 	weighttask[task]   = wsev
 

Modified: cdd/trunk/webtools/templates/bugs.xhtml
==============================================================================
--- cdd/trunk/webtools/templates/bugs.xhtml	(original)
+++ cdd/trunk/webtools/templates/bugs.xhtml	Tue Nov  4 21:38:04 2008
@@ -100,9 +100,9 @@
 		</tr>
 		<py:for each="bug in pkgbug.bugs">
 		  <tr>
-		    <td class="bugid ${bug['severity']}"><a href="http://bugs.debian.org/${bug['bug']}">${bug['bug']}</a></td>
-		    <td class="summary ${bug['severity']}">${bug['summary']}</td>
-		    <td class="severity ${bug['severity']}">${bug['tags']}</td>
+		    <td class="bugid ${bug.severity}"><a href="http://bugs.debian.org/${bug.bug}">${bug.bug}</a></td>
+		    <td class="summary ${bug.severity}">${bug.summary}</td>
+		    <td class="severity ${bug.severity}">${bug.tags}</td>
 		  </tr>
 		</py:for>
 	      </span>

Modified: cdd/trunk/webtools/templates/bugs_idx.xhtml
==============================================================================
--- cdd/trunk/webtools/templates/bugs_idx.xhtml	(original)
+++ cdd/trunk/webtools/templates/bugs_idx.xhtml	Tue Nov  4 21:38:04 2008
@@ -27,6 +27,21 @@
 			<div class="sectionTop"></div>
 			<div class="row">${bugssummary}</div>
 		</div>
+		<span class="section">${legend}</span>
+		<div class="section">
+		  <div class="sectionTop"/>
+		  <div class="row">
+		    <table>
+		      <tr><th>Assessment</th><th>Limit</th></tr>
+                      <py:for each="a in assessments">
+                        <tr>
+			  <td class="${a[1]}">${a[1]}</td>
+			  <td class="${a[1]}">${a[0]}</td>
+			</tr>
+                      </py:for>
+		    </table>
+                  </div>
+		</div>
 	</td>
 	<td class="main">
 		<div class="pageBody">
@@ -37,13 +52,24 @@
                                 <dt class="${weightedclass[task]}"><a href="${task}.html" name="${task}" id="${task}">${tasks[task].metapkg.PrintedName.capitalize()} - <span py:choose="">
 	           <span py:when="tasks[task].metapkg.desc.has_key(lang)">${tasks[task].metapkg.desc[lang]['short']}</span>
 	           <span py:otherwise="">${tasks[task].metapkg.desc['en']['short']}</span>
-                 </span></a> (${weighttask[task]})</dt>
+                 </span></a> (${weighttask[task]}<sup>*</sup>)</dt>
 				<dd><span py:choose="">
 	           <span py:when="tasks[task].metapkg.desc.has_key(lang)">${tasks[task].metapkg.desc[lang]['long']}</span>
 	           <span py:otherwise="">${tasks[task].metapkg.desc['en']['long']}</span>
                  </span></dd>
                              </py:for>
 			</dl>
+<div class="footnotecontent">
+  <sup>*</sup>${weightexplanation}
+  <br />
+  ${weightdetails}:
+  <br />
+  <table class="footnotecontent">
+    <py:for each="s in severities">
+      <tr><td class="footnotecontent">${s}</td><td class="footnotecontent">${weight[s]}</td></tr>
+    </py:for>
+  </table>
+</div>
 		</div>
 	</td>
 </tr>



More information about the Cdd-commits mailing list