def store_pre_save_receiver(sender, instance, *args, **kwargs): if not instance.slug: instance.slug = unique_slug_generator(instance) all_stores = Store.objects.all() if not instance.ordering: instance.ordering = 0 if instance.is_active and instance.ordering == 0: print("2") instance.ordering = all_stores.count() + 1
def tag_pre_save_receiver(sender, instance, *args, **kwargs): if not instance.slug: instance.slug = unique_slug_generator(instance) if not instance.background_image: instance.is_banner = False all_tags = Tag.objects.all().filter(is_banner=True) if not instance.ordering: instance.ordering = 0 if instance.is_banner and instance.ordering == 0: instance.ordering = all_tags.count() + 1
def product_pre_save_receiver(sender, instance, *args, **kwargs): if not instance.slug: instance.slug = unique_slug_generator(instance) if instance.sku == "": instance.sku = unique_sku_generator(instance) if not instance.price: instance.price = instance.base_price if not instance.on_sale: instance.price = instance.base_price if instance.discount: base_price = instance.base_price discount = instance.discount discounted_amount = (discount * base_price) / 100 # discounted_amount = discount_rate * base_price new_price = base_price - discounted_amount instance.price = new_price instance.on_sale = True
def category_pre_save_receiver(sender, instance, *args, **kwargs): if not instance.slug: instance.slug = unique_slug_generator(instance) all_categories = Category.objects.all() if not instance.ordering: instance.ordering = all_categories.count() + 1
def category_pre_save_receiver(sender, instance, *args, **kwargs): if not instance.slug: instance.slug = unique_slug_generator(instance)