ernestophone.ens.fr/partitions/models.py
Martin Pépin 26aba814be Ajoute d'un attribut category à PartitionSet
Indique si les partitions concernées sont
- Archivées
- Actives
- À venir
2016-06-21 09:49:45 +02:00

32 lines
921 B
Python

from django.db import models
import os
import Ernestophone.settings
PARTITION_TYPES = (
("active", "Actif"),
("incoming", "À venir"),
("old", "Archive")
)
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)
category = models.CharField('Types de partitions', max_length=8,
choices=PARTITION_TYPES, default="incoming")
def __str__(self):
return("%s - %s [%s]" % (self.nom, self.auteur, self.category))