コード例 #1
0
def filter_versions(request, query):
    """
    Description: Performs a search and returns the resulting list of versions.

    Params:      $query - Hash: keys must match valid search fields.

    +------------------------------------------------------------------+
    |              Component Search Parameters                         |
    +------------------------------------------------------------------+
    |        Key          |          Valid Values                      |
    | id                  | Integer: ID of product                     |
    | value               | String                                     |
    | product             | ForeignKey: Product                        |
    +------------------------------------------------------------------+

    Returns:     Array: Matching versions are retuned in a list of hashes.

    Example:
    # Get all of versions named like '2.4.0-SNAPSHOT'
    >>> Product.filter_versions({'value__icontains': '2.4.0-SNAPSHOT'})
    # Get all of filter_versions named in product 'Red Hat Enterprise Linux 5'
    >>> Product.filter_versions({'product__name': 'Red Hat Enterprise Linux 5'})
    """
    from nitrate.apps.management.models import Version
    return Version.to_xmlrpc(query)
コード例 #2
0
def get_versions(request, product):
    """
    Description: Get the list of versions 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 Version objects.

    Example:
    # Get with product id
    >>> Product.get_runs(61)
    # Get with product name
    >>> Product.get_runs('Red Hat Enterprise Linux 5')
    """
    from nitrate.apps.management.models import Version
    p = pre_check_product(values = product)
    query = {'product': p}
    return Version.to_xmlrpc(query)