available files are not wanted

This commit is contained in:
j 2014-03-16 13:47:18 +00:00
parent 765e1cd82c
commit 6de05d4c9d

View file

@ -1104,11 +1104,14 @@ class Item(models.Model):
wanted = [] wanted = []
for s in self.sets(): for s in self.sets():
if s.filter(selected=False).count() != 0: 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: else:
break break
self.files.filter(id__in=wanted).update(wanted=True) qs = self.files.all()
self.files.exclude(id__in=wanted).update(wanted=False) 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): def update_selected(self):
sets = self.sets() sets = self.sets()