def testCharField(self): testfield = forms.CharField( max_length=5, min_length=1) ext_dict = testfield.to_ext_dict('testfield') self.assertIn('maxLength', ext_dict) self.assertIn('minLength', ext_dict) self.assertEqual(ext_dict['maxLength'], 5) self.assertEqual(ext_dict['minLength'], 1)
class QuestionForm(forms.BPMTaskForm): class Meta: title = _('ask a question to a human') description = '' title = forms.CharField(max_length=100, label=_('Title')) description = forms.CharField(max_length=1000, label=_('Description'), required=False) answer = forms.CharField(label=_('Answer')) @classmethod @forms.with_cleaned_data def get_title(self): return self.cleaned_data['title'] @classmethod @forms.with_cleaned_data def get_description(self): return self.cleaned_data['description']
class SubprocessForm(forms.BPMTaskForm): class Meta: title = _('start a subprocess') description = '' workflow = forms.ModelChoiceField(queryset=Workflow.objects.all(), label="Workflow", empty_label=None) name = forms.CharField(max_length=100, label="Name") priority = forms.IntegerField(min_value=0, max_value=9, initial=9, label="Priority")
def testField(self): testfield = forms.CharField( required=False, label='Test field', initial=2, help_text='Test help text') ext_dict = testfield.to_ext_dict('testfield') self.assertIn('name', ext_dict) self.assertIn('xtype', ext_dict) self.assertIn('fieldLabel', ext_dict) self.assertIn('value', ext_dict) #TODO: self.assertTrue('required' in ext_dict) #TODO: self.assertTrue('help_text' in ext_dict) self.assertEqual(ext_dict['name'], 'testfield') self.assertEqual(ext_dict['xtype'], 'textfield') self.assertEqual(ext_dict['fieldLabel'], 'Test field')
class DownloadForm(forms.BPMTaskForm): class Meta: title = _('download a file from a FTP server') description = '' url = forms.CharField(max_length=500, label='url', initial='ftp://')
class TestForm(forms.BPMTaskForm): one = forms.IntegerField() two = forms.CharField()