Skip to content

Commit

Permalink
Feat: Add Wharton application cycle extensions, club membership editi…
Browse files Browse the repository at this point in the history
…ng within cycles
  • Loading branch information
julianweng committed Dec 1, 2023
1 parent 1893090 commit ea5779c
Show file tree
Hide file tree
Showing 6 changed files with 281 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.18 on 2023-11-17 22:01

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("clubs", "0090_auto_20230106_1443"),
]

operations = [
migrations.AddField(
model_name="clubapplication",
name="application_end_time_exception",
field=models.BooleanField(blank=True, default=False),
),
]
1 change: 1 addition & 0 deletions backend/clubs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1551,6 +1551,7 @@ class ClubApplication(CloneModel):
description = models.TextField(blank=True)
application_start_time = models.DateTimeField()
application_end_time = models.DateTimeField()
application_end_time_exception = models.BooleanField(default=False, blank=True)
name = models.TextField(blank=True)
result_release_time = models.DateTimeField()
application_cycle = models.ForeignKey(
Expand Down
1 change: 1 addition & 0 deletions backend/clubs/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2738,6 +2738,7 @@ class Meta:
"rejection_email",
"application_start_time",
"application_end_time",
"application_end_time_exception",
"result_release_time",
"external_url",
"committees",
Expand Down
69 changes: 68 additions & 1 deletion backend/clubs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4901,6 +4901,8 @@ def update(self, *args, **kwargs):
)
for app in applications:
app.application_start_time = start
if app.application_end_time_exception:
continue
app.application_end_time = end
if app.result_release_time < app.application_end_time:
filler_time = app.application_end_time + datetime.timedelta(days=10)
Expand Down Expand Up @@ -5050,7 +5052,6 @@ def remove_clubs_from_all(self, *args, **kwargs):
---
"""
club_ids = self.request.data.get("clubs", [])
print(self.request.data)
apps = ClubApplication.objects.filter(pk__in=club_ids)
for app in apps:
app.application_cycle = None
Expand All @@ -5060,6 +5061,72 @@ def remove_clubs_from_all(self, *args, **kwargs):
)
return Response([])

@action(detail=False, methods=["post"])
def add_clubs_to_exception(self, *args, **kwargs):
"""
Exempt selected clubs from application cycle deadline
---
requestBody:
content:
application/json:
schema:
type: object
properties:
clubs:
type: array
items:
type: object:
properties:
id:
type: integer
application_end_time:
type: string
responses:
"200":
content: {}
"""
clubs = self.request.data.get("clubs")
apps = []
for club in clubs:
app = ClubApplication.objects.get(pk=club["id"])
apps.append(app)
app.application_end_time = club["end_date"]
app.application_end_time_exception = True
ClubApplication.objects.bulk_update(
apps, ["application_end_time", "application_end_time_exception"],
)
return Response([])

@action(detail=True, methods=["post"])
def remove_clubs_from_exception(self, *args, **kwargs):
"""
Remove selected clubs from application cycle deadline exemption
---
requestBody:
content:
application/json:
schema:
type: object
properties:
clubs:
type: array
items:
type: string
responses:
"200":
content: {}
---
"""
club_ids = self.request.data.get("clubs", [])
apps = ClubApplication.objects.filter(pk__in=club_ids)
for app in apps:
app.application_end_time_exception = False
app.application_end_time = app.application_cycle.end_date
ClubApplication.objects.bulk_update(
apps, ["application_end_time", "application_end_time_exception"],
)
return Response([])


class WhartonApplicationAPIView(viewsets.ModelViewSet):
"""
Expand Down
Loading

0 comments on commit ea5779c

Please sign in to comment.