diff --git a/bookwyrm/models/list.py b/bookwyrm/models/list.py index 5004a9b0..db8c1af6 100644 --- a/bookwyrm/models/list.py +++ b/bookwyrm/models/list.py @@ -1,4 +1,5 @@ ''' make a list of books!! ''' +from django.apps import apps from django.db import models from bookwyrm import activitypub @@ -71,6 +72,22 @@ class ListItem(CollectionItemMixin, BookWyrmModel): object_field = 'book' collection_field = 'book_list' + def save(self, *args, **kwargs): + ''' create a notification too ''' + created = not bool(self.id) + super().save(*args, **kwargs) + list_owner = self.book_list.user + # create a notification if somoene ELSE added to a local user's list + if created and list_owner.local and list_owner != self.user: + model = apps.get_model('bookwyrm.Notification', require_ready=True) + model.objects.create( + user=list_owner, + related_user=self.user, + related_list_item=self, + notification_type='ADD', + ) + + class Meta: ''' an opinionated constraint! you can't put a book on a list twice ''' unique_together = ('book', 'book_list') diff --git a/bookwyrm/templates/lists/list.html b/bookwyrm/templates/lists/list.html index 7899d593..4bd71284 100644 --- a/bookwyrm/templates/lists/list.html +++ b/bookwyrm/templates/lists/list.html @@ -26,7 +26,7 @@
{% include 'snippets/book_titleby.html' with book=item.book %} {% include 'snippets/stars.html' with rating=item.book|rating:request.user %} - {% include 'snippets/shelve_button.html' with book=item.book %} + {% include 'snippets/shelve_button/shelve_button.html' with book=item.book %}
@@ -36,33 +38,34 @@

{# DESCRIPTION #} {% if notification.related_user %} - {% include 'snippets/avatar.html' with user=notification.related_user %} - {% include 'snippets/username.html' with user=notification.related_user %} - {% if notification.notification_type == 'FAVORITE' %} - favorited your - {{ related_status | status_preview_name|safe }} + {% include 'snippets/avatar.html' with user=notification.related_user %} + {% include 'snippets/username.html' with user=notification.related_user %} + {% if notification.notification_type == 'FAVORITE' %} + favorited your + {{ related_status | status_preview_name|safe }} - {% elif notification.notification_type == 'MENTION' %} - mentioned you in a - {{ related_status | status_preview_name|safe }} + {% elif notification.notification_type == 'MENTION' %} + mentioned you in a + {{ related_status | status_preview_name|safe }} - {% elif notification.notification_type == 'REPLY' %} - replied - to your - {{ related_status | status_preview_name|safe }} - {% elif notification.notification_type == 'FOLLOW' %} - followed you - {% include 'snippets/follow_button.html' with user=notification.related_user %} - {% elif notification.notification_type == 'FOLLOW_REQUEST' %} - sent you a follow request -

- {% include 'snippets/follow_request_buttons.html' with user=notification.related_user %} -
- - {% elif notification.notification_type == 'BOOST' %} - boosted your {{ related_status | status_preview_name|safe }} - {% endif %} - {% else %} + {% elif notification.notification_type == 'REPLY' %} + replied + to your + {{ related_status | status_preview_name|safe }} + {% elif notification.notification_type == 'FOLLOW' %} + followed you + {% include 'snippets/follow_button.html' with user=notification.related_user %} + {% elif notification.notification_type == 'FOLLOW_REQUEST' %} + sent you a follow request +
+ {% include 'snippets/follow_request_buttons.html' with user=notification.related_user %} +
+ {% elif notification.notification_type == 'BOOST' %} + boosted your {{ related_status | status_preview_name|safe }} + {% elif notification.notification_type == 'ADD' %} + {% if notification.related_list_item.approved %}added{% else %}suggested adding{% endif %} {% include 'snippets/book_titleby.html' with book=notification.related_list_item.book %} to your list "{{ notification.related_list_item.book_list.name }}" + {% endif %} + {% elif notification.related_import %} your import completed. {% endif %}