|
1 | 1 | from django.db.models import Q |
2 | | -from django.utils.functional import cached_property |
3 | | -from rest_framework.request import Request |
4 | 2 | from rest_framework.views import APIView |
5 | 3 |
|
6 | | -from usaspending_api.common.data_classes import Pagination |
7 | | -from usaspending_api.common.validator import TinyShield, customize_pagination_with_sort_columns |
| 4 | +from usaspending_api.common.validator import TinyShield |
8 | 5 |
|
9 | 6 |
|
10 | 7 | class FederalAccountBase(APIView): |
@@ -75,33 +72,3 @@ def get_program_activity_query(self, validated_data) -> Q: |
75 | 72 | query &= Q(Q(program_activity_reporting_key__isnull=False) | Q(program_activity__isnull=False)) |
76 | 73 |
|
77 | 74 | return query |
78 | | - |
79 | | - |
80 | | -class PaginationMixin: |
81 | | - request: Request |
82 | | - |
83 | | - default_sort_column: str |
84 | | - sortable_columns: list[str] |
85 | | - |
86 | | - @cached_property |
87 | | - def pagination(self): |
88 | | - model = customize_pagination_with_sort_columns(self.sortable_columns, self.default_sort_column) |
89 | | - request_data = ( |
90 | | - TinyShield(model).block(self.request.data) |
91 | | - if self.request.method == "POST" |
92 | | - else TinyShield(model).block(self.request.query_params) |
93 | | - ) |
94 | | - |
95 | | - # Use the default sort as a tie-breaker in the case of a different sort provided |
96 | | - primary_sort_key = request_data.get("sort", self.default_sort_column) |
97 | | - secondary_sort_key = self.default_sort_column if primary_sort_key != self.default_sort_column else None |
98 | | - |
99 | | - return Pagination( |
100 | | - page=request_data["page"], |
101 | | - limit=request_data["limit"], |
102 | | - lower_limit=(request_data["page"] - 1) * request_data["limit"], |
103 | | - upper_limit=(request_data["page"] * request_data["limit"]), |
104 | | - sort_key=primary_sort_key, |
105 | | - sort_order=request_data["order"], |
106 | | - secondary_sort_key=secondary_sort_key, |
107 | | - ) |
0 commit comments