Skip to content

Commit 86994c0

Browse files
committed
feat: sanitze release names upon submission
1 parent 1efbb24 commit 86994c0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

downloads/models.py

+14
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,20 @@ def is_version_at_least_3_5(self):
146146
def is_version_at_least_3_9(self):
147147
return self.is_version_at_least((3, 9))
148148

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+
# def clean(self):
157+
# super().clean()
158+
# if not re.match(r'^Python\s[\d.]+$', self.name):
159+
# raise ValidationError({
160+
# 'name': 'Name must be in the format "Python X.Y.Z" (e.g., "Python 3.9.0")'
161+
# })
162+
149163

150164
def update_supernav():
151165
latest_python3 = Release.objects.latest_python3()

0 commit comments

Comments
 (0)