← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/unused-bugtask-macros into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/unused-bugtask-macros into lp:launchpad.

Commit message:
Remove unused macros from bugtask-macros-tableview.pt, and garbage-collect some methods used only by those macros.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/unused-bugtask-macros/+merge/148085

== Summary ==

I noticed some unreferenced macros in bugtask-macros-tableview.pt.  I think they should be garbage-collected, along with the methods that only they use.  They can always be pulled back out of history if we need them again in the future.

== Tests ==

bin/test -vvct bugs
-- 
https://code.launchpad.net/~cjwatson/launchpad/unused-bugtask-macros/+merge/148085
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/unused-bugtask-macros into lp:launchpad.
=== modified file 'lib/lp/bugs/browser/bugtask.py'
--- lib/lp/bugs/browser/bugtask.py	2013-01-02 04:00:13 +0000
+++ lib/lp/bugs/browser/bugtask.py	2013-02-13 03:58:25 +0000
@@ -3143,74 +3143,6 @@
         else:
             return None
 
-    def getSortLink(self, colname):
-        """Return a link that can be used to sort results by colname."""
-        form = self.request.form
-        sortlink = ""
-        if form.get("search") is None:
-            # There is no search criteria to preserve.
-            sortlink = "%s?search=Search&orderby=%s" % (
-                str(self.request.URL), colname)
-            return sortlink
-
-        # XXX: kiko 2005-08-23:
-        # Is it not possible to get the exact request supplied and
-        # just sneak a "-" in front of the orderby argument, if it
-        # exists? If so, the code below could be a lot simpler.
-
-        # There is search criteria to preserve.
-        sortlink = str(self.request.URL) + "?"
-        for fieldname in form:
-            fieldvalue = form.get(fieldname)
-            if isinstance(fieldvalue, (list, tuple)):
-                fieldvalue = [value.encode("utf-8") for value in fieldvalue]
-            else:
-                fieldvalue = fieldvalue.encode("utf-8")
-
-            if fieldname != "orderby":
-                sortlink += "%s&" % urllib.urlencode(
-                    {fieldname: fieldvalue}, doseq=True)
-
-        sorted, ascending = self._getSortStatus(colname)
-        if sorted and ascending:
-            # If we are currently ascending, revert the direction
-            colname = "-" + colname
-
-        sortlink += "orderby=%s" % colname
-
-        return sortlink
-
-    def getSortedColumnCSSClass(self, colname):
-        """Return a class appropriate for sorted columns"""
-        sorted, ascending = self._getSortStatus(colname)
-        if not sorted:
-            return ""
-        if ascending:
-            return "sorted ascending"
-        return "sorted descending"
-
-    def _getSortStatus(self, colname):
-        """Finds out if the list is sorted by the column specified.
-
-        Returns a tuple (sorted, ascending), where sorted is true if the
-        list is currently sorted by the column specified, and ascending
-        is true if sorted in ascending order.
-        """
-        current_sort_column = self.request.form.get("orderby")
-        if current_sort_column is None:
-            return (False, False)
-
-        ascending = True
-        sorted = True
-        if current_sort_column.startswith("-"):
-            ascending = False
-            current_sort_column = current_sort_column[1:]
-
-        if current_sort_column != colname:
-            sorted = False
-
-        return (sorted, ascending)
-
     def shouldShowTargetName(self):
         """Should the bug target name be displayed in the list of results?
 

=== modified file 'lib/lp/bugs/templates/bugtask-macros-tableview.pt'
--- lib/lp/bugs/templates/bugtask-macros-tableview.pt	2012-12-10 13:43:47 +0000
+++ lib/lp/bugs/templates/bugtask-macros-tableview.pt	2013-02-13 03:58:25 +0000
@@ -2,238 +2,6 @@
   xmlns:tal="http://xml.zope.org/namespaces/tal";
   xmlns:metal="http://xml.zope.org/namespaces/metal";
   omit-tag="">
-<metal:header define-macro="batched-table">
-  <tal:comment replace="nothing">
-  This macro expects the following variables defined:
-      :task_batch_navigator: an IBatchNavigator
-  Optional:
-      :listing_columns: a list of strings specifying columns to display
-  </tal:comment>
-
-  <table class="listing" width="67%"
-         tal:define="tasks task_batch_navigator/batch;
-                     default_columns python:['id', 'title', 'status',
-                                             'importance'];
-                     listing_columns listing_columns|default_columns">
-
-    <thead tal:define="listing_columns listing_columns|default_columns">
-      <tr metal:use-macro="context/@@+bugtask-macros-tableview/batching-header"
-      />
-      <tr metal:use-macro="context/@@+bugtask-macros-tableview/sortable-header"
-      />
-    </thead>
-    <tbody>
-      <tr tal:repeat="task tasks">
-        <metal:item use-macro="context/@@+bugtask-macros-tableview/item" />
-      </tr>
-    </tbody>
-  </table>
-</metal:header>
-
-<metal:header define-macro="table">
-  <tal:comment replace="nothing">
-  This macro expects the following variables defined:
-      :tasks: a list of task instances
-  Optional:
-      :listing_columns: a list of strings specifying columns to display
-  </tal:comment>
-
-  <table class="sortable listing" id="bugtask-table" width="67%"
-         tal:define="default_columns python:['id', 'product-or-package',
-                                             'title', 'status', 'importance'];
-                     listing_columns listing_columns|default_columns">
-    <thead>
-      <tr metal:use-macro="context/@@+bugtask-macros-tableview/header" />
-    </thead>
-    <tbody>
-      <tr tal:repeat="task tasks">
-        <metal:item use-macro="context/@@+bugtask-macros-tableview/item" />
-      </tr>
-    </tbody>
-  </table>
-</metal:header>
-
-<metal:header define-macro="batching-header">
-  <tr class="results">
-    <td
-      tal:attributes="colspan listing_columns/count:len"
-      tal:content="structure task_batch_navigator/@@+navigation-links-upper" />
-  </tr>
-</metal:header>
-
-<metal:header define-macro="sortable-header">
-  <tr>
-    <th tal:condition="python:'select' in listing_columns">
-      Select
-    </th>
-    <th tal:condition="python:'id' in listing_columns"
-        tal:attributes="class python:view.getSortedColumnCSSClass('id')">
-      <a tal:attributes="href python:view.getSortLink('id')">ID</a>
-    </th>
-    <th tal:condition="python:'title' in listing_columns"
-        tal:attributes="class python:view.getSortedColumnCSSClass('title')">
-       <a tal:attributes="href python:view.getSortLink('title')">Title</a>
-    </th>
-    <th tal:condition="python:'package' in listing_columns"
-        tal:attributes="class python:view.getSortedColumnCSSClass('sourcepackagename')">
-      <a tal:attributes="href python:view.getSortLink('sourcepackagename')">
-        Package
-      </a>
-    </th>
-    <th tal:condition="python:'product' in listing_columns"
-        tal:attributes="class python:view.getSortedColumnCSSClass('product')">
-      <a tal:attributes="href python:view.getSortLink('product')">Project</a>
-    </th>
-    <th tal:condition="python:'importance' in listing_columns"
-        tal:attributes="class python:view.getSortedColumnCSSClass('importance')"
-    >
-      <a tal:attributes="href python:view.getSortLink('importance')"
-      >Importance</a>
-    </th>
-    <th tal:condition="python:'assignedto' in listing_columns"
-        tal:attributes="class python:view.getSortedColumnCSSClass('assignee')">
-      <a tal:attributes="href python:view.getSortLink('assignee')">Assignee</a>
-    </th>
-    <th tal:condition="python:'status' in listing_columns"
-        tal:attributes="class python:view.getSortedColumnCSSClass('status')">
-       <a tal:attributes="href python:view.getSortLink('status')">Status</a>
-    </th>
-    <th tal:condition="python:'milestone' in listing_columns"
-        tal:attributes="class python:view.getSortedColumnCSSClass('milestone')">
-       <a tal:attributes="href python:view.getSortLink('milestone')">Target</a>
-    </th>
-    <th tal:condition="python:'submittedon' in listing_columns"
-        tal:attributes="class python:view.getSortedColumnCSSClass('datecreated')"
-    >
-      <a tal:attributes="href python:view.getSortLink('datecreated')"
-      >Reported</a>
-    </th>
-    <th tal:condition="python:'submittedby' in listing_columns"
-        tal:attributes="class python:view.getSortedColumnCSSClass('owner')">
-      <a tal:attributes="href python:view.getSortLink('owner')">Reporter</a>
-    </th>
-  </tr>
-</metal:header>
-
-<metal:header define-macro="header">
-  <tr>
-    <th tal:condition="python:'select' in listing_columns">
-      Select
-    </th>
-    <th tal:condition="python:'id' in listing_columns">
-      ID
-    </th>
-    <th tal:condition="python:'title' in listing_columns">
-       Title
-    </th>
-    <th tal:condition="python:'package' in listing_columns">
-      Package
-    </th>
-    <th tal:condition="python:'product' in listing_columns">
-      Project
-    </th>
-    <th tal:condition="python:'product-or-package' in listing_columns">
-      Target
-    </th>
-    <th tal:condition="python:'importance' in listing_columns">
-      Importance
-    </th>
-    <th tal:condition="python:'assignedto' in listing_columns">
-      Assignee
-    </th>
-    <th tal:condition="python:'status' in listing_columns">
-       Status
-    </th>
-    <th tal:condition="python:'milestone' in listing_columns">
-       Target
-    </th>
-    <th tal:condition="python:'submittedon' in listing_columns">
-      Reported
-    </th>
-    <th tal:condition="python:'submittedby' in listing_columns">
-      Reporter
-    </th>
-  </tr>
-</metal:header>
-
-<metal:header define-macro="item"
-    tal:define="package_name string:${task/distribution/name|string:}
-                                    ${task/distroseries/name|string:}
-                                    ${task/sourcepackagename/name|string:}">
-  <td tal:condition="python:'select' in listing_columns">
-    <input type="checkbox" name="task" value=""
-           tal:attributes="value task/id" />
-  </td>
-  <td tal:condition="python:'id' in listing_columns">
-      <a tal:attributes="href task/fmt:url"
-         tal:content="string:#${task/bug/id}"
-         style="text-decoration: underline">42</a>
-  </td>
-  <td tal:condition="python:'title' in listing_columns"
-       tal:content="task/bug/title">
-       title
-  </td>
-  <td tal:condition="python:'package' in listing_columns"
-      tal:content="python:package_name and package_name or '(none)'">
-       (none)
-  </td>
-  <td tal:condition="python:('product' in listing_columns) and task.product"
-      tal:content="task/product/name_with_project"
-      style="white-space: nowrap" >
-      [project group] project
-  </td>
-  <td tal:condition="python:'product-or-package' in listing_columns">
-
-    <span tal:condition="package_name"
-          tal:content="python:package_name and package_name or '(none)'">
-       (none)
-    </span>
-
-    <span tal:condition="task/product"
-          tal:content="task/product/name_with_project"
-          style="white-space: nowrap" >
-      [project group] project
-    </span>
-
-  </td>
-  <td tal:condition="python:'importance' in listing_columns"
-      tal:content="task/importance/title"
-      tal:attributes="class string:importance${task/importance/title}">
-      Medium
-  </td>
-  <td tal:condition="python:'assignedto' in listing_columns">
-    <a tal:condition="task/assignee"
-       tal:attributes="href task/assignee/fmt:url"
-       tal:content="task/assignee/displayname">
-      somebody
-    </a>
-    <span tal:condition="not: task/assignee">
-    -
-    </span>
-  </td>
-  <td tal:condition="python:'status' in listing_columns"
-       tal:content="task/status/title"
-       tal:attributes="class string:status${task/status/name}">
-       New
-  </td>
-  <td tal:condition="python:'milestone' in listing_columns"
-       tal:content="task/milestone/name|string:-">
-       milestone
-  </td>
-  <td tal:condition="python:'submittedon' in listing_columns">
-    <span
-      tal:attributes="title task/datecreated/fmt:datetime"
-      tal:content="task/datecreated/fmt:displaydate">
-       date
-    </span>
-  </td>
-  <td tal:condition="python:'submittedby' in listing_columns"
-       tal:content="task/owner/displayname|string:-">
-       name
-  </td>
-</metal:header>
-
-
 <metal:advanced_search_form define-macro="advanced_search_form">
 
   <form class="long" name="search" method="get" action="">

=== modified file 'lib/lp/registry/interfaces/product.py'
--- lib/lp/registry/interfaces/product.py	2012-12-20 16:08:13 +0000
+++ lib/lp/registry/interfaces/product.py	2013-02-13 03:58:25 +0000
@@ -670,10 +670,6 @@
                 'series branch.')))
     development_focusID = Attribute("The development focus ID.")
 
-    name_with_project = Attribute(_("Returns the product name prefixed "
-        "by the project name, if a project is associated with this "
-        "product; otherwise, simply returns the product name."))
-
     releases = exported(
         doNotSnapshot(
             CollectionField(

=== modified file 'lib/lp/registry/model/product.py'
--- lib/lp/registry/model/product.py	2013-02-07 06:10:38 +0000
+++ lib/lp/registry/model/product.py	2013-02-13 03:58:25 +0000
@@ -1167,13 +1167,6 @@
         return DecoratedResultSet(result, decorate)
 
     @property
-    def name_with_project(self):
-        """See `IProduct`"""
-        if self.project and self.project.name != self.name:
-            return self.project.name + ": " + self.name
-        return self.name
-
-    @property
     def releases(self):
         store = Store.of(self)
         origin = [

=== modified file 'lib/lp/registry/tests/test_product.py'
--- lib/lp/registry/tests/test_product.py	2013-02-07 06:10:38 +0000
+++ lib/lp/registry/tests/test_product.py	2013-02-13 03:58:25 +0000
@@ -853,7 +853,7 @@
             'homepageurl', 'invitesTranslationEdits',
             'invitesTranslationSuggestions',
             'license_info', 'license_status', 'licenses', 'milestones',
-            'mugshot', 'name_with_project', 'newCodeImport',
+            'mugshot', 'newCodeImport',
             'obsolete_translatable_series', 'official_bug_tags',
             'packagedInDistros', 'packagings',
             'past_sprints', 'personHasDriverRights', 'pillar',