# Path: simplestore/products/models/product.py
# class Product(models.Model):
#     name = models.CharField(max_length=255)
#     slug = models.SlugField(unique=True)
#     sku = models.CharField(
#         max_length=50,
#         verbose_name='Reference Number',
#         unique=True
#     )
#     created_at = models.DateTimeField(auto_now=True, db_index=True)
#     updated_at = models.DateTimeField(auto_now_add=True, db_index=True)
#     image = FilerImageField(null=True, blank=True, on_delete=models.DO_NOTHING)
#     price = models.DecimalField(max_digits=10, decimal_places=2)
#     perex = models.TextField(max_length=255)
#     content = models.TextField(verbose_name='Content Description')
#     category = models.ManyToManyField(Category, blank=True)
#     is_active = models.BooleanField(default=True, verbose_name='Active')
#     is_featured = models.BooleanField(default=False, verbose_name='Featured')
# 
#     objects = ProductManager()
# 
#     _metadata = {
#         'description': 'content',
#     }
# 
#     class Meta:
#         ordering = ['-created_at']
# 
#     @property
#     def get_image_url(self):
#         return self.image.url
# 
#     def get_absolute_url(self):
#         return reverse('products:detail', kwargs={'slug': self.slug})
# 
#     def __str__(self):
#         return self.name


from django.db.models.signals import pre_delete, post_delete
from django.dispatch import receiver
from .models.product import Product



@receiver(pre_delete, sender=Product)
def product_pre_delete_receiver(sender, instance, **kwargs):
    """Instead of deleting object from DB set it's state is_active to False"""
    instance.is_active = False



# Path: simplestore/products/models/product.py
# class Product(models.Model):
#     name = models.CharField(max_length=255)
#     slug = models.SlugField(unique=True)
#     sku = models.CharField(
#         max_length=50,
#         verbose_name='Reference Number',
#         unique=True
#     )
#     created_at = models.DateTimeField(auto_now=True, db_index=True)
#     updated_at = models.DateTimeField(auto_now_add=True, db_index=True)
#     image = FilerImageField(null=True, blank=True, on_delete=models.DO_NOTHING)
#     price = models.DecimalField(max_digits=10, decimal_places=2)
#     perex = models.TextField(max_length=255)
#     content = models.TextField(verbose_name='Content Description')
#     category = models.ManyToManyField(Category, blank=True)
#     is_active = models.BooleanField(default=True, verbose_name='Active')
#     is_featured = models.BooleanField(default=False, verbose_name='Featured')
# 
#     objects = ProductManager()
# 
#     _metadata = {
#         'description': 'content',
#     }
# 
#     class Meta:
#         ordering = ['-created_at']
# 
#     @property
#     def get_image_url(self):
#         return self.image.url
# 
#     def get_absolute_url(self):
#         return reverse('products:detail', kwargs={'slug': self.slug})
# 
#     def __str__(self):
#         return self.name


# Path: simplestore/products/signals.py
from django.db.models.signals import pre_delete, post_delete
from django.dispatch import receiver
from .models.product import Product




@receiver(pre_delete, sender=Product)
def product_pre_delete_receiver(sender, instance, **kwargs):
    """Instead of deleting object from DB set it's state is_active to False"""
    instance.is_active = False



@receiver(post_delete, sender=Product)