You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
906 B
33 lines
906 B
# -*- coding: utf-8 -*- |
|
from __future__ import unicode_literals |
|
|
|
import uuid |
|
from django.db import models |
|
from django.utils.encoding import python_2_unicode_compatible |
|
from django.utils.translation import ugettext_lazy as _ |
|
|
|
from ..medialibrary.fields import MediaAssetField |
|
|
|
|
|
class UUIDMixin(models.Model): |
|
uuid_hex = models.CharField(max_length=32, null=False, editable=False) |
|
|
|
class Meta: |
|
abstract = True |
|
|
|
# TODO Make auto-initializing UUID-field |
|
def get_uuid(self): |
|
if not self.uuid_hex: |
|
self.uuid_hex = uuid.uuid4().hex |
|
return str(uuid.UUID(self.uuid_hex)) |
|
|
|
|
|
@python_2_unicode_compatible |
|
class MediaAsset(UUIDMixin, models.Model): |
|
original_file = MediaAssetField(_("original file")) |
|
name = models.CharField(_('name'), max_length=50) |
|
simple_file = models.FileField(null=True, blank=True) |
|
|
|
def __str__(self): |
|
return self.name |
|
|
|
|