launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #13463
[Merge] lp:~abentley/launchpad/product-specifications-storm into lp:launchpad
Aaron Bentley has proposed merging lp:~abentley/launchpad/product-specifications-storm into lp:launchpad with lp:~abentley/launchpad/product-specifications-tests as a prerequisite.
Commit message:
Reimplement Product.specifications.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~abentley/launchpad/product-specifications-storm/+merge/130002
= Summary =
Make it easy to implement privacy for Product.specifications.
== Proposed fix ==
Reimplement Product.specifications in terms of get_specification_filters.
== Pre-implementation notes ==
None.
== LOC Rationale ==
Part of Private Products.
== Implementation details ==
None
== Tests ==
bin/test test_product.py -t TestSpecifications
== Demo and Q/A ==
None
= Launchpad lint =
Checking for conflicts and issues in changed files.
Linting changed files:
lib/lp/testing/factory.py
lib/lp/blueprints/model/specification.py
lib/lp/blueprints/model/sprint.py
lib/lp/registry/model/product.py
lib/lp/registry/model/person.py
lib/lp/registry/tests/test_person.py
lib/lp/registry/tests/test_product.py
--
https://code.launchpad.net/~abentley/launchpad/product-specifications-storm/+merge/130002
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~abentley/launchpad/product-specifications-storm into lp:launchpad.
=== modified file 'lib/lp/registry/model/product.py'
--- lib/lp/registry/model/product.py 2012-10-16 14:28:22 +0000
+++ lib/lp/registry/model/product.py 2012-10-16 22:26:30 +0000
@@ -92,11 +92,10 @@
)
from lp.app.model.launchpad import InformationTypeMixin
from lp.blueprints.enums import (
- SpecificationDefinitionStatus,
SpecificationFilter,
- SpecificationImplementationStatus,
)
from lp.blueprints.model.specification import (
+ get_specification_filters,
HasSpecificationsMixin,
Specification,
SPECIFICATION_POLICY_ALLOWED_TYPES,
@@ -193,7 +192,6 @@
)
from lp.services.database.lpstorm import IStore
from lp.services.database.sqlbase import (
- quote,
SQLBase,
sqlvalues,
)
@@ -1357,47 +1355,9 @@
# - completeness.
# - informational.
#
- base = 'Specification.product = %s' % self.id
- query = base
- # look for informational specs
- if SpecificationFilter.INFORMATIONAL in filter:
- query += (' AND Specification.implementation_status = %s' %
- quote(SpecificationImplementationStatus.INFORMATIONAL))
-
- # filter based on completion. see the implementation of
- # Specification.is_complete() for more details
- completeness = Specification.completeness_clause
-
- if SpecificationFilter.COMPLETE in filter:
- query += ' AND ( %s ) ' % completeness
- elif SpecificationFilter.INCOMPLETE in filter:
- query += ' AND NOT ( %s ) ' % completeness
-
- # Filter for validity. If we want valid specs only then we should
- # exclude all OBSOLETE or SUPERSEDED specs
- if SpecificationFilter.VALID in filter:
- query += (' AND Specification.definition_status NOT IN '
- '( %s, %s ) ' % sqlvalues(
- SpecificationDefinitionStatus.OBSOLETE,
- SpecificationDefinitionStatus.SUPERSEDED))
-
- # ALL is the trump card
- if SpecificationFilter.ALL in filter:
- query = base
-
- # Filter for specification text
- for constraint in filter:
- if isinstance(constraint, basestring):
- # a string in the filter is a text search filter
- query += ' AND Specification.fti @@ ftq(%s) ' % quote(
- constraint)
-
- if prejoin_people:
- results = self._preload_specifications_people(query)
- else:
- results = Store.of(self).find(
- Specification,
- SQL(query))
+ clauses = [Specification.product == self]
+ clauses.extend(get_specification_filters(filter))
+ results = Store.of(self).find(Specification, *clauses)
results.order_by(order)
if quantity is not None:
results = results[:quantity]
Follow ups