1
0
Fork 0

Consistent use of plurals

This commit is contained in:
Mouse Reeve 2022-07-05 14:44:15 -07:00
parent 7508ae9eae
commit e54c563865
4 changed files with 11 additions and 20 deletions

View file

@ -156,7 +156,6 @@ class ListItem(CollectionItemMixin, BookWyrmModel):
self.book_list.updated_date = timezone.now() self.book_list.updated_date = timezone.now()
self.book_list.save(broadcast=False, update_fields=["updated_date"]) self.book_list.save(broadcast=False, update_fields=["updated_date"])
def raise_not_deletable(self, viewer): def raise_not_deletable(self, viewer):
"""the associated user OR the list owner can delete""" """the associated user OR the list owner can delete"""
if self.book_list.user == viewer: if self.book_list.user == viewer:

View file

@ -69,18 +69,17 @@ class Notification(BookWyrmModel):
@classmethod @classmethod
@transaction.atomic @transaction.atomic
def notify_list_item(cls, user, list_item): def notify_list_item(cls, user, list_item):
""" Group the notifications around the list items, not the user """ """Group the notifications around the list items, not the user"""
related_user = list_item.user related_user = list_item.user
notification = cls.objects.filter( notification = cls.objects.filter(
user=user, user=user,
related_users=related_user, related_users=related_user,
related_list_items__book_list=list_item.book_list, related_list_items__book_list=list_item.book_list,
notification_type=Notification.ADD notification_type=Notification.ADD,
).first() ).first()
if not notification: if not notification:
notification = cls.objects.create( notification = cls.objects.create(
user=user, user=user, notification_type=Notification.ADD
notification_type=Notification.ADD
) )
notification.related_users.add(related_user) notification.related_users.add(related_user)
notification.related_list_items.add(list_item) notification.related_list_items.add(list_item)
@ -252,15 +251,9 @@ def notify_user_on_list_item_add(sender, instance, created, *args, **kwargs):
# create a notification if somoene ELSE added to a local user's list # create a notification if somoene ELSE added to a local user's list
if list_owner.local and list_owner != instance.user: if list_owner.local and list_owner != instance.user:
# keep the related_user singular, group the items # keep the related_user singular, group the items
Notification.notify_list_item( Notification.notify_list_item(list_owner, instance)
list_owner,
instance
)
if instance.book_list.group: if instance.book_list.group:
for membership in instance.book_list.group.memberships.all(): for membership in instance.book_list.group.memberships.all():
if membership.user != instance.user: if membership.user != instance.user:
Notification.notify_list_item( Notification.notify_list_item(membership.user, instance)
membership.user,
instance
)

View file

@ -4,7 +4,7 @@
{% load utilities %} {% load utilities %}
{% block primary_link %}{% spaceless %} {% block primary_link %}{% spaceless %}
{{ notification.related_user.local_path }} {% url 'user-followers' request.user.localname %}
{% endspaceless %}{% endblock %} {% endspaceless %}{% endblock %}
{% block icon %} {% block icon %}
@ -12,7 +12,6 @@
{% endblock %} {% endblock %}
{% block description %} {% block description %}
{% if related_user_count == 1 %} {% if related_user_count == 1 %}
{% blocktrans trimmed %} {% blocktrans trimmed %}
<a href="{{ related_user_link }}">{{ related_user }}</a> followed you <a href="{{ related_user_link }}">{{ related_user }}</a> followed you
@ -24,8 +23,7 @@
{% endblocktrans %} {% endblocktrans %}
{% else %} {% else %}
{% blocktrans trimmed %} {% blocktrans trimmed %}
<a href="{{ related_user_link }}">{{ related_user }}</a>, <a href="{{ related_user_link }}">{{ related_user }}</a> and {{ other_user_display_count }} others followed you
<a href="{{ second_user_link }}">{{ second_user }}</a>, and {{ other_user_display_count }} users followed you
{% endblocktrans %} {% endblocktrans %}
{% endif %} {% endif %}

View file

@ -2,7 +2,7 @@
{% load humanize %} {% load humanize %}
{% related_status notification as related_status %} {% related_status notification as related_status %}
{% with related_users=notification.related_users.all %} {% with related_users=notification.related_users.all.distinct %}
{% with related_user_count=notification.related_users.count %} {% with related_user_count=notification.related_users.count %}
<div class="notification {% if notification.id in unread %}has-background-primary{% endif %}"> <div class="notification {% if notification.id in unread %}has-background-primary{% endif %}">
<div class="columns is-mobile {% if notification.id in unread %}has-text-white{% else %}has-text-more-muted{% endif %}"> <div class="columns is-mobile {% if notification.id in unread %}has-text-white{% else %}has-text-more-muted{% endif %}">
@ -40,8 +40,8 @@
{% with related_user=related_users.first.display_name %} {% with related_user=related_users.first.display_name %}
{% with related_user_link=related_users.first.local_path %} {% with related_user_link=related_users.first.local_path %}
{% with second_user=related_users.all.1.display_name %} {% with second_user=related_users.1.display_name %}
{% with second_user_link=related_users.all.1.local_path %} {% with second_user_link=related_users.1.local_path %}
{% with other_user_count=related_user_count|add:"-1" %} {% with other_user_count=related_user_count|add:"-1" %}
{% with other_user_display_count=other_user_count|intcomma %} {% with other_user_display_count=other_user_count|intcomma %}
{% block description %}{% endblock %} {% block description %}{% endblock %}
@ -63,3 +63,4 @@
</div> </div>
</div> </div>
{% endwith %} {% endwith %}
{% endwith %}