Added poster and og_image
This commit is contained in:
@@ -25,7 +25,7 @@ class TranscodingsInline(admin.StackedInline):
|
||||
|
||||
class VideoAdmin(admin.ModelAdmin):
|
||||
model = models.Video
|
||||
fields = ['title', 'description', 'slug']
|
||||
fields = ['title', 'description', 'slug', 'poster', 'og_image', 'created_at']
|
||||
inlines = [TranscodingsInline]
|
||||
|
||||
admin.site.register(models.Video, VideoAdmin)
|
||||
|
||||
@@ -34,11 +34,20 @@ transcoding_types = (
|
||||
TranscodingType(name='video/mp4; codecs="avc1.64001f,mp4a.40.2"', short_name='h.264'),
|
||||
)
|
||||
|
||||
class Upload(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
file = models.FileField()
|
||||
|
||||
def __str__(self):
|
||||
return os.path.basename(self.file.path)
|
||||
|
||||
class Video(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
title = models.CharField(max_length=256)
|
||||
slug = models.CharField(max_length=256, unique=True)
|
||||
description = models.TextField()
|
||||
poster = models.OneToOneField(Upload, on_delete=models.PROTECT, blank=True, null=True, related_name='video_poster')
|
||||
og_image = models.OneToOneField(Upload, on_delete=models.PROTECT, blank=True, null=True, related_name='video_og_image')
|
||||
created_at = models.DateTimeField(default=datetime.now)
|
||||
updated_at = models.DateTimeField(default=datetime.now)
|
||||
|
||||
@@ -49,13 +58,6 @@ class Video(models.Model):
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
class Upload(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
file = models.FileField()
|
||||
|
||||
def __str__(self):
|
||||
return os.path.basename(self.file.path)
|
||||
|
||||
class Transcoding(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
video = models.ForeignKey(Video, on_delete=models.CASCADE, related_name='transcodings')
|
||||
|
||||
Reference in New Issue
Block a user