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=PlanType.objects.all(), required=False, ) env_group = forms.ModelChoiceField(label="Environment Group", queryset=EnvGroup.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): results = [] try: for result in string_to_list(self.cleaned_data['pk__in']): results.append(int(result)) except Exception as error: raise forms.ValidationError(str(error)) return results def clean_tag__name__in(self): return 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()
class BasePlanForm(forms.Form): name = forms.CharField(label="Plan name") type = forms.ModelChoiceField( label="Type", queryset=PlanType.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=EnvGroup.get_active().all(), required=False ) parent = forms.IntegerField(required=False) owner = forms.CharField( label="Plan Document", required=False ) def clean_parent(self): try: parent_pk = self.cleaned_data['parent'] if parent_pk: return TestPlan.objects.get(pk=parent_pk) except TestPlan.DoesNotExist: raise forms.ValidationError('The plan does not exist in database.') return None 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()
def filter(query): """ .. function:: XML-RPC Env.Group.filter(query) Perform a search and return the resulting list of :class:`tcms.management.models.EnvGroup` objects. :param query: Field lookups for :class:`tcms.management.models.EnvGroup` :type query: dict :returns: List of serialized :class:`tcms.management.models.EnvGroup` objects :rtype: list(dict) """ if 'is_active' in query: query['is_active'] = parse_bool_value(query['is_active']) return EnvGroup.to_xmlrpc(query)
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=EnvGroup.get_active().all(), required=False) build = forms.ModelChoiceField( label='Build', queryset=Build.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 = Build.objects.filter( product__pk=product_id) else: self.fields['product_version'].queryset = Version.objects.all() self.fields['build'].queryset = Build.list_active()
class SearchRunForm(forms.Form): """ Includes *only* fields used in search.html b/c the actual search is now done via JSON RPC. """ plan = forms.CharField(required=False) product = forms.ModelChoiceField( queryset=Product.objects.all(), required=False ) product_version = forms.ModelChoiceField( queryset=Version.objects.none(), required=False ) build = forms.ModelChoiceField( label='Build', queryset=Build.objects.none(), required=False, ) default_tester = UserField(required=False) tag__name__in = forms.CharField(required=False) env_group = forms.ModelChoiceField( queryset=EnvGroup.get_active().all(), required=False ) def clean_tag__name__in(self): return 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__pk=product_id ) self.fields['build'].queryset = Build.objects.filter( product__pk=product_id )