Example #1
0
def update_saved():
    total_saved = 0
    for purchase in Purchase.objects.filter(purchase_complete=True):
        deal = purchase.deal
        total_saved += deal.savings()
        
    s = Saved(value=total_saved)
    s.save()
Example #2
0
 def get_saved_items_for_user(self, user):
     q = Item.select(
         Item.id).join(Feed).join(Subscription).join(User).where(
             (User.id == user.id), (Item.id << Saved.select(
                 Saved.item).where(User.id == user.id))).order_by(
                     Item.id).distinct().naive()
     return [r.id for r in q]
Example #3
0
 def get_saved_items_for_user(self, user):
     q = Item.select(Item.id).join(Feed).join(Subscription).join(User).where(
         (User.id == user.id), 
         (Item.id << Saved.select(Saved.item).where(User.id == user.id))).order_by(Item.id).distinct().naive()
     return [r.id for r in q]