diff --git a/apitester/runtests/forms.py b/apitester/runtests/forms.py index 464aae8..dea4326 100644 --- a/apitester/runtests/forms.py +++ b/apitester/runtests/forms.py @@ -4,7 +4,7 @@ """ from django import forms - +import random from .models import TestConfiguration from django.core.validators import RegexValidator @@ -20,13 +20,19 @@ class Meta: validators=[RegexValidator(r'^\d\.\d\.\d$', 'Please Input correct api_version like 3.1.0')], widget=forms.TextInput( attrs={ + 'value': '3.1.0', 'placeholder': '3.1.0', 'class': 'form-control', } ), required=False, ) + def __init__(self, *args, **kwargs): super(TestConfigurationForm, self).__init__(*args, **kwargs) for field_name, field in self.fields.items(): + if field_name == 'name': + profile_key = int(random.random() * 10000000) + field.widget.attrs['value'] = 'Profile{}'.format(profile_key) + field.widget.attrs['placeholder'] = 'Profile{}'.format(profile_key) field.widget.attrs['class'] = 'form-control' diff --git a/apitester/runtests/models.py b/apitester/runtests/models.py index 0e7a334..cee3a26 100644 --- a/apitester/runtests/models.py +++ b/apitester/runtests/models.py @@ -11,6 +11,7 @@ class TestConfiguration(models.Model): name = models.CharField( max_length=255, verbose_name='Name', + unique=True, help_text='Name of the configuration', blank=False, null=False,