diff --git a/intranet/apps/auth/decorators.py b/intranet/apps/auth/decorators.py index c1005d5b3d4..c99db081cac 100644 --- a/intranet/apps/auth/decorators.py +++ b/intranet/apps/auth/decorators.py @@ -26,9 +26,6 @@ def in_admin_group(user): #: Restrict the wrapped view to eighth admins eighth_admin_required = admin_required("eighth") -# Restrict the wrapped view to eighth sponsors -eighth_sponsor_required = user_passes_test(lambda u: not u.is_anonymous and u.is_eighth_sponsor) - #: Restrict the wrapped view to announcements admins announcements_admin_required = admin_required("announcements") diff --git a/intranet/apps/eighth/forms/activities.py b/intranet/apps/eighth/forms/activities.py index ecae85c14ca..b4fcf396981 100644 --- a/intranet/apps/eighth/forms/activities.py +++ b/intranet/apps/eighth/forms/activities.py @@ -15,9 +15,9 @@ def __init__(self, *args, sponsors=None, **kwargs): self.fields["subscriptions_enabled"].label = "Enable club announcements" self.fields["subscriptions_enabled"].help_text = "Allow students to subscribe to receive announcements for this activity through Ion." self.fields["club_sponsors"].label = "Teacher moderators" - + sponsors_list = "; ".join([str(sponsor) for sponsor in sponsors]) if sponsors else "no sponsors" - + self.fields["club_sponsors"].help_text = ( f"Teacher moderators can post and manage this club's announcements. " f"These are in addition to the activity's eighth period sponsors ({sponsors_list})." diff --git a/intranet/apps/eighth/forms/admin/activities.py b/intranet/apps/eighth/forms/admin/activities.py index 68ec88b3084..c23ae83fa90 100644 --- a/intranet/apps/eighth/forms/admin/activities.py +++ b/intranet/apps/eighth/forms/admin/activities.py @@ -145,14 +145,14 @@ def __init__(self, *args, sponsors=None, **kwargs): self.fields["subscriptions_enabled"].label = "Enable club announcements" self.fields["subscriptions_enabled"].help_text = "Allow students to subscribe to receive announcements for this activity through Ion." self.fields["officers"].help_text = "Student officers can send club announcements to subscribers." - + sponsors_list = "; ".join([str(sponsor) for sponsor in sponsors]) if sponsors else "no sponsors" - + self.fields["club_sponsors"].help_text = ( f"Teacher moderators can post and manage this club's announcements. " f"These are in addition to the activity's eighth period sponsors ({sponsors_list})." ) - + self.fields["club_sponsors"].label = "Teacher moderators" self.fields["subscribers"].help_text = "Students who subscribe to this activity will receive club announcements." diff --git a/intranet/apps/eighth/models.py b/intranet/apps/eighth/models.py index 2fa093dbad4..264aba5386e 100644 --- a/intranet/apps/eighth/models.py +++ b/intranet/apps/eighth/models.py @@ -82,9 +82,10 @@ class EighthSponsor(AbstractBaseEighthModel): show_full_name = models.BooleanField(default=False) history = HistoricalRecords() - + def __str__(self): return self.name + class Meta: unique_together = (("first_name", "last_name", "user", "online_attendance", "full_time", "department"),) ordering = ("last_name", "first_name") @@ -108,9 +109,6 @@ def to_be_assigned(self) -> bool: """ return any(x in self.name.lower() for x in ["to be assigned", "to be determined", "to be announced"]) - def __str__(self): - return self.name - class EighthRoom(AbstractBaseEighthModel): """Represents a room in which an eighth period activity can be held. diff --git a/intranet/apps/eighth/views/activities.py b/intranet/apps/eighth/views/activities.py index 6a002bf548e..697ce36c359 100644 --- a/intranet/apps/eighth/views/activities.py +++ b/intranet/apps/eighth/views/activities.py @@ -20,7 +20,7 @@ from ....utils.date import get_date_range_this_year, get_senior_graduation_year from ....utils.helpers import is_entirely_digit from ....utils.serialization import safe_json -from ...auth.decorators import deny_restricted, eighth_sponsor_required +from ...auth.decorators import deny_restricted from ..forms.activities import ActivitySettingsForm from ..forms.admin.activities import ActivityMultiSelectForm from ..models import EighthActivity, EighthBlock, EighthScheduledActivity, EighthSignup, EighthSponsor @@ -55,7 +55,7 @@ def activity_view(request, activity_id=None): @login_required def settings_view(request, activity_id=None): activity = get_object_or_404(EighthActivity, id=activity_id) - + if not (EighthSponsor.objects.filter(user=request.user).exists() or request.user in activity.club_sponsors.all()): raise Http404