Skip to content

Commit 5fce9e1

Browse files
author
Alvise
committed
❇️ add control for the url config
1 parent f048f8f commit 5fce9e1

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

src/vng/testsession/models.py

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,41 @@ def get_json_obj(self):
105105
class VNGEndpoint(models.Model):
106106

107107
port = models.PositiveIntegerField(default=8080, blank=True)
108-
url = models.URLField(max_length=200, blank=True, null=True, default=None,
109-
help_text='Base url (host of the service). E.g. http://ref.tst.vng.cloud, without the ending slash.')
110-
path = models.CharField(max_length=200, default='',
111-
help_text='Path url that is appended in the front end page. The path must contain the slash at \
112-
the beginning. E.g. /zrc/api/v1/', blank=True)
108+
url = models.URLField(
109+
max_length=200,
110+
blank=True,
111+
null=True,
112+
default=None,
113+
validators=[
114+
RegexValidator(
115+
regex='/$',
116+
message=_('The url must not contain a final slash'),
117+
code='Invalid_url',
118+
inverse_match=True
119+
)
120+
],
121+
help_text=_('Base url (host of the service). E.g. http://ref.tst.vng.cloud, without the ending slash.')
122+
)
123+
path = models.CharField(
124+
max_length=200,
125+
default='',
126+
validators=[
127+
RegexValidator(
128+
regex='^/',
129+
message=_('The path must start with a slash'),
130+
code='Invalid_path',
131+
)
132+
],
133+
help_text=_('Path url that is appended in the front end page. The path must contain the slash at \
134+
the beginning. E.g. /zrc/api/v1/'),
135+
blank=True
136+
)
113137
name = models.CharField(
114138
max_length=200,
115139
validators=[
116140
RegexValidator(
117141
regex='^[^ ]*$',
118-
message='The name cannot contain spaces',
142+
message=_('The name cannot contain spaces'),
119143
code='Invalid_name'
120144
)
121145
]

0 commit comments

Comments
 (0)