from rest_framework import viewsets
from .models import ActivityReport
from .serializers import ActivitySerializer
class ActivityViewSet(viewsets.ModelViewSet):
 serializer_class=ActivitySerializer; filterset_fields=['scope','campus','activity_type','approved']; search_fields=['title','summary','venue']; ordering_fields=['activity_date','attendance','souls_won']
 def get_queryset(self):
  queryset=ActivityReport.objects.select_related('campus','submitted_by')
  return queryset if self.request.user.is_staff else queryset.filter(submitted_by=self.request.user)
 def perform_create(self,serializer): serializer.save(submitted_by=self.request.user)
