diff --git a/intranet/apps/announcements/tests.py b/intranet/apps/announcements/tests.py index f49d5871d0..64e81702c3 100644 --- a/intranet/apps/announcements/tests.py +++ b/intranet/apps/announcements/tests.py @@ -6,6 +6,7 @@ from ...test.ion_test import IonTestCase from ...utils.date import get_senior_graduation_year +from ..eighth.models import EighthActivity from ..users.models import Group from .models import Announcement, AnnouncementRequest @@ -443,6 +444,17 @@ def test_hide_announcement_view(self): response = self.client.get(reverse("hide_announcement")) self.assertEqual(405, response.status_code) + def test_modify_club_announcement(self): + self.make_admin() + act = EighthActivity.objects.get_or_create(name="test")[0] + announce = Announcement.objects.get_or_create(title="test9", content="test9", activity=act)[0] + self.client.post( + reverse("modify_club_announcement", args=[announce.id]), + {"title": "hi", "content": "bye", "expiration_date": "3000-01-01"}, + ) + announce.refresh_from_db() + self.assertEqual(act, announce.activity) + class ApiTest(IonTestCase): def test_api_announcements_list(self): diff --git a/intranet/apps/eighth/views/admin/activities.py b/intranet/apps/eighth/views/admin/activities.py index d1fe7a6cf2..704bbcf5e3 100644 --- a/intranet/apps/eighth/views/admin/activities.py +++ b/intranet/apps/eighth/views/admin/activities.py @@ -150,6 +150,7 @@ def edit_activity_view(request, activity_id): activity = form.save() activity.subscribers.add(*[sponsor.user for sponsor in form.cleaned_data["sponsors"]]) + activity.subscribers.add(*form.cleaned_data["club_sponsors"], *form.cleaned_data["officers"]) activity.save() except forms.ValidationError as error: diff --git a/intranet/apps/eighth/views/signup.py b/intranet/apps/eighth/views/signup.py index 7b68adf854..00e9cd3584 100644 --- a/intranet/apps/eighth/views/signup.py +++ b/intranet/apps/eighth/views/signup.py @@ -405,7 +405,8 @@ def unsubscribe_from_club(request, activity_id): activity = get_object_or_404(EighthActivity, id=activity_id) if activity.sponsors.filter(user=request.user).exists() or request.user in activity.club_sponsors.all(): - raise http.Http404 + messages.error(request, "You cannot unsubscribe from an activity you sponsor.") + return redirect("club_announcements") if request.user in activity.subscribers.all(): activity.subscribers.remove(request.user)