Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.

Commit e7e1020

Browse files
Merge pull request #485 from diwash007/special
add validation on suborg name
2 parents ef0c53e + d9fa786 commit e7e1020

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

gsoc/forms.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import re
12
from PIL import Image
23

34
from .models import (
@@ -121,8 +122,12 @@ def clean(self):
121122

122123
if not suborg and suborg_name:
123124
suborg = SubOrg.objects.filter(suborg_name=suborg_name)
124-
if len(suborg) > 0:
125+
if suborg:
125126
cd["suborg"] = suborg.first()
127+
else:
128+
regex = r'^[ a-zA-Z\-]*$'
129+
if not re.match(regex, suborg_name):
130+
raise ValidationError("Invalid suborg name.")
126131
elif suborg and not suborg_name:
127132
cd["suborg_name"] = suborg.suborg_name
128133
elif suborg and suborg_name:

0 commit comments

Comments
 (0)