Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Prevent duplicate committee names" #771

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 0 additions & 91 deletions backend/clubs/management/commands/merge_duplicate_committees.py

This file was deleted.

6 changes: 0 additions & 6 deletions backend/clubs/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2855,12 +2855,6 @@ def save(self):
)
)
)

# Committee names must be unique
normalized_committees = [name.strip().lower() for name in committees]
if len(set(normalized_committees)) != len(normalized_committees):
raise serializers.ValidationError("Committee names must be unique")

if prev_committee_names != committees:
if application_obj.application_start_time < now:
raise serializers.ValidationError(
Expand Down
49 changes: 0 additions & 49 deletions backend/tests/clubs/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from clubs.filters import DEFAULT_PAGE_SIZE
from clubs.models import (
Advisor,
ApplicationCommittee,
ApplicationSubmission,
Asset,
Badge,
Expand Down Expand Up @@ -2938,54 +2937,6 @@ def test_club_approval_response_templates(self):
)
self.assertEqual(resp.status_code, 403)

def test_application_duplicate_committees(self):
"""
Test that duplicate committees are rejected when creating/updating applications.
"""
date = datetime.datetime.now() + datetime.timedelta(days=1)

self.client.login(username=self.user5.username, password="test")

# Test creating new application with duplicates
response = self.client.post(
reverse("club-applications-list", args=(self.club1.code,)),
data={
"name": "Test Application",
"application_start_time": date,
"application_end_time": date + datetime.timedelta(days=7),
"result_release_time": date + datetime.timedelta(days=14),
"committees": [{"name": "General Member"}, {"name": "General Member"}],
},
content_type="application/json",
)

self.assertEqual(response.status_code, 400)
self.assertIn("Committee names must be unique", str(response.content))

# Create valid application for patch test
application = ClubApplication.objects.create(
name="Test Application",
club=self.club1,
application_start_time=date,
application_end_time=date + datetime.timedelta(days=7),
result_release_time=date + datetime.timedelta(days=14),
)
ApplicationCommittee.objects.create(
name="General Member", application=application
)

# Try to update with duplicate committees
response = self.client.patch(
reverse("club-applications-detail", args=(self.club1.code, application.id)),
data={
"committees": [{"name": "General Member"}, {"name": "General Member"}]
},
content_type="application/json",
)

self.assertEqual(response.status_code, 400)
self.assertIn("Committee names must be unique", str(response.content))


class HealthTestCase(TestCase):
def test_health(self):
Expand Down
Loading