phantasma/app/video/models.py

50 lines
1.4 KiB
Python
Raw Normal View History

2021-09-28 13:10:22 +00:00
import logging
2021-10-11 12:55:45 +00:00
from django.conf import settings
2021-09-28 13:10:22 +00:00
from django.contrib.auth import get_user_model
from django.db import models
logger = logging.getLogger(__name__)
User = get_user_model()
class Film(models.Model):
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
slug = models.SlugField()
public = models.BooleanField(default=False)
2021-10-11 12:55:45 +00:00
position = models.IntegerField(default=0)
2021-09-28 13:10:22 +00:00
padma_id = models.CharField(max_length=255)
2021-10-11 12:55:45 +00:00
vimeo_id = models.CharField(max_length=255, default=None, blank=True)
2021-09-28 13:10:22 +00:00
data = models.JSONField(default=dict, blank=True)
def __str__(self):
return self.data.get('title', self.slug)
2021-10-10 15:06:43 +00:00
def get_absolute_url(self):
return '/' + settings.URL_PREFIX + 'film/' + self.slug
def related_texts(self):
from ..text.models import Text
return Text.objects.filter(data__item=self.padma_id)
2021-09-28 13:10:22 +00:00
class Edit(models.Model):
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
slug = models.SlugField()
public = models.BooleanField(default=False)
padma_id = models.CharField(max_length=1024)
annotation_user = models.CharField(max_length=1024)
vimeo_id = models.CharField(max_length=255, default=None, null=True)
data = models.JSONField(default=dict, blank=True)
def __str__(self):
return self.data.get('title', self.slug)