Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion downloads/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from pages.models import Page

from .managers import ReleaseManager

from .validators import is_valid_python_release

DEFAULT_MARKUP_TYPE = getattr(settings, 'DEFAULT_MARKUP_TYPE', 'restructuredtext')

Expand Down Expand Up @@ -50,6 +50,7 @@ class Release(ContentManageable, NameSlugModel):
(PYTHON2, 'Python 2.x.x'),
(PYTHON1, 'Python 1.x.x'),
)
name = models.CharField(max_length=200, validators=[is_valid_python_release])
version = models.IntegerField(default=PYTHON3, choices=PYTHON_VERSION_CHOICES)
is_latest = models.BooleanField(
verbose_name='Is this the latest release?',
Expand Down
9 changes: 9 additions & 0 deletions downloads/validators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Model valdators for the DOwnloads app."""

from django.core.exceptions import ValidationError
from django.core import validators

is_valid_python_release = validators.RegexValidator(
regex=r'^Python\s[\d.]+$',
message="Release name must be in the format 'Python X.Y.Z' (e.g., 'Python 3.14.0')"
)
Loading