add: add update api for counterparty
This commit is contained in:
@@ -66,3 +66,23 @@ class CounterpartyCreateSerializer(serializers.Serializer):
|
||||
balance_date=validated_data.get('balance_date'),
|
||||
comment=validated_data.get('comment'),
|
||||
)
|
||||
|
||||
|
||||
class CounterpartyUpdateSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Counterparty
|
||||
fields = [
|
||||
'inn', 'name', 'phone', 'type', 'folder', 'region', 'district', 'balance',
|
||||
'balance_currency', 'balance_date', 'comment'
|
||||
]
|
||||
extra_kwargs = {
|
||||
'name': {'required': False},
|
||||
'type': {'required': False},
|
||||
'folder': {'required': False},
|
||||
'region': {'required': False},
|
||||
'district': {'required': False},
|
||||
'balance': {'required': False},
|
||||
'balance_currency': {'required': False},
|
||||
'balance_date': {'required': False},
|
||||
'comment': {'required': False}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ urlpatterns = [
|
||||
path('<uuid:id>/archive/', cp_views.ArchiveCounterpartyApiView.as_view()),
|
||||
path('archived/list/', cp_views.ArchivedCounterpartyListApiView.as_view()),
|
||||
path('<uuid:id>/delete/', cp_views.CounterpartyDeleteApiView.as_view()),
|
||||
path('<uuid:id>/update/', cp_views.CounterpartyUpdateApiView.as_view()),
|
||||
]
|
||||
)),
|
||||
path('counterparty_folder/', include(
|
||||
|
||||
@@ -69,4 +69,12 @@ class CounterpartyDeleteApiView(views.APIView):
|
||||
return Response(
|
||||
{'success': True, 'message': 'counterparty deleted'},
|
||||
status=204
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class CounterpartyUpdateApiView(generics.UpdateAPIView):
|
||||
permission_classes = [HasRolePermission]
|
||||
required_permissions = []
|
||||
lookup_field = 'id'
|
||||
serializer_class = serializers.CounterpartyUpdateSerializer
|
||||
queryset = Counterparty.objects.all()
|
||||
|
||||
Reference in New Issue
Block a user