diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index dbe3cb88..29c6b6de 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -159,3 +159,8 @@ class CreateInviteForm(CustomForm): choices=[(i, "%d uses" % (i,)) for i in [1, 5, 10, 25, 50, 100]] + [(None, 'Unlimited')]) } + +class ShelfForm(CustomForm): + class Meta: + model = models.Shelf + fields = ['user', 'name', 'privacy'] 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..e85294ba 100644 --- a/bookwyrm/models/shelf.py +++ b/bookwyrm/models/shelf.py @@ -1,8 +1,9 @@ ''' puttin' books on shelves ''' +import re 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 +12,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, @@ -18,6 +24,15 @@ class Shelf(OrderedCollectionMixin, BookWyrmModel): through_fields=('shelf', 'book') ) + def save(self, *args, **kwargs): + ''' set the identifier ''' + saved = super().save(*args, **kwargs) + if not self.identifier: + slug = re.sub(r'[^\w]', '', self.name).lower() + self.identifier = '%s-%d' % (slug, self.id) + return super().save(*args, **kwargs) + return saved + @property def collection_queryset(self): ''' list of books for this shelf, overrides OrderedCollectionMixin ''' diff --git a/bookwyrm/static/css/fonts/icomoon.eot b/bookwyrm/static/css/fonts/icomoon.eot index 0c2680e2..30ae2cd5 100644 Binary files a/bookwyrm/static/css/fonts/icomoon.eot and b/bookwyrm/static/css/fonts/icomoon.eot differ diff --git a/bookwyrm/static/css/fonts/icomoon.svg b/bookwyrm/static/css/fonts/icomoon.svg index 4edc7913..aa0a9e5d 100644 --- a/bookwyrm/static/css/fonts/icomoon.svg +++ b/bookwyrm/static/css/fonts/icomoon.svg @@ -37,4 +37,5 @@ + \ No newline at end of file diff --git a/bookwyrm/static/css/fonts/icomoon.ttf b/bookwyrm/static/css/fonts/icomoon.ttf index 58aeb8fe..40d6e886 100644 Binary files a/bookwyrm/static/css/fonts/icomoon.ttf and b/bookwyrm/static/css/fonts/icomoon.ttf differ diff --git a/bookwyrm/static/css/fonts/icomoon.woff b/bookwyrm/static/css/fonts/icomoon.woff index 2483f599..6cfa9a4d 100644 Binary files a/bookwyrm/static/css/fonts/icomoon.woff and b/bookwyrm/static/css/fonts/icomoon.woff differ diff --git a/bookwyrm/static/css/icons.css b/bookwyrm/static/css/icons.css index dafaca21..536db560 100644 --- a/bookwyrm/static/css/icons.css +++ b/bookwyrm/static/css/icons.css @@ -1,10 +1,10 @@ @font-face { font-family: 'icomoon'; - src: url('fonts/icomoon.eot?jhaogg'); - src: url('fonts/icomoon.eot?jhaogg#iefix') format('embedded-opentype'), - url('fonts/icomoon.ttf?jhaogg') format('truetype'), - url('fonts/icomoon.woff?jhaogg') format('woff'), - url('fonts/icomoon.svg?jhaogg#icomoon') format('svg'); + src: url('fonts/icomoon.eot?rd4abb'); + src: url('fonts/icomoon.eot?rd4abb#iefix') format('embedded-opentype'), + url('fonts/icomoon.ttf?rd4abb') format('truetype'), + url('fonts/icomoon.woff?rd4abb') format('woff'), + url('fonts/icomoon.svg?rd4abb#icomoon') format('svg'); font-weight: normal; font-style: normal; font-display: block; @@ -115,3 +115,6 @@ .icon-heart:before { content: "\e9da"; } +.icon-plus:before { + content: "\ea0a"; +} diff --git a/bookwyrm/templates/followers.html b/bookwyrm/templates/followers.html index a5fdfd82..645e46a1 100644 --- a/bookwyrm/templates/followers.html +++ b/bookwyrm/templates/followers.html @@ -1,6 +1,16 @@ {% extends 'layout.html' %} {% load fr_display %} {% block content %} +
+

+ {% if is_self %}Your + {% else %} + {% include 'snippets/username.html' with user=user possessive=True %} + {% endif %} + followers +

+
+ {% include 'snippets/user_header.html' with user=user %}
diff --git a/bookwyrm/templates/following.html b/bookwyrm/templates/following.html index c3bf976a..2cca9127 100644 --- a/bookwyrm/templates/following.html +++ b/bookwyrm/templates/following.html @@ -1,6 +1,16 @@ {% extends 'layout.html' %} {% load fr_display %} {% block content %} +
+

+ Users following + {% if is_self %}you + {% else %} + {% include 'snippets/username.html' with user=user %} + {% endif %} +

+
+ {% include 'snippets/user_header.html' with user=user %}
diff --git a/bookwyrm/templates/shelf.html b/bookwyrm/templates/shelf.html index 8e6cc9f8..d6842d13 100644 --- a/bookwyrm/templates/shelf.html +++ b/bookwyrm/templates/shelf.html @@ -1,17 +1,122 @@ {% extends 'layout.html' %} {% load fr_display %} {% block content %} + +
+
+

+ {% if is_self %}Your + {% else %} + {% include 'snippets/username.html' with user=user possessive=True %} + {% endif %} + shelves +

+
+
+ {% include 'snippets/user_header.html' with user=user %} -
-
- +
+
+
+ +
+
+ + {% if is_self %} +
+ + +
+ {% endif %} +
+ + + + +
+
+

+ {{ shelf.name }} + + {% include 'snippets/privacy-icons.html' with item=shelf %} + +

+
+ {% if is_self %} +
+ + +
+ {% endif %} +
+ + + diff --git a/bookwyrm/templates/snippets/privacy-icons.html b/bookwyrm/templates/snippets/privacy-icons.html new file mode 100644 index 00000000..b911f128 --- /dev/null +++ b/bookwyrm/templates/snippets/privacy-icons.html @@ -0,0 +1,18 @@ +{% if item.privacy == 'public' %} + + Public post + +{% elif item.privacy == 'unlisted' %} + + Unlisted post + +{% elif item.privacy == 'followers' %} + + Followers-only post + +{% else %} + + Private post + +{% endif %} + diff --git a/bookwyrm/templates/snippets/privacy_select.html b/bookwyrm/templates/snippets/privacy_select.html index 83ea9bea..c8d974c0 100644 --- a/bookwyrm/templates/snippets/privacy_select.html +++ b/bookwyrm/templates/snippets/privacy_select.html @@ -5,10 +5,18 @@ {% endif %} {% endwith %}
diff --git a/bookwyrm/templates/snippets/shelf.html b/bookwyrm/templates/snippets/shelf.html index 1ca5ed60..2df8b024 100644 --- a/bookwyrm/templates/snippets/shelf.html +++ b/bookwyrm/templates/snippets/shelf.html @@ -76,5 +76,15 @@ {% else %}

This shelf is empty.

+{% if shelf.editable %} +
+ {% csrf_token %} + + +
+{% endif %} + {% endif %} diff --git a/bookwyrm/templates/snippets/status_body.html b/bookwyrm/templates/snippets/status_body.html index 1c1d41de..05e890b9 100644 --- a/bookwyrm/templates/snippets/status_body.html +++ b/bookwyrm/templates/snippets/status_body.html @@ -60,23 +60,7 @@