diff --git a/sdbs_pile/pile/admin.py b/sdbs_pile/pile/admin.py index 06c0ae6..da5cfea 100644 --- a/sdbs_pile/pile/admin.py +++ b/sdbs_pile/pile/admin.py @@ -33,8 +33,8 @@ class DocumentExternalListFilter(admin.SimpleListFilter): class DocumentAdmin(admin.ModelAdmin): exclude = ('is_removed',) - list_display = ('title', 'author', 'published', 'status', 'has_file', 'public', 'filed_under') - list_filter = ('tags', 'status', DocumentExternalListFilter, 'public') + list_display = ('title', 'author', 'published', 'media_type', 'status', 'has_file', 'public', 'filed_under') + list_filter = ('tags', 'media_type', 'status', DocumentExternalListFilter, 'public') search_fields = ('title', 'author', 'published') actions = ('make_published', 'make_hidden') diff --git a/sdbs_pile/pile/migrations/0010_document_media_type.py b/sdbs_pile/pile/migrations/0010_document_media_type.py new file mode 100644 index 0000000..98ad08a --- /dev/null +++ b/sdbs_pile/pile/migrations/0010_document_media_type.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.4 on 2020-05-21 20:54 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('pile', '0009_auto_20200402_1904'), + ] + + operations = [ + migrations.AddField( + model_name='document', + name='media_type', + field=models.CharField(choices=[('T', 'Text'), ('A', 'Audio'), ('V', 'Video'), ('+', 'Multiple types'), ('X', 'Other')], default='T', max_length=1), + ), + ] diff --git a/sdbs_pile/pile/models.py b/sdbs_pile/pile/models.py index 8fecea2..7edbd4e 100644 --- a/sdbs_pile/pile/models.py +++ b/sdbs_pile/pile/models.py @@ -37,6 +37,13 @@ class Document(SoftDeletableModel): STANDARD = "STD", "Standard" FRAGMENT = "FRG", "Fragment" + class DocumentType(models.TextChoices): + TEXT = "T", "Text" + AUDIO = "A", "Audio" + VIDEO = "V", "Video" + MULTI = "+", "Multiple types" + OTHER = "X", "Other" + title = models.CharField(max_length=512, null=False, blank=False) author = models.CharField(max_length=512, null=False, blank=True) published = models.CharField(max_length=128, null=False, blank=True) @@ -44,6 +51,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) + media_type = models.CharField(null=False, blank=False, + max_length=1, choices=DocumentType.choices, default=DocumentType.TEXT) 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)