From ab0f9230c72a23ae4fdaa7654bc0067f151165b4 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 10 Nov 2020 13:39:58 -0800 Subject: [PATCH] Adds privacy setting to shelves --- bookwyrm/migrations/0009_shelf_privacy.py | 18 ++++++++++++++++++ bookwyrm/models/shelf.py | 7 ++++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 bookwyrm/migrations/0009_shelf_privacy.py diff --git a/bookwyrm/migrations/0009_shelf_privacy.py b/bookwyrm/migrations/0009_shelf_privacy.py new file mode 100644 index 00000000..8232c2ed --- /dev/null +++ b/bookwyrm/migrations/0009_shelf_privacy.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.7 on 2020-11-10 20:53 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('bookwyrm', '0008_work_default_edition'), + ] + + operations = [ + migrations.AddField( + model_name='shelf', + name='privacy', + field=models.CharField(choices=[('public', 'Public'), ('unlisted', 'Unlisted'), ('followers', 'Followers'), ('direct', 'Direct')], default='public', max_length=255), + ), + ] diff --git a/bookwyrm/models/shelf.py b/bookwyrm/models/shelf.py index cd82198c..dafc8ff5 100644 --- a/bookwyrm/models/shelf.py +++ b/bookwyrm/models/shelf.py @@ -2,7 +2,7 @@ from django.db import models from bookwyrm import activitypub -from .base_model import BookWyrmModel, OrderedCollectionMixin +from .base_model import BookWyrmModel, OrderedCollectionMixin, PrivacyLevels class Shelf(OrderedCollectionMixin, BookWyrmModel): @@ -11,6 +11,11 @@ class Shelf(OrderedCollectionMixin, BookWyrmModel): identifier = models.CharField(max_length=100) user = models.ForeignKey('User', on_delete=models.PROTECT) editable = models.BooleanField(default=True) + privacy = models.CharField( + max_length=255, + default='public', + choices=PrivacyLevels.choices + ) books = models.ManyToManyField( 'Edition', symmetrical=False,