add "status" to Document, no function yet

This commit is contained in:
Tomáš Mládek 2020-03-29 11:44:10 +02:00
parent edd8ceb858
commit 03c13e2238
2 changed files with 26 additions and 0 deletions

View file

@ -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),
),
]

View file

@ -32,6 +32,12 @@ class DocumentManager(models.Manager):
return self.get_queryset().annotate(tag_count=Count('tags')).filter(tag_count=0) 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): class Document(SoftDeletableModel):
title = models.CharField(max_length=512, null=False, blank=False) title = models.CharField(max_length=512, null=False, blank=False)
author = models.CharField(max_length=512, null=False, blank=True) 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) external_url = models.URLField(null=True, blank=True)
file = models.FileField(null=True, blank=True, storage=FileSystemStorage(location='docs')) file = models.FileField(null=True, blank=True, storage=FileSystemStorage(location='docs'))
public = models.BooleanField(default=True, null=False, blank=False) 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) tags = models.ManyToManyField(Tag, related_name="documents", blank=True)
uploaded = models.DateTimeField(auto_now_add=True, null=True) uploaded = models.DateTimeField(auto_now_add=True, null=True)