From 7b057ea8c660b30730c2d567f97f34eae92b8cc6 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 7 Jul 2023 18:04:36 -0400 Subject: [PATCH] manage and export follow/block/mute --- social/tests.py | 2 +- users/models.py | 4 +++ users/templates/users/account.html | 20 ++++++++++++++- users/templates/users/profile_actions.html | 22 ++++++++++------- users/templates/users/relationship_list.html | 26 ++++++++++++++++++++ 5 files changed, 63 insertions(+), 11 deletions(-) create mode 100644 users/templates/users/relationship_list.html diff --git a/social/tests.py b/social/tests.py index 52814257..a7a66e52 100644 --- a/social/tests.py +++ b/social/tests.py @@ -42,7 +42,7 @@ class SocialTest(TestCase): # bob follows alice, see 2 activities self.bob.mastodon_following = ["Alice@MySpace"] self.alice.mastodon_follower = ["Bob@KKCity"] - self.bob.following = self.bob.merge_following_ids() + self.bob.merge_relationships() timeline2 = self.bob.activity_manager.get_timeline() self.assertEqual(len(timeline2), 2) diff --git a/users/models.py b/users/models.py index 7d91fdd6..38763ad2 100644 --- a/users/models.py +++ b/users/models.py @@ -241,6 +241,10 @@ class User(AbstractUser): if self.pk in target.following: target.following.remove(self.pk) target.save(update_fields=["following"]) + if target in self.local_following.all(): + self.local_following.remove(target) + if self in target.local_following.all(): + target.local_following.remove(self) if target.pk not in self.rejecting: self.rejecting.append(target.pk) self.save(update_fields=["rejecting"]) diff --git a/users/templates/users/account.html b/users/templates/users/account.html index 7e718ac9..f3fb16ff 100644 --- a/users/templates/users/account.html +++ b/users/templates/users/account.html @@ -86,9 +86,27 @@ {% endif %} +
+
+ {% trans '正在关注的用户' %} + {% include 'users/relationship_list.html' with name="关注" id="follow" list=request.user.local_following.all %} +
+
- {% trans '更新社交关系数据' %} + {% trans '已隐藏的用户' %} + {% include 'users/relationship_list.html' with name="隐藏" id="mute" list=request.user.local_muting.all %} +
+
+
+
+ {% trans '已屏蔽的用户' %} + {% include 'users/relationship_list.html' with name="屏蔽" id="block" list=request.user.local_blocking.all %} +
+
+
+
+ {% trans '同步联邦宇宙身份和社交关系数据' %}
diff --git a/users/templates/users/profile_actions.html b/users/templates/users/profile_actions.html index 2c62c7f7..bb266dbf 100644 --- a/users/templates/users/profile_actions.html +++ b/users/templates/users/profile_actions.html @@ -2,7 +2,11 @@ {% current_user_relationship user as relationship %} {% if relationship.rejecting %} - 已屏蔽 + 已屏蔽 {% else %} {% if relationship.status %} @@ -16,7 +20,7 @@ @@ -38,7 +42,7 @@ @@ -47,26 +51,26 @@ {% endif %} {% if not relationship.muting %} - {% elif relationship.unmutable %} - {% else %} - + @@ -75,7 +79,7 @@ diff --git a/users/templates/users/relationship_list.html b/users/templates/users/relationship_list.html new file mode 100644 index 00000000..ddd13be7 --- /dev/null +++ b/users/templates/users/relationship_list.html @@ -0,0 +1,26 @@ +{% for user in list %} +

+ {% include 'users/profile_actions.html' %} + {{ user.handler }} +

+{% empty %} +

无数据

+{% endfor %} +

+ + + + + + 此处只列出你在{{ site_name }}{{ name }}的用户,联邦宇宙{{ name }}列表可在你所属实例查询管理。 +

+