From 212b202ed56fd916656dc83b1157ccf1f495301b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20Ka=CC=88ser?= Date: Tue, 11 Aug 2015 21:26:40 +0200 Subject: [PATCH 1/2] show which patterns are allowed --- ipynbsrv/core/models.py | 10 +++++++++- .../web/container_snapshots/modal_create.html | 1 + ipynbsrv/web/templates/web/images/modal_create.html | 1 + ipynbsrv/web/templates/web/shares/modal_create.html | 3 ++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ipynbsrv/core/models.py b/ipynbsrv/core/models.py index 7d48146..bd959b3 100644 --- a/ipynbsrv/core/models.py +++ b/ipynbsrv/core/models.py @@ -772,7 +772,15 @@ class ContainerImage(models.Model): max_length=255, help_text='The primary key the backend uses to identify this image.' ) - name = models.CharField(max_length=75) + name = models.CharField( + max_length=75, + validators=[ + RegexValidator( + regex='^[A-z][\w\/]*$', + message='Invalid container snapshot name.' + ) + ] + ) description = models.TextField(blank=True, null=True) # TODO: document placeholders command = models.CharField( diff --git a/ipynbsrv/web/templates/web/container_snapshots/modal_create.html b/ipynbsrv/web/templates/web/container_snapshots/modal_create.html index d4ada7c..b87aa5e 100644 --- a/ipynbsrv/web/templates/web/container_snapshots/modal_create.html +++ b/ipynbsrv/web/templates/web/container_snapshots/modal_create.html @@ -14,6 +14,7 @@
+

Allowed pattern: ^[A-z]\w*$

diff --git a/ipynbsrv/web/templates/web/images/modal_create.html b/ipynbsrv/web/templates/web/images/modal_create.html index 57417a8..865e5d3 100644 --- a/ipynbsrv/web/templates/web/images/modal_create.html +++ b/ipynbsrv/web/templates/web/images/modal_create.html @@ -22,6 +22,7 @@
+

Allowed pattern: ^[A-z][\w\/]*$

diff --git a/ipynbsrv/web/templates/web/shares/modal_create.html b/ipynbsrv/web/templates/web/shares/modal_create.html index f00134f..c4bb05b 100644 --- a/ipynbsrv/web/templates/web/shares/modal_create.html +++ b/ipynbsrv/web/templates/web/shares/modal_create.html @@ -12,7 +12,8 @@