delete soft
This commit is contained in:
parent
13833c076b
commit
60208fe934
|
@ -121,7 +121,7 @@ class ConsumerViewSet(ModelViewSet):
|
||||||
"""
|
"""
|
||||||
ids = request.data.get('ids', None)
|
ids = request.data.get('ids', None)
|
||||||
if ids:
|
if ids:
|
||||||
Consumer.objects.filter(id__in = ids).delete(soft=True)
|
Consumer.objects.filter(id__in = ids).delete(soft=False)
|
||||||
return Response(status=status.HTTP_200_OK)
|
return Response(status=status.HTTP_200_OK)
|
||||||
|
|
||||||
@action(methods=['get'], detail=False,
|
@action(methods=['get'], detail=False,
|
||||||
|
|
|
@ -10,12 +10,15 @@ class SoftDeletableQuerySetMixin(object):
|
||||||
its ``is_deleted`` field to True.
|
its ``is_deleted`` field to True.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def delete(self):
|
def delete(self, soft=True):
|
||||||
"""
|
"""
|
||||||
Soft delete objects from queryset (set their ``is_deleted``
|
Soft delete objects from queryset (set their ``is_deleted``
|
||||||
field to True)
|
field to True)
|
||||||
"""
|
"""
|
||||||
self.update(is_delete=True)
|
if soft:
|
||||||
|
self.update(is_delete=True)
|
||||||
|
else:
|
||||||
|
return super(SoftDeletableQuerySetMixin, self).delete()
|
||||||
|
|
||||||
|
|
||||||
class SoftDeletableQuerySet(SoftDeletableQuerySetMixin, QuerySet):
|
class SoftDeletableQuerySet(SoftDeletableQuerySetMixin, QuerySet):
|
||||||
|
|
Loading…
Reference in New Issue