Skip to content

Commit

Permalink
move destination attribute from api to sdk (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
NileshPant1999 authored Nov 9, 2023
1 parent a9957db commit 6aa63cd
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
5 changes: 3 additions & 2 deletions fyle_accounting_mappings/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
MappingStatsView,
ExpenseAttributesMappingView,
EmployeeAttributesMappingView,
ExpenseFieldView
ExpenseFieldView,
DestinationAttributesView
)

urlpatterns = [
Expand All @@ -40,5 +41,5 @@
path('category_attributes/', CategoryAttributesMappingView.as_view()),
path('employee_attributes/', EmployeeAttributesMappingView.as_view()),
path('expense_fields/', ExpenseFieldView.as_view()),

path('destination_attributes/', DestinationAttributesView.as_view()),
]
10 changes: 10 additions & 0 deletions fyle_accounting_mappings/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,13 @@ def assert_valid(condition: bool, message: str) -> Response or None:
raise ValidationError(detail={
'message': message
})

class LookupFieldMixin:
lookup_field = 'workspace_id'

def filter_queryset(self, queryset):
if self.lookup_field in self.kwargs:
lookup_value = self.kwargs[self.lookup_field]
filter_kwargs = {self.lookup_field: lookup_value}
queryset = queryset.filter(**filter_kwargs)
return super().filter_queryset(queryset)
17 changes: 16 additions & 1 deletion fyle_accounting_mappings/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
from functools import reduce
from typing import Dict, List

from rest_framework.generics import ListCreateAPIView, ListAPIView, DestroyAPIView, RetrieveAPIView
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.generics import ListCreateAPIView, ListAPIView, DestroyAPIView
from rest_framework.response import Response
from rest_framework.views import status
from django.db.models import Count, Q

from .utils import LookupFieldMixin
from .exceptions import BulkError
from .utils import assert_valid
from .models import MappingSetting, Mapping, ExpenseAttribute, DestinationAttribute, EmployeeMapping, \
Expand Down Expand Up @@ -436,3 +438,16 @@ def get_queryset(self):
return ExpenseField.objects.filter(
workspace_id=self.kwargs['workspace_id']
).all()


class DestinationAttributesView(LookupFieldMixin, ListAPIView):
"""
Destination Attributes view
"""

queryset = DestinationAttribute.objects.all()
serializer_class = DestinationAttributeSerializer
pagination_class = None
filter_backends = (DjangoFilterBackend,)
filterset_fields = {'attribute_type': {'exact', 'in'}, 'display_name': {'exact', 'in'}, 'active': {'exact'}}
ordering_fields = ('value',)
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ chardet==3.0.4
charset-normalizer==2.0.8
Django==3.1.14
django-rest-framework==0.1.0
django-filter==21.1
djangorestframework==3.11.2
idna==2.8
isort==4.3.21
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name='fyle-accounting-mappings',
version='1.27.3',
version='1.28.0',
author='Shwetabh Kumar',
author_email='[email protected]',
description='Django application to store the fyle accounting mappings in a generic manner',
Expand Down

0 comments on commit 6aa63cd

Please sign in to comment.