Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 077f164

Browse files
author
Stephen Toon
committed
Updated release API to use same regex as the version validation.
1 parent bd1bde2 commit 077f164

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

project_manager/common/api/views/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
ProjectRelatedInfoMixin,
2424
ProjectThroughModelMixin,
2525
)
26+
from project_manager.common.constants import RELEASE_VERSION_REGEX
2627

2728

2829
# =============================================================================
@@ -187,7 +188,7 @@ class ProjectReleaseViewSet(ProjectRelatedInfoMixin):
187188
http_method_names = ('get', 'post', 'options')
188189
ordering = ('-created',)
189190
ordering_fields = ('created',)
190-
lookup_value_regex = '[0-9.]+'
191+
lookup_value_regex = RELEASE_VERSION_REGEX
191192
lookup_field = 'version'
192193

193194
api_type = 'Releases'

project_manager/common/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
'RELEASE_NOTES_MAX_LENGTH',
3333
'RELEASE_URL',
3434
'RELEASE_VERSION_MAX_LENGTH',
35+
'RELEASE_VERSION_REGEX',
3536
'VCS_REQUIREMENT_TYPES',
3637
)
3738

@@ -48,6 +49,7 @@
4849
PROJECT_SYNOPSIS_MAX_LENGTH = 128
4950
RELEASE_NOTES_MAX_LENGTH = 512
5051
RELEASE_VERSION_MAX_LENGTH = 8
52+
RELEASE_VERSION_REGEX = r'[0-9][0-9a-z.]*[0-9a-z]'
5153

5254
# Base URL for project thread
5355
FORUM_THREAD_URL = settings.FORUM_URL + 'viewtopic.php?t={topic}'

project_manager/common/validators.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
# Django
77
from django.core.validators import RegexValidator
88

9+
# App
10+
from project_manager.common.constants import RELEASE_VERSION_REGEX
11+
912

1013
# =============================================================================
1114
# >> ALL DECLARATION
@@ -29,4 +32,4 @@
2932
# Start with a number.
3033
# Contain only numbers, lower-case characters, and decimals.
3134
# End in a number or lower-case character.
32-
version_validator = RegexValidator(r'^[0-9][0-9a-z.]*[0-9a-z]')
35+
version_validator = RegexValidator(r'^' + RELEASE_VERSION_REGEX)

0 commit comments

Comments
 (0)