feat: add product activation/deactivation and filtering by active status
- Add 'active' boolean field to Product model with default=True - Implement ProductView.get_queryset() to filter products by active status - Default behavior: return only active products - Support query params: ?active=true|false|all - Support variations: 1/0, yes/no for true/false - Detail operations (GET/PATCH/DELETE by ID) work with all products - Update ProductSerializer to include 'active' field - Add comprehensive test suite (11 new tests): - Test filtering by active/inactive/all products - Test parameter variations (1, yes, 0, no) - Test PATCH to activate/deactivate products - Test default list behavior after status changes - Update API documentation in doc/requests.org with examples - All tests passing (13 product tests + 8 API tests)
This commit is contained in:
@@ -14,6 +14,7 @@ class ProductCategory(models.Model):
|
||||
|
||||
|
||||
class Product(models.Model):
|
||||
active = models.BooleanField(default=True)
|
||||
name = models.CharField(max_length=100, unique=True)
|
||||
price = models.DecimalField(max_digits=9, decimal_places=2)
|
||||
measuring_unit = models.CharField(
|
||||
|
||||
Reference in New Issue
Block a user