class BaseCaseForm(forms.Form): summary = forms.CharField(label="Summary", ) default_tester = UserField(label="Default tester", required=False) requirement = forms.CharField(label="Requirement", required=False) is_automated = forms.BooleanField(initial=False, required=False) script = forms.CharField(label="Script", required=False) arguments = forms.CharField(label="Arguments", required=False) extra_link = StripURLField(label='Extra link', max_length=1024, required=False) # sortkey = forms.IntegerField(label = 'Sortkey', required = False) case_status = forms.ModelChoiceField(label="Case status", queryset=TestCaseStatus.objects.all(), empty_label=None, required=False) priority = forms.ModelChoiceField( label="Priority", queryset=Priority.objects.filter(is_active=True), empty_label=None, ) product = forms.ModelChoiceField( label="Product", queryset=Product.objects.all(), empty_label=None, ) category = forms.ModelChoiceField( label="Category", queryset=Category.objects.none(), empty_label=None, ) notes = forms.CharField(label='Notes', widget=forms.Textarea, required=False) text = forms.CharField( widget=SimpleMDE(), required=False, initial=_("""**Scenario**: ... what behavior will be tested ... **Given** ... conditions ... **When** ... actions ... **Then** ... expected results ... *Actions*: 1. item 2. item 3. item *Expected results*: 1. item 2. item 3. item """)) def populate(self, product_id=None): if product_id: self.fields['category'].queryset = Category.objects.filter( product__id=product_id) else: self.fields['category'].queryset = Category.objects.all()
class BasePlanForm(forms.Form): name = forms.CharField(required=True) type = forms.ModelChoiceField( queryset=PlanType.objects.all(), empty_label=None, ) text = forms.CharField(widget=SimpleMDE(), required=False) product = forms.ModelChoiceField( queryset=Product.objects.all(), empty_label=None, ) product_version = forms.ModelChoiceField( queryset=Version.objects.none(), empty_label=None, ) extra_link = StripURLField(max_length=1024, required=False) parent = forms.IntegerField(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()
class SimpleCommentForm(forms.Form): # pylint: disable=must-inherit-from-model-form """ A simple class for rendering comment forms which could be then manipulated via the JSON-RPC API! """ text = forms.CharField( widget=SimpleMDE(), required=False, )
class TestCaseForm(forms.ModelForm): class Meta: model = TestCase exclude = [ # pylint: disable=modelform-uses-exclude "reviewer", "tag", "component", "plan", ] default_tester = UserField(required=False) priority = forms.ModelChoiceField( queryset=Priority.objects.filter(is_active=True), empty_label=None, ) product = forms.ModelChoiceField( queryset=Product.objects.all(), empty_label=None, ) setup_duration = forms.DurationField( widget=DurationWidget(), required=False, ) testing_duration = forms.DurationField( widget=DurationWidget(), required=False, ) text = forms.CharField( widget=SimpleMDE(), required=False, initial=_( """**Scenario**: ... what behavior will be tested ... **Given** ... conditions ... **When** ... actions ... **Then** ... expected results ... *Actions*: 1. item 2. item 3. item *Expected results*: 1. item 2. item 3. item""" ), ) def populate(self, product_id=None): if product_id: self.fields["category"].queryset = Category.objects.filter( product_id=product_id ) else: self.fields["category"].queryset = Category.objects.all()
class BugCommentForm(forms.Form): bug = forms.ModelChoiceField(queryset=Bug.objects.all(), ) text = forms.CharField( widget=SimpleMDE(), required=False, ) def populate(self, bug_id): self.fields['bug'].queryset = Bug.objects.filter(pk=bug_id)
class BugCommentForm(forms.Form): # pylint: disable=must-inherit-from-model-form bug = forms.ModelChoiceField(queryset=Bug.objects.all(), ) text = forms.CharField( widget=SimpleMDE(), required=False, ) def populate(self, bug_id): self.fields["bug"].queryset = Bug.objects.filter(pk=bug_id)
class NewPlanForm(forms.ModelForm): class Meta: model = TestPlan exclude = ("tag", ) # pylint: disable=modelform-uses-exclude text = forms.CharField(widget=SimpleMDE(), required=False) 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()
class TemplateAdminForm(forms.ModelForm): text = forms.CharField( widget=SimpleMDE(), required=True, ) class Meta: model = Template fields = "__all__" class Media: js = [ "js/jsonrpc.js", ]
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=SimpleMDE(), 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()
class NewBugForm(forms.ModelForm): class Meta: model = Bug fields = [ "summary", "assignee", "reporter", "product", "version", "build" ] assignee = UserField(required=False) text = forms.CharField( widget=SimpleMDE(), required=False, initial=_("""Description of problem: How often reproducible: Steps to Reproduce: 1. 2. 3. Actual results: Expected results: Additional info:"""), ) def populate(self, product_id=None): if product_id: self.fields["version"].queryset = Version.objects.filter( product_id=product_id) self.fields["build"].queryset = Build.objects.filter( version__product=product_id) else: self.fields["version"].queryset = Version.objects.all() self.fields["build"].queryset = Build.objects.all()
class TestCaseForm(forms.ModelForm): class Meta: model = TestCase exclude = [ # pylint: disable=modelform-uses-exclude "reviewer", "tag", "component", "plan", ] default_tester = UserField(required=False) priority = forms.ModelChoiceField( queryset=Priority.objects.filter(is_active=True), empty_label=None, ) product = forms.ModelChoiceField( queryset=Product.objects.all(), empty_label=None, ) setup_duration = forms.DurationField( widget=DurationWidget(), required=False, ) testing_duration = forms.DurationField( widget=DurationWidget(), required=False, ) text = forms.CharField( widget=SimpleMDE(), required=False, ) def populate(self, product_id=None): if product_id: self.fields["category"].queryset = Category.objects.filter( product_id=product_id ) else: self.fields["category"].queryset = Category.objects.all()
class NewBugForm(forms.ModelForm): class Meta: model = Bug fields = [ 'summary', 'assignee', 'reporter', 'product', 'version', 'build' ] text = forms.CharField(widget=SimpleMDE(), required=False, initial=_("""Description of problem: How often reproducible: Steps to Reproduce: 1. 2. 3. Actual results: Expected results: Additional info:""")) def populate(self, product_id=None): if product_id: self.fields['version'].queryset = Version.objects.filter( product_id=product_id) self.fields['build'].queryset = Build.objects.filter( product_id=product_id) else: self.fields['version'].queryset = Version.objects.all() self.fields['build'].queryset = Build.objects.all()
class BaseCaseForm(forms.Form): summary = forms.CharField(label="Summary", ) default_tester = UserField(label="Default tester", required=False) requirement = forms.CharField(label="Requirement", required=False) is_automated = forms.MultipleChoiceField( choices=AUTOMATED_CHOICES, widget=forms.CheckboxSelectMultiple(), ) is_automated_proposed = forms.BooleanField(label='Autoproposed', required=False) script = forms.CharField(label="Script", required=False) arguments = forms.CharField(label="Arguments", required=False) alias = forms.CharField(label="Alias", required=False) extra_link = StripURLField(label='Extra link', max_length=1024, required=False) # sortkey = forms.IntegerField(label = 'Sortkey', required = False) case_status = forms.ModelChoiceField(label="Case status", queryset=TestCaseStatus.objects.all(), empty_label=None, required=False) priority = forms.ModelChoiceField( label="Priority", queryset=Priority.objects.filter(is_active=True), empty_label=None, ) product = forms.ModelChoiceField( label="Product", queryset=Product.objects.all(), empty_label=None, ) category = forms.ModelChoiceField( label="Category", queryset=Category.objects.none(), empty_label=None, ) component = forms.ModelMultipleChoiceField( label="Components", queryset=Component.objects.none(), required=False, ) notes = forms.CharField(label='Notes', widget=forms.Textarea, required=False) setup = forms.CharField(label="Setup", widget=SimpleMDE(), required=False) action = forms.CharField(label="Actions", widget=SimpleMDE(), required=False) effect = forms.CharField(label="Expect results", widget=SimpleMDE(), required=False) breakdown = forms.CharField(label="Breakdown", widget=SimpleMDE(), required=False) def __init__(self, *args, **kwargs): if args: self.notes_val = args[0].get('notes', None) self.script_val = args[0].get('script', None) elif kwargs: self.notes_val = kwargs.get('notes', None) self.script_val = kwargs.get('script', None) else: self.notes_val = '' self.script_val = '' super(BaseCaseForm, self).__init__(*args, **kwargs) def clean_is_automated(self): data = self.cleaned_data['is_automated'] if len(data) == 2: return 2 if data: # FIXME: Should data always be a list? try: return int(data[0]) except ValueError: return data[0] return data def clean_script(self): if self.script_val: return self.cleaned_data['script'] return '' def clean_notes(self): if self.notes_val: return self.cleaned_data['notes'] return '' def populate(self, product_id=None): if product_id: self.fields['category'].queryset = Category.objects.filter( product__id=product_id) self.fields['component'].queryset = Component.objects.filter( product__id=product_id) else: self.fields['category'].queryset = Category.objects.all() self.fields['component'].queryset = Component.objects.all()