Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added filter for is_archieved on file viewset #2704

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions care/emr/api/viewsets/file_upload.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.utils import timezone
from django_filters import rest_framework as filters
from pydantic import BaseModel
from rest_framework.decorators import action
from rest_framework.exceptions import PermissionDenied
Expand Down Expand Up @@ -50,6 +51,10 @@ def file_authorizer(user, file_type, associating_id, permission):
raise PermissionDenied("Cannot View File")


class FileUploadFilter(filters.FilterSet):
is_archived = filters.BooleanFilter(field_name="is_archived")


class FileUploadViewSet(
EMRCreateMixin, EMRRetrieveMixin, EMRUpdateMixin, EMRListMixin, EMRBaseViewSet
):
Expand All @@ -58,6 +63,8 @@ class FileUploadViewSet(
pydantic_retrieve_model = FileUploadRetrieveSpec
pydantic_update_model = FileUploadUpdateSpec
pydantic_read_model = FileUploadListSpec
filterset_class = FileUploadFilter
filter_backends = [filters.DjangoFilterBackend]

def authorize_create(self, instance):
file_authorizer(
Expand Down