3535from django .contrib .auth .models import User
3636from rest_framework_simplejwt .tokens import RefreshToken
3737from rest_framework .permissions import IsAuthenticated , AllowAny , BasePermission , IsAuthenticatedOrReadOnly
38+ from rest_framework .throttling import AnonRateThrottle
3839from django .contrib .auth .models import User as DjangoUser
3940
4041from datetime import datetime , time
4142from django .utils .timezone import make_aware
4243
44+ class SponsorGuestThrottle (AnonRateThrottle ):
45+ rate = '30/hour'
46+
4347class MailerViewSet (viewsets .ModelViewSet ):
4448 queryset = Mailer .objects .all ()
4549 serializer_class = MailerSerializer
@@ -238,7 +242,7 @@ class SponsorsViewSet(viewsets.ModelViewSet):
238242 serializer_class = SponsorsSerializer
239243 filter_backends = [DynamicSearchFilter , filters .OrderingFilter ]
240244 ordering_fields = ['order' ]
241- permission_classes = [AllowAny ]
245+ permission_classes = [IsAuthenticated ]
242246
243247 @action (detail = False , methods = ['get' ], permission_classes = [AllowAny ], url_path = 'public' )
244248 def public (self , request ):
@@ -261,6 +265,7 @@ def public(self, request):
261265 detail = False ,
262266 methods = ['get' , 'post' , 'delete' ],
263267 permission_classes = [AllowAny ],
268+ throttle_classes = [SponsorGuestThrottle ],
264269 url_path = 'public/guests'
265270 )
266271 def public_guests (self , request ):
@@ -300,7 +305,7 @@ def public_guests(self, request):
300305 if not sponsor :
301306 return Response ({"detail" : "Sponsor not found" }, status = 404 )
302307
303- guest = Guests .objects .filter (id = guest_id , tag__icontains = sponsor .slug ).first ()
308+ guest = Guests .objects .filter (id = guest_id , tag__istartswith = sponsor .slug ).first ()
304309 if not guest :
305310 return Response ({"detail" : "Guest not found" }, status = 404 )
306311
@@ -460,7 +465,7 @@ def has_permission(self, request, view):
460465class BrucosiFormResponseViewSet (viewsets .ModelViewSet ):
461466 queryset = BrucosiFormResponse .objects .all ()
462467 serializer_class = BrucosiFormResponseSerializer
463- permission_classes = [AllowAny ]
468+ permission_classes = [AllowPostAnyOtherwiseAuthenticated ]
464469
465470 @action (detail = False , methods = ['post' ], url_path = 'brucosi-form-submit' )
466471 def brucosi_form_submit (self , request ):
0 commit comments