Commit a22fe792 authored by fred's avatar fred

add filename to NonstopFile model

This will be useful once all files are moved to the same directory and a
symlink farm put in use.
parent f0bed937
......@@ -66,5 +66,6 @@ class Command(BaseCommand):
track.sabam = False
nonstopfile.track = track
nonstopfile.filename = os.path.basename(nonstopfile.filepath)
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
from django.db import migrations, models
def create_filenames(apps, schema_editor):
NonstopFile = apps.get_model('nonstop', 'NonstopFile')
for nonstop_file in NonstopFile.objects.filter(filename__isnull=True):
nonstop_file.filename = os.path.basename(nonstop_file.filepath)
class Migration(migrations.Migration):
dependencies = [
('nonstop', '0004_auto_20170418_1525'),
operations = [
field=models.CharField(max_length=255, null=True, verbose_name='Filename', unique=True),
migrations.RunPython(create_filenames, lambda x, y: None),
......@@ -50,6 +50,7 @@ class Track(models.Model):
class NonstopFile(models.Model):
filepath = models.CharField(_('Filepath'), max_length=255)
filename = models.CharField(_('Filename'), max_length=255, null=True, unique=True)
creation_timestamp = models.DateTimeField(auto_now_add=True, null=True)
track = models.ForeignKey(Track, null=True)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment