manage and export follow/block/mute
This commit is contained in:
parent
d601dde535
commit
7b057ea8c6
5 changed files with 63 additions and 11 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -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"])
|
||||
|
|
|
@ -86,9 +86,27 @@
|
|||
</details>
|
||||
</article>
|
||||
{% endif %}
|
||||
<article id="local_following">
|
||||
<details>
|
||||
<summary>{% trans '正在关注的用户' %}</summary>
|
||||
{% include 'users/relationship_list.html' with name="关注" id="follow" list=request.user.local_following.all %}
|
||||
</details>
|
||||
</article>
|
||||
<article>
|
||||
<details>
|
||||
<summary>{% trans '更新社交关系数据' %}</summary>
|
||||
<summary>{% trans '已隐藏的用户' %}</summary>
|
||||
{% include 'users/relationship_list.html' with name="隐藏" id="mute" list=request.user.local_muting.all %}
|
||||
</details>
|
||||
</article>
|
||||
<article>
|
||||
<details>
|
||||
<summary>{% trans '已屏蔽的用户' %}</summary>
|
||||
{% include 'users/relationship_list.html' with name="屏蔽" id="block" list=request.user.local_blocking.all %}
|
||||
</details>
|
||||
</article>
|
||||
<article>
|
||||
<details>
|
||||
<summary>{% trans '同步联邦宇宙身份和社交关系数据' %}</summary>
|
||||
<form action="{% url 'users:sync_mastodon' %}"
|
||||
method="post"
|
||||
enctype="multipart/form-data">
|
||||
|
|
|
@ -2,7 +2,11 @@
|
|||
{% current_user_relationship user as relationship %}
|
||||
{% if relationship.rejecting %}
|
||||
<span class="tag-list">
|
||||
<span><a>已屏蔽</a></span>
|
||||
<span><a title="点击可取消屏蔽"
|
||||
hx-confirm="确定要取消对该用户的屏蔽吗?"
|
||||
hx-post="{% url 'users:unblock' user.handler %}"
|
||||
hx-target="closest .action"
|
||||
hx-swap="innerHTML">已屏蔽</a></span>
|
||||
</span>
|
||||
{% else %}
|
||||
{% if relationship.status %}
|
||||
|
@ -16,7 +20,7 @@
|
|||
<a title="已关注,点击可取消关注"
|
||||
class="activated"
|
||||
hx-post="{% url 'users:unfollow' user.handler %}"
|
||||
hx-target="#profile_actions"
|
||||
hx-target="closest .action"
|
||||
hx-swap="innerHTML">
|
||||
<i class="fa-solid fa-user-check"></i>
|
||||
</a>
|
||||
|
@ -38,7 +42,7 @@
|
|||
<span>
|
||||
<a title="点击可关注该用户"
|
||||
hx-post="{% url 'users:follow' user.handler %}"
|
||||
hx-target="#profile_actions"
|
||||
hx-target="closest .action"
|
||||
hx-swap="innerHTML">
|
||||
<i class="fa-solid fa-user-plus"></i>
|
||||
</a>
|
||||
|
@ -47,26 +51,26 @@
|
|||
{% endif %}
|
||||
{% if not relationship.muting %}
|
||||
<span>
|
||||
<a title="点击可忽略该用户"
|
||||
<a title="点击可隐藏该用户"
|
||||
hx-post="{% url 'users:mute' user.handler %}"
|
||||
hx-target="#profile_actions"
|
||||
hx-target="closest .action"
|
||||
hx-swap="innerHTML">
|
||||
<i class="fa-solid fa-volume-high"></i>
|
||||
</a>
|
||||
</span>
|
||||
{% elif relationship.unmutable %}
|
||||
<span>
|
||||
<a title="已忽略,点击可取消忽略"
|
||||
<a title="已隐藏,点击可取消隐藏"
|
||||
class="activated"
|
||||
hx-post="{% url 'users:unmute' user.handler %}"
|
||||
hx-target="#profile_actions"
|
||||
hx-target="closest .action"
|
||||
hx-swap="innerHTML">
|
||||
<i class="fa-solid fa-volume-off"></i>
|
||||
</a>
|
||||
</span>
|
||||
{% else %}
|
||||
<span>
|
||||
<a title="已在联邦宇宙中忽略" class="activated">
|
||||
<a title="已在联邦宇宙中隐藏" class="activated">
|
||||
<i class="fa-solid fa-volume-xmark"></i>
|
||||
</a>
|
||||
</span>
|
||||
|
@ -75,7 +79,7 @@
|
|||
<a title="点击可屏蔽该用户"
|
||||
hx-confirm="确定要屏蔽该用户吗?"
|
||||
hx-post="{% url 'users:block' user.handler %}"
|
||||
hx-target="#profile_actions"
|
||||
hx-target="closest .action"
|
||||
hx-swap="innerHTML">
|
||||
<i class="fa-solid fa-user-slash"></i>
|
||||
</a>
|
||||
|
|
26
users/templates/users/relationship_list.html
Normal file
26
users/templates/users/relationship_list.html
Normal file
|
@ -0,0 +1,26 @@
|
|||
{% for user in list %}
|
||||
<p style="border-bottom: gray 1px dashed; padding-bottom:4px;">
|
||||
<span class="action">{% include 'users/profile_actions.html' %}</span>
|
||||
<code class="{{ id }}_handler"
|
||||
style="cursor:pointer"
|
||||
onmouseleave="$(this).removeAttr('data-tooltip')"
|
||||
onclick="navigator.clipboard.writeText(this.innerText);$(this).data('tooltip','copied');">{{ user.handler }}</code>
|
||||
</p>
|
||||
{% empty %}
|
||||
<p class="empty">无数据</p>
|
||||
{% endfor %}
|
||||
<p>
|
||||
<span class="action">
|
||||
<span>
|
||||
<a id="download_{{ id }}" title="导出列表" download="neodb_{{ id }}.csv"><i class="fa-solid fa-download"></i></a>
|
||||
</span>
|
||||
</span>
|
||||
此处只列出你在{{ site_name }}{{ name }}的用户,联邦宇宙{{ name }}列表可在你所属实例查询管理。
|
||||
</p>
|
||||
<script>
|
||||
let csv = "data:text/csv;charset=utf-8,Account address,Show boosts,Notify on new posts,Languages\n"
|
||||
$('.{{id}}_handler').each(function() {
|
||||
csv += $(this).text() + ',true,false,\n'
|
||||
})
|
||||
$('#download_{{id}}').attr('href', encodeURI(csv))
|
||||
</script>
|
Loading…
Add table
Reference in a new issue