25 lines
693 B
Python
25 lines
693 B
Python
from django.db import models
|
|
import os
|
|
|
|
import Ernestophone.settings
|
|
|
|
class Partition(models.Model):
|
|
nom = models.CharField(max_length=100)
|
|
part = models.FileField(upload_to="partitions/")
|
|
morceau = models.ForeignKey('PartitionSet')
|
|
|
|
def __str__(self):
|
|
return self.nom
|
|
|
|
def delete(self, *args, **kwargs):
|
|
os.remove(os.path.join(Ernestophone.settings.MEDIA_ROOT, self.part.name))
|
|
super(Partition, self).delete(*args, **kwargs)
|
|
|
|
class PartitionSet(models.Model):
|
|
nom = models.CharField(max_length=100)
|
|
auteur = models.CharField(max_length=100)
|
|
|
|
def __str__(self):
|
|
return self.nom + " - " + self.auteur
|
|
|
|
# Create your models here.
|