From 03c13e2238126f01fc9143da15780fe780e381c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Sun, 29 Mar 2020 11:44:10 +0200 Subject: [PATCH] add "status" to Document, no function yet --- .../pile/migrations/0007_document_status.py | 18 ++++++++++++++++++ sdbs_pile/pile/models.py | 8 ++++++++ 2 files changed, 26 insertions(+) create mode 100644 sdbs_pile/pile/migrations/0007_document_status.py diff --git a/sdbs_pile/pile/migrations/0007_document_status.py b/sdbs_pile/pile/migrations/0007_document_status.py new file mode 100644 index 0000000..17cccd5 --- /dev/null +++ b/sdbs_pile/pile/migrations/0007_document_status.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.4 on 2020-03-29 09:42 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('pile', '0006_auto_20200329_1132'), + ] + + operations = [ + migrations.AddField( + model_name='document', + name='status', + field=models.CharField(choices=[('REF', 'Referential'), ('STD', 'Standard'), ('FRG', 'Fragment')], default='STD', max_length=3), + ), + ] diff --git a/sdbs_pile/pile/models.py b/sdbs_pile/pile/models.py index 802d7df..26da648 100644 --- a/sdbs_pile/pile/models.py +++ b/sdbs_pile/pile/models.py @@ -32,6 +32,12 @@ class DocumentManager(models.Manager): return self.get_queryset().annotate(tag_count=Count('tags')).filter(tag_count=0) +class DocumentStatus(models.TextChoices): + REFERENCE = "REF", "Referential" + STANDARD = "STD", "Standard" + FRAGMENT = "FRG", "Fragment" + + class Document(SoftDeletableModel): title = models.CharField(max_length=512, null=False, blank=False) author = models.CharField(max_length=512, null=False, blank=True) @@ -40,6 +46,8 @@ class Document(SoftDeletableModel): external_url = models.URLField(null=True, blank=True) file = models.FileField(null=True, blank=True, storage=FileSystemStorage(location='docs')) public = models.BooleanField(default=True, null=False, blank=False) + status = models.CharField(null=False, blank=False, + max_length=3, choices=DocumentStatus.choices, default=DocumentStatus.STANDARD) tags = models.ManyToManyField(Tag, related_name="documents", blank=True) uploaded = models.DateTimeField(auto_now_add=True, null=True)