diff --git a/bookwyrm/models/__init__.py b/bookwyrm/models/__init__.py index 9edb89286..c455c751f 100644 --- a/bookwyrm/models/__init__.py +++ b/bookwyrm/models/__init__.py @@ -27,7 +27,7 @@ from .group import Group, GroupMember, GroupMemberInvitation from .import_job import ImportJob, ImportItem -from .move import MoveUser, MoveUserNotification +from .move import MoveUser from .site import SiteSettings, Theme, SiteInvite from .site import PasswordReset, InviteRequest diff --git a/bookwyrm/models/move.py b/bookwyrm/models/move.py index ef7cad372..a5bf9d76d 100644 --- a/bookwyrm/models/move.py +++ b/bookwyrm/models/move.py @@ -6,6 +6,7 @@ from bookwyrm import activitypub from .activitypub_mixin import ActivityMixin from .base_model import BookWyrmModel from . import fields +from .notification import Notification class Move(ActivityMixin, BookWyrmModel): @@ -63,25 +64,9 @@ class MoveUser(Move): for follower in self.user.followers.all(): if follower.local: - MoveUserNotification.objects.create(user=follower, target=self.user) + Notification.notify( + follower, self.user, notification_type=Notification.MOVE + ) else: raise PermissionDenied() - - -class MoveUserNotification(models.Model): - """notify followers that the user has moved""" - - created_date = models.DateTimeField(auto_now_add=True) - - user = models.ForeignKey( - "User", on_delete=models.PROTECT, related_name="moved_user_notifications" - ) # user we are notifying - - target = models.ForeignKey( - "User", on_delete=models.PROTECT, related_name="moved_user_notification_target" - ) # new account of user who moved - - def save(self, *args, **kwargs): - """send notification""" - super().save(*args, **kwargs) diff --git a/bookwyrm/models/notification.py b/bookwyrm/models/notification.py index 9026b23df..093c25c65 100644 --- a/bookwyrm/models/notification.py +++ b/bookwyrm/models/notification.py @@ -2,14 +2,7 @@ from django.db import models, transaction from django.dispatch import receiver from .base_model import BookWyrmModel -from . import ( - Boost, - Favorite, - GroupMemberInvitation, - ImportJob, - LinkDomain, - MoveUserNotification, -) +from . import Boost, Favorite, GroupMemberInvitation, ImportJob, LinkDomain from . import ListItem, Report, Status, User, UserFollowRequest @@ -336,12 +329,3 @@ def notify_user_on_follow(sender, instance, created, *args, **kwargs): notification_type=Notification.FOLLOW, read=False, ) - - -@receiver(models.signals.post_save, sender=MoveUserNotification) -# pylint: disable=unused-argument -def notify_on_move(sender, instance, *args, **kwargs): - """someone migrated their account""" - Notification.notify( - instance.user, instance.target, notification_type=Notification.MOVE - ) diff --git a/bookwyrm/templates/feed/layout.html b/bookwyrm/templates/feed/layout.html index 3a17e3e0b..1a2fb33c6 100644 --- a/bookwyrm/templates/feed/layout.html +++ b/bookwyrm/templates/feed/layout.html @@ -5,22 +5,6 @@ {% block title %}{% trans "Updates" %}{% endblock %} {% block content %} -{% if user.moved_to %} -
-
-

- {% trans "You have have moved to" %} - {% id_to_username user.moved_to %} -

-

{% trans "You can undo this move to restore full functionality, but some followers may have already unfollowed this account." %}

-
- {% csrf_token %} - - -
-
-
-{% else %}
{% if user.is_authenticated %}
@@ -44,7 +28,6 @@ {% endif %}
-{% endif %} {% endblock %} diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html index e6f8a6f84..9b726d4ca 100644 --- a/bookwyrm/templates/layout.html +++ b/bookwyrm/templates/layout.html @@ -30,10 +30,11 @@ + {% if not request.user.moved_to %} \ No newline at end of file diff --git a/bookwyrm/templates/notifications/items/move_user.html b/bookwyrm/templates/notifications/items/move_user.html index 04163bc12..ba83ffa9c 100644 --- a/bookwyrm/templates/notifications/items/move_user.html +++ b/bookwyrm/templates/notifications/items/move_user.html @@ -14,11 +14,15 @@ {% block description %} {% if related_user_moved_to %} - {{ related_user }} {% trans "has moved to" %} {% id_to_username related_user_moved_to %} + {% blocktrans %} + {{ related_user }} has moved to + {% endblocktrans %}{% id_to_username related_user_moved_to %}
{% include 'snippets/move_user_buttons.html' with group=notification.related_group %}
{% else %} - {{ related_user }} {% trans "has undone their move" %} + {% blocktrans %} + {{ related_user }} has undone their move + {% endblocktrans %} {% endif %} {% endblock %} diff --git a/bookwyrm/templates/preferences/move_user.html b/bookwyrm/templates/preferences/move_user.html index aa1b9f12d..47b370e82 100644 --- a/bookwyrm/templates/preferences/move_user.html +++ b/bookwyrm/templates/preferences/move_user.html @@ -16,7 +16,9 @@ {% trans "Moving your account will notify all your followers and direct them to follow the new account." %}

- {{ user.username }} {% trans "will be marked as moved and will not be discoverable or usable unless you undo the move." %} + {% blocktrans %} + {{ user }} will be marked as moved and will not be discoverable or usable unless you undo the move. + {% endblocktrans %}