moviewyrm/bookwyrm/models/attachment.py

30 lines
852 B
Python
Raw Normal View History

''' media that is posted in the app '''
from django.db import models
from bookwyrm import activitypub
from .base_model import ActivitypubMixin
2020-11-30 22:24:31 +00:00
from .base_model import BookWyrmModel
from . import fields
class Attachment(ActivitypubMixin, BookWyrmModel):
''' an image (or, in the future, video etc) associated with a status '''
2020-11-30 22:24:31 +00:00
status = fields.ForeignKey(
'Status',
on_delete=models.CASCADE,
2020-11-28 04:11:22 +00:00
related_name='attachments',
null=True
)
2020-11-30 22:24:31 +00:00
reverse_unfurl = True
class Meta:
''' one day we'll have other types of attachments besides images '''
abstract = True
class Image(Attachment):
''' an image attachment '''
2020-11-30 22:24:31 +00:00
image = fields.ImageField(upload_to='status/', null=True, blank=True)
caption = fields.TextField(null=True, blank=True)
activity_serializer = activitypub.Image