def filter_components(request, query): """ Description: Performs a search and returns the resulting list of components. Params: $query - Hash: keys must match valid search fields. +------------------------------------------------------------------+ | Component Search Parameters | +------------------------------------------------------------------+ | Key | Valid Values | | id | Integer: ID of product | | name | String | | product | ForeignKey: Product | | initial_owner | ForeignKey: Auth.User | | initial_qa_contact | ForeignKey: Auth.User | | description | String | +------------------------------------------------------------------+ Returns: Array: Matching components are retuned in a list of hashes. Example: # Get all of components named like 'libvirt' >>> Product.filter_components({'name__icontains': 'libvirt'}) # Get all of components named in product 'Red Hat Enterprise Linux 5' >>> Product.filter_components({'product__name': 'Red Hat Enterprise Linux 5'}) """ from nitrate.apps.management.models import Component return Component.to_xmlrpc(query)
def get_components(request, case_id): """" Description: Get the list of components attached to this case. Params: $case_id - Integer/String: An integer representing the ID in the database Returns: Array: An array of component object hashes. Example: >>> TestCase.get_components(12345) """ from nitrate.apps.management.models import Component try: tc = TestCase.objects.get(case_id = case_id) except: raise component_ids = tc.component.values_list('id', flat = True) query = {'id__in': component_ids} return Component.to_xmlrpc(query)
def get_components(request, product): """ Description: Get the list of components associated with this product. Params: $product - Integer/String Integer: product_id of the product in the Database String: Product name Returns: Array: Returns an array of Component objects. Example: # Get with product id >>> Product.get_components(61) # Get with product name >>> Product.get_components('Red Hat Enterprise Linux 5') """ from nitrate.apps.management.models import Component p = pre_check_product(values = product) query = {'product': p} return Component.to_xmlrpc(query)