32 lines
944 B
Python
32 lines
944 B
Python
|
|
|
|
def upgrade_originals():
|
|
import item.models
|
|
import itemlist.models
|
|
nt = itemlist.models.List.objects.get(name='No Type')
|
|
no = itemlist.models.List.objects.get(name='New Originals')
|
|
for i in nt.get_items(nt.user):
|
|
orig = item.models.Item.objects.get(data__title=i.get('title'), data__type=["Original"])
|
|
print(i, orig)
|
|
orig.files.all().update(selected=False)
|
|
i.files.all().update(item=orig)
|
|
orig.save()
|
|
orig.remove_poster()
|
|
orig.make_poster()
|
|
i.data['type'] = ['Empty']
|
|
i.save()
|
|
no.items.add(orig)
|
|
|
|
|
|
def remove_deselected_files():
|
|
import itemlist.models
|
|
il = itemlist.models.List.objects.get(name='New Originals')
|
|
for i in il.items.all():
|
|
changed = False
|
|
for f in i.files.filter(selected=False):
|
|
f.data.delete()
|
|
f.delete()
|
|
changed = True
|
|
if changed:
|
|
i.save()
|
|
|