mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-04-18 06:50:05 +02:00
add tests and fix missing get_queryset
This commit is contained in:
@@ -6,18 +6,21 @@ from apps.api.serializers import DCAStrategySerializer, DCAEntrySerializer
|
||||
|
||||
|
||||
class DCAStrategyViewSet(viewsets.ModelViewSet):
|
||||
queryset = DCAStrategy.all_objects.all()
|
||||
queryset = DCAStrategy.objects.all()
|
||||
serializer_class = DCAStrategySerializer
|
||||
filterset_fields = {
|
||||
'name': ['exact', 'icontains'],
|
||||
'target_currency': ['exact'],
|
||||
'payment_currency': ['exact'],
|
||||
'notes': ['exact', 'icontains'],
|
||||
'created_at': ['exact', 'gte', 'lte', 'gt', 'lt'],
|
||||
'updated_at': ['exact', 'gte', 'lte', 'gt', 'lt'],
|
||||
"name": ["exact", "icontains"],
|
||||
"target_currency": ["exact"],
|
||||
"payment_currency": ["exact"],
|
||||
"notes": ["exact", "icontains"],
|
||||
"created_at": ["exact", "gte", "lte", "gt", "lt"],
|
||||
"updated_at": ["exact", "gte", "lte", "gt", "lt"],
|
||||
}
|
||||
search_fields = ['name', 'notes']
|
||||
ordering_fields = '__all__'
|
||||
search_fields = ["name", "notes"]
|
||||
ordering_fields = "__all__"
|
||||
|
||||
def get_queryset(self):
|
||||
return DCAStrategy.objects.all()
|
||||
|
||||
@action(detail=True, methods=["get"])
|
||||
def investment_frequency(self, request, pk=None):
|
||||
@@ -43,16 +46,21 @@ class DCAEntryViewSet(viewsets.ModelViewSet):
|
||||
queryset = DCAEntry.objects.all()
|
||||
serializer_class = DCAEntrySerializer
|
||||
filterset_fields = {
|
||||
'strategy': ['exact'],
|
||||
'date': ['exact', 'gte', 'lte', 'gt', 'lt'],
|
||||
'amount_paid': ['exact', 'gte', 'lte', 'gt', 'lt'],
|
||||
'amount_received': ['exact', 'gte', 'lte', 'gt', 'lt'],
|
||||
'expense_transaction': ['exact', 'isnull'],
|
||||
'income_transaction': ['exact', 'isnull'],
|
||||
'notes': ['exact', 'icontains'],
|
||||
'created_at': ['exact', 'gte', 'lte', 'gt', 'lt'],
|
||||
'updated_at': ['exact', 'gte', 'lte', 'gt', 'lt'],
|
||||
"strategy": ["exact"],
|
||||
"date": ["exact", "gte", "lte", "gt", "lt"],
|
||||
"amount_paid": ["exact", "gte", "lte", "gt", "lt"],
|
||||
"amount_received": ["exact", "gte", "lte", "gt", "lt"],
|
||||
"expense_transaction": ["exact", "isnull"],
|
||||
"income_transaction": ["exact", "isnull"],
|
||||
"notes": ["exact", "icontains"],
|
||||
"created_at": ["exact", "gte", "lte", "gt", "lt"],
|
||||
"updated_at": ["exact", "gte", "lte", "gt", "lt"],
|
||||
}
|
||||
search_fields = ['notes']
|
||||
ordering_fields = '__all__'
|
||||
ordering = ['-date']
|
||||
search_fields = ["notes"]
|
||||
ordering_fields = "__all__"
|
||||
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