Skip to content

Commit

Permalink
Additions to cycle creation logic (#604)
Browse files Browse the repository at this point in the history
* Additions to cycle creation logic

* make test cases happy

* UI/UX I guess
  • Loading branch information
rohangpta authored Jan 11, 2024
1 parent 1559d9f commit d596250
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 352 deletions.
10 changes: 10 additions & 0 deletions backend/clubs/management/commands/populate.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,12 @@ def get_image(url):
tag_undergrad, _ = Tag.objects.get_or_create(name="Undergraduate")
tag_generic, _ = Tag.objects.get_or_create(name="Generic")

wharton_badge, _ = Badge.objects.get_or_create(
label="Wharton Council",
purpose="Dummy badge to mock Wharton-affiliated clubs",
visible=True,
)

for i in range(1, 50):
club, created = Club.objects.get_or_create(
code="z-club-{}".format(i),
Expand All @@ -406,6 +412,10 @@ def get_image(url):
},
)

if 10 <= i <= 15:
# Make some clubs Wharton-affiliated
club.badges.add(wharton_badge)

if created:
club.available_virtually = i % 2 == 0
club.appointment_needed = i % 3 == 0
Expand Down
166 changes: 0 additions & 166 deletions backend/clubs/management/commands/wharton_council_application.py

This file was deleted.

18 changes: 18 additions & 0 deletions backend/clubs/migrations/0094_applicationcycle_release_date.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.18 on 2024-01-11 14:39

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("clubs", "0093_auto_20240106_1153"),
]

operations = [
migrations.AddField(
model_name="applicationcycle",
name="release_date",
field=models.DateTimeField(null=True),
),
]
1 change: 1 addition & 0 deletions backend/clubs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1534,6 +1534,7 @@ class ApplicationCycle(models.Model):
name = models.CharField(max_length=255)
start_date = models.DateTimeField(null=True)
end_date = models.DateTimeField(null=True)
release_date = models.DateTimeField(null=True)

def __str__(self):
return self.name
Expand Down
10 changes: 7 additions & 3 deletions backend/clubs/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,22 @@ def save(self):
class ApplicationCycleSerializer(serializers.ModelSerializer):
class Meta:
model = ApplicationCycle
fields = ["id", "name", "start_date", "end_date"]
fields = ["id", "name", "start_date", "end_date", "release_date"]

def validate(self, data):
"""
Check that start_date is before end_date.
Check that start_date <= end_date <= release_date
"""
start_date = data.get("start_date")
end_date = data.get("end_date")
release_date = data.get("release_date")

if start_date and end_date and start_date >= end_date:
raise serializers.ValidationError("Start must be before end.")

if end_date and release_date and end_date >= release_date:
raise serializers.ValidationError("End must be before release.")

return data


Expand Down Expand Up @@ -1030,6 +1034,7 @@ class Meta:
"is_favorite",
"is_member",
"is_subscribe",
"is_wharton",
"membership_count",
"recruiting_cycle",
"name",
Expand Down Expand Up @@ -1682,7 +1687,6 @@ class Meta(ClubListSerializer.Meta):
"instagram",
"is_ghost",
"is_request",
"is_wharton",
"linkedin",
"listserv",
"members",
Expand Down
Loading

0 comments on commit d596250

Please sign in to comment.