Ajoute d'un attribut category à PartitionSet

Indique si les partitions concernées sont
- Archivées
- Actives
- À venir
This commit is contained in:
Martin Pépin 2016-06-21 09:49:45 +02:00
parent 4560eebf3e
commit 26aba814be
2 changed files with 29 additions and 2 deletions

View file

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('partitions', '0005_partition_morceau'),
]
operations = [
migrations.AddField(
model_name='partitionset',
name='category',
field=models.CharField(choices=[('active', 'Actif'), ('incoming', 'À venir'), ('old', 'Archive')], max_length=8, verbose_name='Types de partitions', default='incoming'),
preserve_default=True,
),
]

View file

@ -3,6 +3,12 @@ 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/")
@ -18,8 +24,9 @@ class Partition(models.Model):
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 self.nom + " - " + self.auteur
return("%s - %s [%s]" % (self.nom, self.auteur, self.category))
# Create your models here.