diff --git a/bookwyrm/activitypub/base_activity.py b/bookwyrm/activitypub/base_activity.py index f6a3f9b1e..62fce70b2 100644 --- a/bookwyrm/activitypub/base_activity.py +++ b/bookwyrm/activitypub/base_activity.py @@ -227,7 +227,8 @@ def image_attachments_formatter(images_json): ''' deserialize a list of images ''' attachments = [] for image in images_json: - attachment = models.Attachment() + caption = image.get('name') + attachment = models.Attachment(caption=caption) image_field = image_formatter(image) attachment.image.save(*image_field, save=False) attachments.append(attachment) diff --git a/bookwyrm/migrations/0012_attachment.py b/bookwyrm/migrations/0012_attachment.py index 2af545a86..495538517 100644 --- a/bookwyrm/migrations/0012_attachment.py +++ b/bookwyrm/migrations/0012_attachment.py @@ -1,4 +1,4 @@ -# Generated by Django 3.0.7 on 2020-11-24 17:46 +# Generated by Django 3.0.7 on 2020-11-24 19:39 from django.db import migrations, models import django.db.models.deletion @@ -19,6 +19,7 @@ class Migration(migrations.Migration): ('updated_date', models.DateTimeField(auto_now=True)), ('remote_id', models.CharField(max_length=255, null=True)), ('image', models.ImageField(blank=True, null=True, upload_to='status/')), + ('caption', models.TextField(blank=True, null=True)), ('status', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attachments', to='bookwyrm.Status')), ], options={ diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index dcf4c4715..6f534f506 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -159,6 +159,7 @@ class Attachment(BookWyrmModel): related_name='attachments' ) image = models.ImageField(upload_to='status/', null=True, blank=True) + caption = models.TextField(null=True, blank=True) class GeneratedNote(Status): diff --git a/bookwyrm/templates/snippets/status_content.html b/bookwyrm/templates/snippets/status_content.html index eac372711..834549ea2 100644 --- a/bookwyrm/templates/snippets/status_content.html +++ b/bookwyrm/templates/snippets/status_content.html @@ -21,7 +21,7 @@ {% if status.attachments %}
{% for attachment in status.attachments.all %} - + {{ attachment.caption }} {% endfor %}
{% endif %} diff --git a/bw-dev b/bw-dev index 22ca9412e..6d74924ff 100755 --- a/bw-dev +++ b/bw-dev @@ -61,7 +61,7 @@ case "$1" in ;; migrate) execweb python manage.py rename_app fedireads bookwyrm - execweb python manage.py migrate + execweb python manage.py "$@" ;; bash) execweb bash