def createRanking(sender, instance, created, update_fields, **kwargs): try: from apps.public.models.ranking import Ranking from apps.public.views.product_ranking import updateRankings, newProductResult if created: ranking, is_new = Ranking.objects.get_or_create(product = instance) ranking.new_product = newProductResult(instance) except Exception as e: ExceptionHandler(e, "error on product.createRanking post_save signal")
def updateRatingRankings(sender, instance, created, **kwargs): from apps.public.views.product_ranking import newProductResult, newStoreResult, photographyResult, priceResult, appealResult try: ranking, is_new = Ranking.objects.get_or_create(product=instance.product) if is_new: ranking.new_product = newProductResult(instance.product) ranking.new_store = newStoreResult(instance.product) if instance.subject == Rating.PHOTOGRAPHY: ranking.photography = photographyResult(instance.product) elif instance.subject == Rating.PRICE: ranking.price = priceResult(instance.product) elif instance.subject == Rating.APPEAL: ranking.appeal = appealResult(instance.product) ranking.save() except Exception as e: ExceptionHandler(e, "error on product_rankings.updateRatingRankings", no_email=True)