Skip to content

Commit

Permalink
ViewSet for ComputingFacility class. Addresses #38
Browse files Browse the repository at this point in the history
  • Loading branch information
joncison committed Aug 12, 2020
1 parent 735f4b8 commit 575ab1f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ifbcatsandbox_api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,3 +352,27 @@ def perform_create(self, serializer):
'homepage',
'description',
)


# Model ViewSet for computing facilities
class ComputingFacilityViewSet(viewsets.ModelViewSet):
"""Handles creating, reading and updating computing facilities."""

serializer_class = serializers.ComputingFacilitySerializer
queryset = models.ComputingFacility.objects.all()

permission_classes = (permissions.PubliclyReadableEditableByOwner, IsAuthenticatedOrReadOnly)

def perform_create(self, serializer):
"""Sets the user profile to the logged-in user."""
serializer.save(user_profile=self.request.user)

filter_backends = (filters.SearchFilter,)
# TODO: : add to "search_fields" below: 'team', 'providedBy'
search_fields = (
'homepage',
# 'providedBy',
# 'team',
'accessibility',
'serverDescription',
)

0 comments on commit 575ab1f

Please sign in to comment.