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

Commit 6a5f942

Browse files
Merge pull request #477 from diwash007/year
restrict addition of new year untill gsoc ends
2 parents c1ac667 + 16b45ff commit 6a5f942

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Diff for: gsoc/models.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ def gen_uuid_str():
5555
return str(uuid.uuid4())
5656

5757

58+
def validate_date(value):
59+
gsoc_year = GsocYear.objects.latest('gsoc_year')
60+
try:
61+
end_date = GsocEndDate.objects.get(
62+
date__contains=gsoc_year
63+
)
64+
if end_date.date > datetime.datetime.now().date():
65+
raise ValidationError('Cannot add new year untl GSoC ends!')
66+
except GsocEndDate.DoesNotExist:
67+
pass
68+
69+
5870
def getCreds():
5971
creds = None
6072
if os.path.exists(os.path.join(BASE_DIR, 'token.json')):
@@ -222,7 +234,8 @@ class Meta:
222234
ordering = ["-gsoc_year"]
223235

224236
gsoc_year = models.IntegerField(name="gsoc_year",
225-
primary_key=True)
237+
primary_key=True,
238+
validators=[validate_date])
226239

227240
def __str__(self):
228241
return str(self.gsoc_year)

0 commit comments

Comments
 (0)