mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-05 18:24:21 +02:00
Initial commit that merge both the front end and the API in the same repository
This commit is contained in:
commit
76f98b74dd
285 changed files with 51318 additions and 0 deletions
61
api/funkwhale_api/music/migrations/0011_rename_files.py
Normal file
61
api/funkwhale_api/music/migrations/0011_rename_files.py
Normal file
|
@ -0,0 +1,61 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import os
|
||||
|
||||
from django.db import migrations, models
|
||||
from funkwhale_api.common.utils import rename_file
|
||||
|
||||
|
||||
def rename_files(apps, schema_editor):
|
||||
"""
|
||||
This migration script is utterly broken and made me redownload all my audio files.
|
||||
So next time -> Write some actual tests before running a migration script
|
||||
on thousand of tracks...
|
||||
"""
|
||||
return
|
||||
# TrackFile = apps.get_model("music", "TrackFile")
|
||||
# qs = TrackFile.objects.select_related(
|
||||
# 'track__album__artist', 'track__artist')
|
||||
# total = len(qs)
|
||||
#
|
||||
#
|
||||
# for i, tf in enumerate(qs):
|
||||
# try:
|
||||
# new_name = '{} - {} - {}'.format(
|
||||
# tf.track.artist.name,
|
||||
# tf.track.album.title,
|
||||
# tf.track.title,
|
||||
# )
|
||||
# except AttributeError:
|
||||
# new_name = '{} - {}'.format(
|
||||
# tf.track.artist.name,
|
||||
# tf.track.title,
|
||||
# )
|
||||
# rename_file(
|
||||
# instance=tf,
|
||||
# field_name='audio_file',
|
||||
# allow_missing_file=True,
|
||||
# new_name=new_name)
|
||||
# print('Renamed file {}/{} (new name: {})'.format(
|
||||
# i + 1, total, tf.audio_file.name
|
||||
# ))
|
||||
|
||||
|
||||
def rewind(apps, schema_editor):
|
||||
pass
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('music', '0010_auto_20160920_1742'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='trackfile',
|
||||
name='audio_file',
|
||||
field=models.FileField(upload_to='tracks/%Y/%m/%d', max_length=255),
|
||||
),
|
||||
migrations.RunPython(rename_files, rewind),
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue