Created
February 8, 2015 22:42
-
-
Save akatreyt/c2bbd92e91ee56074ee0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
total = 0 | |
sale_products = Product.objects.filter(site_match=from_product.site_match, site_id__in=sale_site_ids) | |
if sale_products is not None and len(sale_products) > 0: | |
for product in sale_products: | |
print product.rating | |
total += float(product.rating) | |
rating = total/len(sale_products) | |
from_product.site_match.sale_site_rating = rating | |
from_product.site_match.save() | |
else: | |
from_product.site_match.sale_site_rating = 0 | |
from_product.site_match.save() | |
total = 0 | |
review_products = Product.objects.filter(site_match=from_product.site_match, site_id__in=review_site_ids) | |
if review_products is not None and len(review_products) > 0: | |
for product in review_products: | |
print product.rating | |
total += float(product.rating) | |
rating = total / len(review_products) | |
from_product.site_match.review_site_rating = rating | |
from_product.site_match.save() | |
else: | |
from_product.site_match.review_site_rating = 0 | |
from_product.site_match.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment