mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-23 01:51:08 +00:00
fixes to move layout and notifs
- make Move notifications less complicated - moved users cannot do anything other than unmove or log out - refactor translations for moved users
This commit is contained in:
parent
088b9ab555
commit
6f3b1b565f
8 changed files with 75 additions and 64 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
|
|
@ -5,22 +5,6 @@
|
|||
{% block title %}{% trans "Updates" %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% if user.moved_to %}
|
||||
<div class="container my-6">
|
||||
<div class="notification is-info has-text-centered">
|
||||
<p>
|
||||
{% trans "You have have moved to" %}
|
||||
<a href="{{user.moved_to}}">{% id_to_username user.moved_to %}</a>
|
||||
</p>
|
||||
<p> {% trans "You can undo this move to restore full functionality, but some followers may have already unfollowed this account." %}</p>
|
||||
<form name="remove-alias" action="{% url 'prefs-unmove' %}" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="remote_id" id="remote_id" value="{{user.moved_to}}">
|
||||
<button type="submit" class="button is-small">{% trans "Undo move" %}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="columns">
|
||||
{% if user.is_authenticated %}
|
||||
<div class="column is-one-third">
|
||||
|
@ -44,7 +28,6 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
|
|
@ -30,10 +30,11 @@
|
|||
<a class="navbar-item" href="/">
|
||||
<img class="image logo" src="{% if site.logo_small %}{% get_media_prefix %}{{ site.logo_small }}{% else %}{% static "images/logo-small.png" %}{% endif %}" alt="{% blocktrans with site_name=site.name %}{{ site_name }} home page{% endblocktrans %}" loading="lazy" decoding="async">
|
||||
</a>
|
||||
{% if not request.user.moved_to %}
|
||||
<form class="navbar-item column is-align-items-start pt-5" action="{% url 'search' %}">
|
||||
<div class="field has-addons">
|
||||
<div class="control">
|
||||
{% if user.is_authenticated %}
|
||||
{% if request.user.is_authenticated %}
|
||||
{% trans "Search for a book, user, or list" as search_placeholder %}
|
||||
{% else %}
|
||||
{% trans "Search for a book" as search_placeholder %}
|
||||
|
@ -79,7 +80,6 @@
|
|||
</strong>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="navbar-menu" id="main_nav">
|
||||
<div class="navbar-start" id="tour-navbar-start">
|
||||
{% if request.user.is_authenticated %}
|
||||
|
@ -151,6 +151,7 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
</nav>
|
||||
|
@ -167,11 +168,15 @@
|
|||
|
||||
<main class="section is-flex-grow-1">
|
||||
<div class="container">
|
||||
{# almost every view needs to know the user shelves #}
|
||||
{% with request.user.shelf_set.all as user_shelves %}
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
{% endwith %}
|
||||
{% if request.user.moved_to %}
|
||||
{% include "moved.html" %}
|
||||
{% else %}
|
||||
{# almost every view needs to know the user shelves #}
|
||||
{% with request.user.shelf_set.all as user_shelves %}
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</main>
|
||||
|
||||
|
|
48
bookwyrm/templates/moved.html
Normal file
48
bookwyrm/templates/moved.html
Normal file
|
@ -0,0 +1,48 @@
|
|||
{% load i18n %}
|
||||
{% load static %}
|
||||
{% load utilities %}
|
||||
|
||||
<div class="container my-6">
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<div class="media">
|
||||
<div class="media-left">
|
||||
<figure class="image is-48x48">
|
||||
<img src="{% if request.user.avatar %}{% get_media_prefix %}{{ request.user.avatar }}{% else %}{% static "images/default_avi.jpg" %}{% endif %}">
|
||||
</figure>
|
||||
</div>
|
||||
<div class="media-content">
|
||||
<p class="title is-4">{{ request.user.display_name }}</p>
|
||||
<p class="subtitle is-6"><s>{{request.user.username}}</s></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="notification is-warning">
|
||||
<p>
|
||||
{% blocktrans %}
|
||||
<strong>You have moved your account</strong> to <a href="{{user.moved_to}}">
|
||||
{% endblocktrans %}
|
||||
{% id_to_username request.user.moved_to %}</a>
|
||||
</p>
|
||||
{% blocktrans %}
|
||||
<p class="mt-2">You can undo the move to restore full functionality, but some followers may have already unfollowed this account.</p>
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="columns is-justify-content-center">
|
||||
<div class="column is-one-quarter">
|
||||
<div class="level">
|
||||
<form class="level-left" name="remove-alias" action="{% url 'prefs-unmove' %}" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="remote_id" id="remote_id" value="{{user.moved_to}}">
|
||||
<button type="submit" class="button is-medium is-danger">{% trans "Undo move" %}</button>
|
||||
</form>
|
||||
<form class="level-right" name="logout" action="{% url 'logout' %}" method="post">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="button is-medium is-primary">{% trans 'Log out' %}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -14,11 +14,15 @@
|
|||
|
||||
{% block description %}
|
||||
{% if related_user_moved_to %}
|
||||
{{ related_user }} {% trans "has moved to" %} <a href="{{ related_user_moved_to }}">{% id_to_username related_user_moved_to %}</a>
|
||||
{% blocktrans %}
|
||||
{{ related_user }} has moved to <a href="{{ related_user_moved_to }}">
|
||||
{% endblocktrans %}{% id_to_username related_user_moved_to %}</a>
|
||||
<div class="row shrink my-2">
|
||||
{% include 'snippets/move_user_buttons.html' with group=notification.related_group %}
|
||||
</div>
|
||||
{% else %}
|
||||
{{ related_user }} {% trans "has undone their move" %}
|
||||
{% blocktrans %}
|
||||
{{ related_user }} has undone their move
|
||||
{% endblocktrans %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -16,7 +16,9 @@
|
|||
{% trans "Moving your account will notify all your followers and direct them to follow the new account." %}
|
||||
</p>
|
||||
<p>
|
||||
<strong>{{ user.username }}</strong> {% trans "will be marked as moved and will not be discoverable or usable unless you undo the move." %}
|
||||
{% blocktrans %}
|
||||
<strong>{{ user }}</strong> will be marked as moved and will not be discoverable or usable unless you undo the move.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
</div>
|
||||
<div class="notification is-info is-light">
|
||||
|
|
Loading…
Reference in a new issue