Skip to content

Commit

Permalink
Merge pull request #44 from PengfeiLi0218/master
Browse files Browse the repository at this point in the history
#43 API Version in new profile must be a required field
  • Loading branch information
simonredfern authored Jan 9, 2019
2 parents 142a79d + d1be896 commit a8384fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion apitester/runtests/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

from django import forms

import random
from .models import TestConfiguration

from django.core.validators import RegexValidator
Expand All @@ -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'
1 change: 1 addition & 0 deletions apitester/runtests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a8384fd

Please sign in to comment.