2021-03-08 08:49:10 -08:00
|
|
|
""" media that is posted in the app """
|
2020-11-27 17:20:01 -08:00
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
from bookwyrm import activitypub
|
2021-02-04 10:47:03 -08:00
|
|
|
from .activitypub_mixin import ActivitypubMixin
|
2020-11-30 14:24:31 -08:00
|
|
|
from .base_model import BookWyrmModel
|
|
|
|
from . import fields
|
2020-11-27 17:20:01 -08:00
|
|
|
|
|
|
|
|
|
|
|
class Attachment(ActivitypubMixin, BookWyrmModel):
|
2021-04-26 09:15:42 -07:00
|
|
|
"""an image (or, in the future, video etc) associated with a status"""
|
2021-03-08 08:49:10 -08:00
|
|
|
|
2020-12-07 18:28:42 -08:00
|
|
|
status = models.ForeignKey(
|
2021-03-08 08:49:10 -08:00
|
|
|
"Status", on_delete=models.CASCADE, related_name="attachments", null=True
|
2020-11-27 17:20:01 -08:00
|
|
|
)
|
2020-11-30 14:24:31 -08:00
|
|
|
reverse_unfurl = True
|
2021-03-08 08:49:10 -08:00
|
|
|
|
2020-11-27 17:20:01 -08:00
|
|
|
class Meta:
|
2021-04-26 09:15:42 -07:00
|
|
|
"""one day we'll have other types of attachments besides images"""
|
2021-03-08 08:49:10 -08:00
|
|
|
|
2020-11-27 17:20:01 -08:00
|
|
|
abstract = True
|
|
|
|
|
|
|
|
|
|
|
|
class Image(Attachment):
|
2021-04-26 09:15:42 -07:00
|
|
|
"""an image attachment"""
|
2021-03-08 08:49:10 -08:00
|
|
|
|
2020-12-07 18:28:42 -08:00
|
|
|
image = fields.ImageField(
|
2021-03-15 13:55:48 -07:00
|
|
|
upload_to="status/",
|
|
|
|
null=True,
|
|
|
|
blank=True,
|
|
|
|
activitypub_field="url",
|
|
|
|
alt_field="caption",
|
2021-03-08 08:49:10 -08:00
|
|
|
)
|
|
|
|
caption = fields.TextField(null=True, blank=True, activitypub_field="name")
|
2020-11-27 17:20:01 -08:00
|
|
|
|
2021-04-15 16:35:04 -07:00
|
|
|
activity_serializer = activitypub.Document
|