diff options
Diffstat (limited to 'bitbake/lib/toaster/orm/models.py')
-rw-r--r-- | bitbake/lib/toaster/orm/models.py | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index 3c7f6611dc..309f8ea5be 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py | |||
@@ -24,6 +24,28 @@ from django.db.models import F | |||
24 | from django.utils.encoding import python_2_unicode_compatible | 24 | from django.utils.encoding import python_2_unicode_compatible |
25 | from django.utils import timezone | 25 | from django.utils import timezone |
26 | 26 | ||
27 | |||
28 | from django.core import validators | ||
29 | |||
30 | class GitURLValidator(validators.URLValidator): | ||
31 | import re | ||
32 | regex = re.compile( | ||
33 | r'^(?:ssh|git|http|ftp)s?://' # http:// or https:// | ||
34 | r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' # domain... | ||
35 | r'localhost|' # localhost... | ||
36 | r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|' # ...or ipv4 | ||
37 | r'\[?[A-F0-9]*:[A-F0-9:]+\]?)' # ...or ipv6 | ||
38 | r'(?::\d+)?' # optional port | ||
39 | r'(?:/?|[/?]\S+)$', re.IGNORECASE) | ||
40 | |||
41 | def GitURLField(**kwargs): | ||
42 | r = models.URLField(**kwargs) | ||
43 | for i in xrange(len(r.validators)): | ||
44 | if isinstance(r.validators[i], validators.URLValidator): | ||
45 | r.validators[i] = GitURLValidator() | ||
46 | return r | ||
47 | |||
48 | |||
27 | class ToasterSetting(models.Model): | 49 | class ToasterSetting(models.Model): |
28 | name = models.CharField(max_length=63) | 50 | name = models.CharField(max_length=63) |
29 | helptext = models.TextField() | 51 | helptext = models.TextField() |
@@ -663,8 +685,9 @@ class LayerIndexLayerSource(LayerSource): | |||
663 | pass | 685 | pass |
664 | 686 | ||
665 | class BitbakeVersion(models.Model): | 687 | class BitbakeVersion(models.Model): |
688 | |||
666 | name = models.CharField(max_length=32, unique = True) | 689 | name = models.CharField(max_length=32, unique = True) |
667 | giturl = models.URLField() | 690 | giturl = GitURLField() |
668 | branch = models.CharField(max_length=32) | 691 | branch = models.CharField(max_length=32) |
669 | dirpath = models.CharField(max_length=255) | 692 | dirpath = models.CharField(max_length=255) |
670 | 693 | ||
@@ -708,7 +731,7 @@ class Layer(models.Model): | |||
708 | name = models.CharField(max_length=100) | 731 | name = models.CharField(max_length=100) |
709 | local_path = models.FilePathField(max_length=255, null = True, default = None) | 732 | local_path = models.FilePathField(max_length=255, null = True, default = None) |
710 | layer_index_url = models.URLField() | 733 | layer_index_url = models.URLField() |
711 | vcs_url = models.URLField(default = None, null = True) | 734 | vcs_url = GitURLField(default = None, null = True) |
712 | vcs_web_file_base_url = models.URLField(null = True, default = None) | 735 | vcs_web_file_base_url = models.URLField(null = True, default = None) |
713 | 736 | ||
714 | summary = models.CharField(max_length=200, help_text='One-line description of the layer', null = True, default = None) | 737 | summary = models.CharField(max_length=200, help_text='One-line description of the layer', null = True, default = None) |