feat: add status and is_active fields to Product model and filter product queries by approved status and active state
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 18s
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 18s
This commit is contained in:
parent
17f3a6eb30
commit
f904cad860
2 changed files with 4 additions and 2 deletions
|
|
@ -23,6 +23,8 @@ class Product(models.Model):
|
|||
stock = models.IntegerField(default=0)
|
||||
sku = models.CharField(max_length=100, unique=True)
|
||||
image = models.TextField(blank=True, null=True) # Textfield for base64 / URL
|
||||
status = models.CharField(max_length=50, default='pending')
|
||||
is_active = models.BooleanField(default=True)
|
||||
|
||||
class Meta:
|
||||
db_table = 'api_product'
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class ProductListView(generics.ListAPIView):
|
|||
except Exception as e:
|
||||
print("Error fetching approved suppliers:", e)
|
||||
|
||||
queryset = Product.objects.filter(supplier_id__in=approved_supplier_ids)
|
||||
queryset = Product.objects.filter(supplier_id__in=approved_supplier_ids, status='approved', is_active=True)
|
||||
category_slug = self.request.query_params.get('category', None)
|
||||
search_query = self.request.query_params.get('search', None)
|
||||
|
||||
|
|
@ -51,4 +51,4 @@ class ProductDetailView(generics.RetrieveAPIView):
|
|||
approved_supplier_ids = [row[0] for row in cursor.fetchall()]
|
||||
except Exception as e:
|
||||
print("Error fetching approved suppliers:", e)
|
||||
return Product.objects.filter(supplier_id__in=approved_supplier_ids)
|
||||
return Product.objects.filter(supplier_id__in=approved_supplier_ids, status='approved', is_active=True)
|
||||
|
|
|
|||
Loading…
Reference in a new issue