|
17 | 17 | from pages.models import Page |
18 | 18 |
|
19 | 19 | from .managers import ReleaseManager |
20 | | - |
| 20 | +from .validators import is_valid_python_release |
21 | 21 |
|
22 | 22 | DEFAULT_MARKUP_TYPE = getattr(settings, 'DEFAULT_MARKUP_TYPE', 'restructuredtext') |
23 | 23 |
|
@@ -50,6 +50,7 @@ class Release(ContentManageable, NameSlugModel): |
50 | 50 | (PYTHON2, 'Python 2.x.x'), |
51 | 51 | (PYTHON1, 'Python 1.x.x'), |
52 | 52 | ) |
| 53 | + name = models.CharField(max_length=200, validators=[is_valid_python_release]) |
53 | 54 | version = models.IntegerField(default=PYTHON3, choices=PYTHON_VERSION_CHOICES) |
54 | 55 | is_latest = models.BooleanField( |
55 | 56 | verbose_name='Is this the latest release?', |
@@ -146,13 +147,6 @@ def is_version_at_least_3_5(self): |
146 | 147 | def is_version_at_least_3_9(self): |
147 | 148 | return self.is_version_at_least((3, 9)) |
148 | 149 |
|
149 | | - def clean(self): |
150 | | - super().clean() |
151 | | - if not re.match(r'^Python\s[\d.]+$', self.name): |
152 | | - raise ValidationError({ |
153 | | - "name": "Release name must be in the format 'Python X.Y.Z' (e.g., 'Python 3.14.0')" |
154 | | - }) |
155 | | - |
156 | 150 |
|
157 | 151 | def update_supernav(): |
158 | 152 | latest_python3 = Release.objects.latest_python3() |
|
0 commit comments