fix song review migration
This commit is contained in:
parent
3b53d626bc
commit
a24a9c516a
2 changed files with 17 additions and 8 deletions
|
@ -117,7 +117,7 @@ class Command(BaseCommand):
|
||||||
print("Deleting migrated user pieces")
|
print("Deleting migrated user pieces")
|
||||||
# Piece.objects.all().delete()
|
# Piece.objects.all().delete()
|
||||||
for cls in classes: # Collection
|
for cls in classes: # Collection
|
||||||
print(cls)
|
print(f"Deleting {cls}")
|
||||||
cls.objects.all().delete()
|
cls.objects.all().delete()
|
||||||
|
|
||||||
def collection(self, options):
|
def collection(self, options):
|
||||||
|
@ -143,8 +143,12 @@ class Command(BaseCommand):
|
||||||
c.catalog_item.save()
|
c.catalog_item.save()
|
||||||
for citem in entity.collectionitem_list:
|
for citem in entity.collectionitem_list:
|
||||||
if citem.song:
|
if citem.song:
|
||||||
LinkModel = AlbumLink
|
if citem.song.album_id:
|
||||||
old_id = citem.song.album_id
|
LinkModel = AlbumLink
|
||||||
|
old_id = citem.song.album_id
|
||||||
|
else:
|
||||||
|
LinkModel = SongLink
|
||||||
|
old_id = citem.song.id
|
||||||
else:
|
else:
|
||||||
LinkModel = model_link[citem.item.__class__]
|
LinkModel = model_link[citem.item.__class__]
|
||||||
old_id = citem.item.id
|
old_id = citem.item.id
|
||||||
|
@ -153,7 +157,6 @@ class Command(BaseCommand):
|
||||||
item = Item.objects.get(uid=item_link.new_uid)
|
item = Item.objects.get(uid=item_link.new_uid)
|
||||||
c.append_item(item, metadata={"note": citem.comment})
|
c.append_item(item, metadata={"note": citem.comment})
|
||||||
else:
|
else:
|
||||||
# TODO convert song to album
|
|
||||||
print(f"{c.owner} {c.id} {c.title} {citem.item} were skipped")
|
print(f"{c.owner} {c.id} {c.title} {citem.item} were skipped")
|
||||||
CollectionLink.objects.create(old_id=entity.id, new_uid=c.uid)
|
CollectionLink.objects.create(old_id=entity.id, new_uid=c.uid)
|
||||||
qs = (
|
qs = (
|
||||||
|
@ -199,7 +202,9 @@ class Command(BaseCommand):
|
||||||
edited_time=entity.edited_time,
|
edited_time=entity.edited_time,
|
||||||
)
|
)
|
||||||
ReviewLink.objects.create(
|
ReviewLink.objects.create(
|
||||||
old_id=entity.id, new_uid=review.uid
|
module=entity.__class__.__module__.split(".")[0],
|
||||||
|
old_id=entity.id,
|
||||||
|
new_uid=review.uid,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Convert failed for {typ} {entity.id}: {e}")
|
print(f"Convert failed for {typ} {entity.id}: {e}")
|
||||||
|
@ -306,12 +311,12 @@ class Command(BaseCommand):
|
||||||
self.initshelf()
|
self.initshelf()
|
||||||
elif options["collection"]:
|
elif options["collection"]:
|
||||||
if options["clear"]:
|
if options["clear"]:
|
||||||
self.clear([Collection, Like])
|
self.clear([CollectionLink, Like, Collection])
|
||||||
else:
|
else:
|
||||||
self.collection(options)
|
self.collection(options)
|
||||||
elif options["review"]:
|
elif options["review"]:
|
||||||
if options["clear"]:
|
if options["clear"]:
|
||||||
self.clear([Review])
|
self.clear([ReviewLink, Review])
|
||||||
else:
|
else:
|
||||||
self.review(options)
|
self.review(options)
|
||||||
elif options["mark"]:
|
elif options["mark"]:
|
||||||
|
|
|
@ -33,5 +33,9 @@ class CollectionLink(models.Model):
|
||||||
|
|
||||||
|
|
||||||
class ReviewLink(models.Model):
|
class ReviewLink(models.Model):
|
||||||
old_id = models.IntegerField(unique=True)
|
module = models.CharField(max_length=20)
|
||||||
|
old_id = models.IntegerField()
|
||||||
new_uid = models.UUIDField()
|
new_uid = models.UUIDField()
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
unique_together = [["module", "old_id"]]
|
||||||
|
|
Loading…
Add table
Reference in a new issue