mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-07-10 14:52:42 +02:00
add tests and fix missing get_queryset
This commit is contained in:
committed by
icovada
parent
3b2b6d6473
commit
49cac0588e
@@ -6,7 +6,7 @@ from apps.api.serializers import DCAStrategySerializer, DCAEntrySerializer
|
|||||||
|
|
||||||
|
|
||||||
class DCAStrategyViewSet(viewsets.ModelViewSet):
|
class DCAStrategyViewSet(viewsets.ModelViewSet):
|
||||||
queryset = DCAStrategy.all_objects.all()
|
queryset = DCAStrategy.objects.all()
|
||||||
serializer_class = DCAStrategySerializer
|
serializer_class = DCAStrategySerializer
|
||||||
filterset_fields = {
|
filterset_fields = {
|
||||||
"name": ["exact", "icontains"],
|
"name": ["exact", "icontains"],
|
||||||
@@ -22,9 +22,6 @@ class DCAStrategyViewSet(viewsets.ModelViewSet):
|
|||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return DCAStrategy.objects.all()
|
return DCAStrategy.objects.all()
|
||||||
|
|
||||||
def get_queryset(self):
|
|
||||||
return DCAStrategy.objects.all().order_by("id")
|
|
||||||
|
|
||||||
@action(detail=True, methods=["get"])
|
@action(detail=True, methods=["get"])
|
||||||
def investment_frequency(self, request, pk=None):
|
def investment_frequency(self, request, pk=None):
|
||||||
strategy = self.get_object()
|
strategy = self.get_object()
|
||||||
@@ -59,6 +56,11 @@ class DCAEntryViewSet(viewsets.ModelViewSet):
|
|||||||
"created_at": ["exact", "gte", "lte", "gt", "lt"],
|
"created_at": ["exact", "gte", "lte", "gt", "lt"],
|
||||||
"updated_at": ["exact", "gte", "lte", "gt", "lt"],
|
"updated_at": ["exact", "gte", "lte", "gt", "lt"],
|
||||||
}
|
}
|
||||||
search_fields = ['notes']
|
search_fields = ["notes"]
|
||||||
ordering_fields = '__all__'
|
ordering_fields = "__all__"
|
||||||
ordering = ['-date']
|
ordering = ["-date"]
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
# Filter entries by strategies the user has access to
|
||||||
|
accessible_strategies = DCAStrategy.objects.all()
|
||||||
|
return DCAEntry.objects.filter(strategy__in=accessible_strategies)
|
||||||
|
|||||||
Reference in New Issue
Block a user