forked from mirrors/bookwyrm
Adds image attachment field to status model
This commit is contained in:
parent
56638f79cf
commit
dab0aeffb2
3 changed files with 25 additions and 1 deletions
19
bookwyrm/migrations/0012_status_images.py
Normal file
19
bookwyrm/migrations/0012_status_images.py
Normal 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),
|
||||||
|
),
|
||||||
|
]
|
|
@ -5,6 +5,7 @@ from django.db import models
|
||||||
from model_utils.managers import InheritanceManager
|
from model_utils.managers import InheritanceManager
|
||||||
|
|
||||||
from bookwyrm import activitypub
|
from bookwyrm import activitypub
|
||||||
|
from bookwyrm.utils.fields import ArrayField
|
||||||
from .base_model import ActivitypubMixin, OrderedCollectionPageMixin
|
from .base_model import ActivitypubMixin, OrderedCollectionPageMixin
|
||||||
from .base_model import ActivityMapping, BookWyrmModel, PrivacyLevels
|
from .base_model import ActivityMapping, BookWyrmModel, PrivacyLevels
|
||||||
from .base_model import tag_formatter
|
from .base_model import tag_formatter
|
||||||
|
@ -17,6 +18,10 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
|
||||||
mention_users = models.ManyToManyField('User', related_name='mention_user')
|
mention_users = models.ManyToManyField('User', related_name='mention_user')
|
||||||
mention_books = models.ManyToManyField(
|
mention_books = models.ManyToManyField(
|
||||||
'Edition', related_name='mention_book')
|
'Edition', related_name='mention_book')
|
||||||
|
images = ArrayField(
|
||||||
|
models.ImageField(upload_to='status/'),
|
||||||
|
default=list
|
||||||
|
)
|
||||||
local = models.BooleanField(default=True)
|
local = models.BooleanField(default=True)
|
||||||
privacy = models.CharField(
|
privacy = models.CharField(
|
||||||
max_length=255,
|
max_length=255,
|
||||||
|
|
|
@ -13,7 +13,7 @@ def delete_status(status):
|
||||||
|
|
||||||
|
|
||||||
def create_status(activity):
|
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
|
# render the json into an activity object
|
||||||
serializer = activitypub.activity_objects[activity['type']]
|
serializer = activitypub.activity_objects[activity['type']]
|
||||||
activity = serializer(**activity)
|
activity = serializer(**activity)
|
||||||
|
|
Loading…
Reference in a new issue