Updates status model and serializer
This commit is contained in:
parent
8bc0a57bd4
commit
3966c84e08
7 changed files with 167 additions and 166 deletions
|
@ -3,30 +3,27 @@ from django.db import models
|
|||
|
||||
from bookwyrm import activitypub
|
||||
from .base_model import ActivitypubMixin
|
||||
from .base_model import ActivityMapping, BookWyrmModel
|
||||
from .base_model import BookWyrmModel
|
||||
from . import fields
|
||||
|
||||
|
||||
class Attachment(ActivitypubMixin, BookWyrmModel):
|
||||
''' an image (or, in the future, video etc) associated with a status '''
|
||||
status = models.ForeignKey(
|
||||
status = fields.ForeignKey(
|
||||
'Status',
|
||||
on_delete=models.CASCADE,
|
||||
related_name='attachments',
|
||||
null=True
|
||||
)
|
||||
reverse_unfurl = True
|
||||
class Meta:
|
||||
''' one day we'll have other types of attachments besides images '''
|
||||
abstract = True
|
||||
|
||||
activity_mappings = [
|
||||
ActivityMapping('id', 'remote_id'),
|
||||
ActivityMapping('url', 'image'),
|
||||
ActivityMapping('name', 'caption'),
|
||||
]
|
||||
|
||||
class Image(Attachment):
|
||||
''' an image attachment '''
|
||||
image = models.ImageField(upload_to='status/', null=True, blank=True)
|
||||
caption = models.TextField(null=True, blank=True)
|
||||
image = fields.ImageField(upload_to='status/', null=True, blank=True)
|
||||
caption = fields.TextField(null=True, blank=True)
|
||||
|
||||
activity_serializer = activitypub.Image
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue