def filter(query): """ Description: Performs a search and returns the resulting list of products. Params: $query - Hash: keys must match valid search fields. TODO: query keys match the product class +------------------------------------------------------------------+ | Product Search Parameters | +------------------------------------------------------------------+ | Key | Valid Values | | id | Integer: ID of product | | name | String | | classification | ForeignKey: Classfication | | description | String | +------------------------------------------------------------------+ Returns: Array: Matching products are retuned in a list of hashes. Example: # Get all of product named 'Red Hat Enterprise Linux 5' >>> Product.filter({'name': 'Red Hat Enterprise Linux 5'}) """ return Product.to_xmlrpc(query)
def filter(query): # pylint: disable=redefined-builtin """ .. function:: XML-RPC Product.filter(query) Perform a search and return the resulting list of products. :param query: Field lookups for :class:`tcms.management.models.Product` :type query: dict :return: Serialized list of :class:`tcms.management.models.Product` objects :rtype: dict Example:: # Get all of products named 'Red Hat Enterprise Linux 5' >>> Product.filter({'name': 'Red Hat Enterprise Linux 5'}) """ return Product.to_xmlrpc(query)
def get_product(plan_id): """ Description: Get the Product the plan is assiciated with. Params: $plan_id - Integer: An integer representing the ID of the plan in the database. Returns: Hash: A blessed Product hash. Example: >>> TestPlan.get_product(137) """ products = Product.objects.filter(plan=plan_id) products = products.select_related('classification') products = products.defer('classification__description') if len(products) == 0: raise Product.DoesNotExist('Product matching query does not exist') else: return products[0].serialize()
def filter(request, query): """Performs a search and returns the resulting list of products. :param dict query: a mapping containing following criteria. * id: (int) product id. * name: (str) product name. * classification: ForeignKey: :class:`Classification`. * description: (str) description. :return: a mapping representing a :class:`Product`. :rtype: dict Example:: # Get all of product named 'product name' >>> Product.filter({'name': 'product name'}) """ return Product.to_xmlrpc(query)
def filter(request, query): """Performs a search and returns the resulting list of products. :param dict query: a mapping containing following criteria. * id: (int) product id. * name: (str) product name. * classification: ForeignKey: :class:`Classification`. * description: (str) description. :return: a mapping representing a :class:`Product`. :rtype: dict Example:: # Get all of product named 'product name' >>> Product.filter({'name': 'product name'}) """ return Product.to_xmlrpc(query)
def filter(request, query): """ Description: Performs a search and returns the resulting list of products. Params: $query - Hash: keys must match valid search fields. +------------------------------------------------------------------+ | Product Search Parameters | +------------------------------------------------------------------+ | Key | Valid Values | | id | Integer: ID of product | | name | String | | classification | ForeignKey: Classfication | | description | String | +------------------------------------------------------------------+ Returns: Array: Matching products are retuned in a list of hashes. Example: # Get all of product named 'Red Hat Enterprise Linux 5' >>> Product.filter({'name': 'Red Hat Enterprise Linux 5'}) """ return Product.to_xmlrpc(query)