Adds image attachment field to status model

This commit is contained in:
Mouse Reeve 2020-11-23 12:48:41 -08:00
parent 56638f79cf
commit dab0aeffb2
3 changed files with 25 additions and 1 deletions

View file

@ -0,0 +1,19 @@
# Generated by Django 3.0.7 on 2020-11-23 20:44
import bookwyrm.utils.fields
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('bookwyrm', '0011_auto_20201113_1727'),
]
operations = [
migrations.AddField(
model_name='status',
name='images',
field=bookwyrm.utils.fields.ArrayField(base_field=models.ImageField(upload_to='status/'), default=list, size=None),
),
]

View file

@ -5,6 +5,7 @@ from django.db import models
from model_utils.managers import InheritanceManager
from bookwyrm import activitypub
from bookwyrm.utils.fields import ArrayField
from .base_model import ActivitypubMixin, OrderedCollectionPageMixin
from .base_model import ActivityMapping, BookWyrmModel, PrivacyLevels
from .base_model import tag_formatter
@ -17,6 +18,10 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
mention_users = models.ManyToManyField('User', related_name='mention_user')
mention_books = models.ManyToManyField(
'Edition', related_name='mention_book')
images = ArrayField(
models.ImageField(upload_to='status/'),
default=list
)
local = models.BooleanField(default=True)
privacy = models.CharField(
max_length=255,

View file

@ -13,7 +13,7 @@ def delete_status(status):
def create_status(activity):
''' unfortunately, it's not QUITE as simple as deserialiing it '''
''' unfortunately, it's not QUITE as simple as deserializing it '''
# render the json into an activity object
serializer = activitypub.activity_objects[activity['type']]
activity = serializer(**activity)