Simplify filtering gallery by slug
This commit is contained in:
parent
0d52cdca9e
commit
af798e3fcc
1 changed files with 7 additions and 8 deletions
|
|
@ -19,15 +19,14 @@ class Command(BaseCommand):
|
||||||
if options['all']:
|
if options['all']:
|
||||||
galleries = Gallery.objects.all()
|
galleries = Gallery.objects.all()
|
||||||
else:
|
else:
|
||||||
|
galleries = []
|
||||||
for slug in options['slugs']:
|
for slug in options['slugs']:
|
||||||
for gallery in Gallery.objects.all():
|
gallery_query = Gallery.objects.filter(slug=slug)
|
||||||
if gallery.slug == slug:
|
if not gallery_query:
|
||||||
galleries += [gallery]
|
raise CommandError(f"Slug {slug} does not correspond to a "
|
||||||
break
|
"gallery in the database.")
|
||||||
else:
|
galleries += gallery_query
|
||||||
raise CommandError(
|
|
||||||
'Slug {} does not correspond to a gallery in the database.'.format(slug))
|
|
||||||
print('error')
|
|
||||||
# Find duplicates in all galleries
|
# Find duplicates in all galleries
|
||||||
for gallery in galleries:
|
for gallery in galleries:
|
||||||
duplicates = find_duplicate(gallery)
|
duplicates = find_duplicate(gallery)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue