From 6de05d4c9d4c0a8d0ac5b8e609552f00f0edfaa7 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 16 Mar 2014 13:47:18 +0000 Subject: [PATCH] available files are not wanted --- pandora/item/models.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pandora/item/models.py b/pandora/item/models.py index cd4cce1f..258e5172 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -1104,11 +1104,14 @@ class Item(models.Model): wanted = [] for s in self.sets(): if s.filter(selected=False).count() != 0: - wanted += [i.id for i in s] + wanted += [f.id for f in s if not f.available] else: break - self.files.filter(id__in=wanted).update(wanted=True) - self.files.exclude(id__in=wanted).update(wanted=False) + qs = self.files.all() + if wanted: + self.files.filter(id__in=wanted).update(wanted=True) + qs = qs.exclude(id__in=wanted) + qs.update(wanted=False) def update_selected(self): sets = self.sets()