Example #1
0
def filter_groups(request, query):
    """
    Description: Performs a search and returns the resulting list of env groups.

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

    +------------------------------------------------------------------+
    |               Product Search Parameters                          |
    +------------------------------------------------------------------+
    |        Key          |          Valid Values                      |
    | id                  | Integer: ID of env group                   |
    | name                | String                                     |
    | manager             | ForeignKey: Auth.user                      |
    | modified_by         | ForeignKey: Auth.user                      |
    | is_active           | Boolean                                    |
    | property            | ForeignKey: TCMSEnvProperty                |
    +------------------------------------------------------------------+

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

    Example:
    # Get all of env group name contains 'Desktop'
    >>> Env.filter_groups({'name__icontains': 'Desktop'})
    """
    if 'is_active' in query:
        query['is_active'] = parse_bool_value(query['is_active'])
    return TCMSEnvGroup.to_xmlrpc(query)
Example #2
0
class SearchPlanForm(forms.Form):
    pk = forms.IntegerField(required=False)
    pk__in = forms.CharField(required=False)
    parent__pk = forms.IntegerField(required=False)
    search = forms.CharField(label="Search", required=False)
    plan_id = forms.IntegerField(label="Plan ID", required=False)
    name__icontains = forms.CharField(label="Plan name", required=False)
    product = forms.ModelChoiceField(label="Product",
                                     queryset=Product.objects.all(),
                                     required=False)
    product_version = forms.ModelChoiceField(label="Product Version",
                                             queryset=Version.objects.none(),
                                             required=False)
    type = forms.ModelChoiceField(
        label="Type",
        queryset=TestPlanType.objects.all(),
        required=False,
    )
    env_group = forms.ModelChoiceField(
        label="Environment Group",
        queryset=TCMSEnvGroup.get_active().all(),
        required=False)
    author__username__startswith = forms.CharField(required=False)
    author__email__startswith = forms.CharField(required=False)
    owner__username__startswith = forms.CharField(required=False)
    case__default_tester__username__startswith = forms.CharField(
        required=False)
    tag__name__in = forms.CharField(required=False)
    is_active = forms.BooleanField(required=False)
    create_date__gte = forms.DateTimeField(
        label='Create after',
        required=False,
        widget=forms.DateInput(attrs={
            'class': 'vDateField',
        }))
    create_date__lte = forms.DateTimeField(
        label='Create before',
        required=False,
        widget=forms.DateInput(attrs={
            'class': 'vDateField',
        }))

    def clean_pk__in(self):
        from tcms.core.utils import string_to_list

        results = string_to_list(self.cleaned_data['pk__in'])
        try:
            return [int(r) for r in results]
        except Exception as e:
            raise forms.ValidationError(str(e))

    def clean_tag__name__in(self):
        return TestTag.string_to_list(self.cleaned_data['tag__name__in'])

    def populate(self, product_id=None):
        if product_id:
            self.fields['product_version'].queryset = Version.objects.filter(
                product__id=product_id)
        else:
            self.fields['product_version'].queryset = Version.objects.all()
Example #3
0
File: env.py Project: jetlyb/Kiwi
def filter_groups(query):
    """
    .. function:: XML-RPC Env.filter_groups(query)

        Perform a search and return the resulting list of env groups.
        Parameter ``query`` is dict which recognizes the following
        keys:

        :param id: ID of env group
        :type id: int
        :param name: Name of env group
        :type name: str
        :param manager: Manager of this group. ForeignKey!
        :type manager: int or ``settings.AUTH_USER_MODEL`` object
        :param modified_by: Who modified the group. ForeignKey!
        :type modified_by: int or ``settings.AUTH_USER_MODEL`` object
        :param is_active: if this group is active or not
        :type is_active: bool
        :param property: Group property. ForeignKey
        :type property: int or :class:`tcms.management.models.TCMSEnvProperty`
        :returns: List of serialized env groups that match the query
        :rtype: list(dict)

    Query keys support the double-underscore field lookups from Django.
    For example to get all of env group with name containing 'Desktop'::

        >>> Env.filter_groups({'name__icontains': 'Desktop'})
    """
    if 'is_active' in query:
        query['is_active'] = parse_bool_value(query['is_active'])
    return TCMSEnvGroup.to_xmlrpc(query)
Example #4
0
def get_env_groups(request, plan_id):
    """Get the list of env groups to the fields of this plan.

    :param int plan_id: plan ID.
    :return: list of mappings of found :class:`TCMSEnvGroup`.
    :rtype: list[dict]
    """
    from tcms.management.models import TCMSEnvGroup

    query = {'testplan__pk': plan_id}
    return TCMSEnvGroup.to_xmlrpc(query)
Example #5
0
class SearchRunForm(forms.Form):
    search = forms.CharField(required=False)
    summary = forms.CharField(required=False)
    plan = forms.CharField(required=False)
    product = forms.ModelChoiceField(
        queryset=Product.objects.all(),
        required=False
    )
    product_version = forms.ModelChoiceField(
        queryset=Version.objects.none(),
        required=False
    )
    env_group = forms.ModelChoiceField(
        label='Environment Group',
        queryset=TCMSEnvGroup.get_active().all(),
        required=False
    )
    build = forms.ModelChoiceField(
        label='Build',
        queryset=TestBuild.objects.none(),
        required=False,
    )
    people_type = forms.ChoiceField(choices=PEOPLE_TYPE_CHOICES,
                                    required=False)
    people = UserField(required=False)
    manager = UserField(required=False)
    default_tester = UserField(required=False)
    status = forms.ChoiceField(choices=STATUS_CHOICES, required=False)
    tag__name__in = forms.CharField(label='Tag', required=False)
    env_value__value__in = forms.CharField(label='Environment', required=False)

    case_run__assignee = UserField(required=False)

    def clean_tag__name__in(self):
        return string_to_list(self.cleaned_data['tag__name__in'])

    def clean_env_value__value__in(self):
        return string_to_list(self.cleaned_data['env_value__value__in'])

    def populate(self, product_id=None):
        # We can dynamically set choices for a form field:
        # Seen at: http://my.opera.com/jacob7908/blog/2009/06/19/
        #          django-choicefield-queryset (Chinese)
        # Is this documented elsewhere?
        if product_id:
            self.fields['product_version'].queryset = Version.objects.filter(
                product__pk=product_id
            )
            self.fields['build'].queryset = TestBuild.objects.filter(
                product__pk=product_id
            )
        else:
            self.fields['product_version'].queryset = Version.objects.all()
            self.fields['build'].queryset = TestBuild.list_active()
Example #6
0
def get_env_groups(request, plan_id):
    """Get the list of env groups to the fields of this plan.

    :param int plan_id: plan ID.
    :return: list of mappings of found :class:`TCMSEnvGroup`.
    :rtype: list[dict]
    """
    from tcms.management.models import TCMSEnvGroup

    query = {'testplan__pk': plan_id}
    return TCMSEnvGroup.to_xmlrpc(query)
Example #7
0
def get_env_groups(plan_id):
    """
    Description: Get the list of env groups to the fields of this plan.

    Params:      $plan_id - Integer: An integer representing the ID of this plan in the database

    Returns:     Array: An array of hashes with env groups.
    """
    from tcms.management.models import TCMSEnvGroup

    query = {'testplan__pk': plan_id}
    return TCMSEnvGroup.to_xmlrpc(query)
Example #8
0
def get_env_groups(request, plan_id):
    """
    Description: Get the list of env groups to the fields of this plan.

    Params:      $plan_id - Integer: An integer representing the ID of this plan in the database

    Returns:     Array: An array of hashes with env groups.
    """
    from tcms.management.models import TCMSEnvGroup

    query = {'testplan__pk': plan_id}
    return TCMSEnvGroup.to_xmlrpc(query)
Example #9
0
def filter(query):
    """
    .. function:: XML-RPC Env.Group.filter(query)

        Perform a search and return the resulting list of
        :class:`tcms.management.models.TCMSEnvGroup` objects.

        :param query: Field lookups for :class:`tcms.management.models.TCMSEnvGroup`
        :type query: dict
        :returns: List of serialized :class:`tcms.management.models.TCMSEnvGroup` objects
        :rtype: list(dict)
    """
    if 'is_active' in query:
        query['is_active'] = parse_bool_value(query['is_active'])
    return TCMSEnvGroup.to_xmlrpc(query)
Example #10
0
File: forms.py Project: jetlyb/Kiwi
class BasePlanForm(forms.Form):
    name = forms.CharField(label="Plan name")
    type = forms.ModelChoiceField(
        label="Type",
        queryset=TestPlanType.objects.all(),
        empty_label=None,
    )
    text = forms.CharField(label="Plan Document",
                           widget=TinyMCE(),
                           required=False)
    product = forms.ModelChoiceField(
        label="Product",
        queryset=Product.objects.all(),
        empty_label=None,
    )
    product_version = forms.ModelChoiceField(
        label="Product Version",
        queryset=Version.objects.none(),
        empty_label=None,
    )
    extra_link = StripURLField(label='Extra link',
                               max_length=1024,
                               required=False)
    env_group = forms.ModelChoiceField(
        label="Environment Group",
        queryset=TCMSEnvGroup.get_active().all(),
        required=False)
    parent = forms.IntegerField(required=False)

    owner = forms.CharField(label="Plan Document", required=False)

    def clean_parent(self):
        try:
            p = self.cleaned_data['parent']
            if p:
                return TestPlan.objects.get(pk=p)
        except TestPlan.DoesNotExist:
            raise forms.ValidationError('The plan does not exist in database.')

    def populate(self, product_id):
        if product_id:
            self.fields['product_version'].queryset = Version.objects.filter(
                product__id=product_id)
        else:
            self.fields['product_version'].queryset = Version.objects.all()
Example #11
0
def filter_groups(request, query):
    """Performs a search and returns the resulting list of env groups.

    :param dict query: mapping containing following criteria to find out
        envrionment groups.

        * id: (int) environment group ID.
        * name: (str) environment group name.
        * manager: ForeignKey: Auth.user
        * modified_by: ForeignKey: Auth.user
        * is_active: (bool)
        * property: ForeignKey: :class:`TCMSEnvProperty`

    :return: list of mappings of found environment groups.
    :rtype: list

    Example::

        # Get all of env group name contains 'Desktop'
        >>> Env.filter_groups({'name__icontains': 'Desktop'})
    """
    if 'is_active' in query:
        query['is_active'] = parse_bool_value(query['is_active'])
    return TCMSEnvGroup.to_xmlrpc(query)