add "media_type" field to Document (does nothing for now)
This commit is contained in:
parent
df87a2d13c
commit
55e4b11eac
3 changed files with 29 additions and 2 deletions
|
@ -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')
|
||||
|
||||
|
|
18
sdbs_pile/pile/migrations/0010_document_media_type.py
Normal file
18
sdbs_pile/pile/migrations/0010_document_media_type.py
Normal file
|
@ -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),
|
||||
),
|
||||
]
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue