Skip to content

Commit f17e1bb

Browse files
author
mein Name
committed
show attachements in notification
1 parent e90b489 commit f17e1bb

16 files changed

+94
-69
lines changed

catalog/templates/item_mark_list.html

+4-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ <h5>
3636
{% endif %}
3737
{% if mark.comment.latest_post %}
3838
{% include "action_reply_piece.html" with post=mark.comment.latest_post piece=mark.comment %}
39-
{% include "action_like_post.html" with post=mark.comment.latest_post %}
40-
{% include "action_boost_post.html" with post=mark.comment.latest_post %}
39+
{% endif %}
40+
{% if mark.shelfmember.latest_post %}
41+
{% include "action_like_post.html" with post=mark.shelfmember.latest_post %}
42+
{% include "action_boost_post.html" with post=mark.shelfmember.latest_post %}
4143
{% endif %}
4244
{% if mark.comment and request.user.is_authenticated and translate_enabled %}
4345
<span>

journal/templates/action_post_timestamp.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% load i18n %}
22
{% load duration %}
3-
<span>
3+
<span class="post_timestamp">
44
<a title="{% trans 'view post' %}"
55
href="{% url 'journal:post_view' post.author.handle post.pk %}">
66
{{ post.edited|default:post.published|naturaldelta }}

social/templates/_event_post.html

+50-47
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@
2121
{% trans 'boosted' %}
2222
</div>
2323
{% endif %}
24-
{% if post.in_reply_to_post_ %}
25-
<div class="replied">
26-
{% trans 'replying to' %}
27-
{% comment %}do not show replying to detail in case viewer has no access to it{% endcomment %}
28-
<a class="nickname"
29-
href="{% url 'journal:post_view' post.in_reply_to_post_.author.handle post.in_reply_to_post_.pk %}">
30-
@{{ post.in_reply_to_post_.author.username }}@{{ post.in_reply_to_post_.author.domain_id }}
31-
</a>
32-
</div>
33-
{% endif %}
3424
<div style="display:flex;">
3525
<div>
3626
<div class="avatar" style="margin:0.6em 0.6em 0.6em 0;">
@@ -43,52 +33,65 @@
4333
<div style="flex-grow:1;">
4434
<span class="action">
4535
{% include "action_post_timestamp.html" %}
46-
{% if item and item.class_name != 'tvepisode' %}
47-
<span>
48-
{% if item.class_name == 'podcastepisode' %}
49-
<a title="{% trans "play" %}"
50-
class="episode"
51-
data-uuid="{{ item.uuid }}"
52-
data-media="{{ item.media_url }}"
53-
data-cover="{{ item.cover_url|default:item.parent_item.cover.url }}"
54-
data-title="{{ item.display_title }}"
55-
data-album="{{ item.parent_item.display_title }}"
56-
data-hosts="{{ item.parent_item.host|join:' / ' }}"
57-
{% if request.user.is_authenticated %} data-comment-href="{% url 'journal:comment' item.uuid %}" {% endif %}
58-
data-position="{{ piece.metadata.position | default:0 }}"><i class="fa-solid fa-circle-play"></i></a>
59-
{% else %}
60-
<a title="{% trans "mark" %}"
61-
hx-get="{% url 'journal:mark' item.uuid %}?shelf_type=wishlist"
62-
hx-target="body"
63-
hx-swap="beforeend">
64-
<i class="fa-regular fa-bookmark"></i>
65-
</a>
66-
{% endif %}
67-
</span>
68-
{% endif %}
69-
{% if show_all_actions and request.user.is_authenticated and post.author_id == request.user.identity.pk %}
70-
{% include "action_pin_post.html" %}
71-
{% include "action_delete_post.html" %}
72-
{% endif %}
73-
{% include "action_reply_post.html" %}
74-
{% include "action_like_post.html" %}
75-
{% include "action_boost_post.html" %}
76-
{% if translate_enabled and request.user.is_authenticated %}
77-
{% include "action_translate_post.html" %}
78-
{% endif %}
79-
{% if show_all_actions and request.user.is_authenticated %}
80-
{% include "action_flag_post.html" %}
36+
{% if not hide_actions %}
37+
{% if item and item.class_name != 'tvepisode' %}
38+
<span>
39+
{% if item.class_name == 'podcastepisode' %}
40+
<a title="{% trans "play" %}"
41+
class="episode"
42+
data-uuid="{{ item.uuid }}"
43+
data-media="{{ item.media_url }}"
44+
data-cover="{{ item.cover_url|default:item.parent_item.cover.url }}"
45+
data-title="{{ item.display_title }}"
46+
data-album="{{ item.parent_item.display_title }}"
47+
data-hosts="{{ item.parent_item.host|join:' / ' }}"
48+
{% if request.user.is_authenticated %} data-comment-href="{% url 'journal:comment' item.uuid %}" {% endif %}
49+
data-position="{{ piece.metadata.position | default:0 }}"><i class="fa-solid fa-circle-play"></i></a>
50+
{% else %}
51+
<a title="{% trans "mark" %}"
52+
hx-get="{% url 'journal:mark' item.uuid %}?shelf_type=wishlist"
53+
hx-target="body"
54+
hx-swap="beforeend">
55+
<i class="fa-regular fa-bookmark"></i>
56+
</a>
57+
{% endif %}
58+
</span>
59+
{% endif %}
60+
{% if show_all_actions and request.user.is_authenticated and post.author_id == request.user.identity.pk %}
61+
{% include "action_pin_post.html" %}
62+
{% include "action_delete_post.html" %}
63+
{% endif %}
64+
{% include "action_reply_post.html" %}
65+
{% include "action_like_post.html" %}
66+
{% include "action_boost_post.html" %}
67+
{% if translate_enabled and request.user.is_authenticated %}
68+
{% include "action_translate_post.html" %}
69+
{% endif %}
70+
{% if show_all_actions and request.user.is_authenticated %}
71+
{% include "action_flag_post.html" %}
72+
{% endif %}
73+
{% include "action_open_post.html" %}
8174
{% endif %}
82-
{% include "action_open_post.html" %}
8375
</span>
84-
<span>
76+
<span class="post_author">
8577
<a href="{{ post.author.url }}"
8678
class="nickname"
8779
title="@{{ post.author.handle }}">{{ post.author.name|default:post.author.username }}</a>
8880
{% if piece and piece.classname == 'note' %}
8981
{% trans "wrote a note" %}
9082
{% endif %}
9183
</span>
84+
{% if post.in_reply_to_post_ %}
85+
<span class="replied">
86+
{% trans 'replying to' %}
87+
{% comment %}do not show replying to detail in case viewer has no access to it{% endcomment %}
88+
<a class="nickname"
89+
title="@{{ post.in_reply_to_post_.author.handle }}"
90+
href="{% url 'journal:post_view' post.in_reply_to_post_.author.handle post.in_reply_to_post_.pk %}">
91+
{{ post.in_reply_to_post_.author.name | default:post.in_reply_to_post_.author.handle }}
92+
</a>
93+
</span>
94+
{% endif %}
9295
{% if item and piece.classname != 'note' %}
9396
<article>{% include "_item_card.html" with item=item allow_embed=1 %}</article>
9497
{% endif %}

social/templates/event/boosted.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% load i18n %}
22
{% load bleach_tags %}
33
{% trans 'boosted your post' %}
4-
<blockquote class="tldr" _="on click toggle .tldr on me">
5-
{{ event.post.content|bleach:"a,p,span,br,div,img"|default:"<br>" }}
4+
<blockquote>
5+
{% include "_event_post.html" with post=event.post %}
66
</blockquote>

social/templates/event/liked.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% load i18n %}
22
{% load bleach_tags %}
33
{% trans 'liked your post' %}
4-
<blockquote class="tldr" _="on click toggle .tldr on me">
5-
{{ event.post.content|bleach:"a,p,span,br,div,img"|default:"<br>" }}
4+
<blockquote>
5+
{% include "_event_post.html" with post=event.post %}
66
</blockquote>

social/templates/event/mentioned.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% load i18n %}
22
{% load bleach_tags %}
33
{% trans 'mentioned you' %}
4-
<blockquote class="tldr" _="on click toggle .tldr on me">
5-
{{ event.post.content|bleach:"a,p,span,br,div,img"|default:"" }}
4+
<blockquote class="reply_to_post">
5+
{% include "_event_post.html" with post=event.post hide_actions=1 %}
66
</blockquote>
7-
{% include "event/_post.html" with post=event.reply %}
7+
{% include "_event_post.html" with post=event.reply %}

social/templates/event/mentioned_collection.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
{% blocktrans with piece_url=event.piece.url piece_title=event.piece.title %}
33
replied to your collection <a href="{{ piece_url }}">{{ piece_title }}</a>
44
{% endblocktrans %}
5-
{% include "event/_post.html" with post=event.reply %}
5+
{% include "_event_post.html" with post=event.reply %}

social/templates/event/mentioned_comment.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
</span>
1010
{{ event.piece.html|safe }}
1111
</blockquote>
12-
{% include "event/_post.html" with post=event.reply %}
12+
{% include "_event_post.html" with post=event.reply %}

social/templates/event/mentioned_note.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
<blockquote class="tldr" _="on click toggle .tldr on me">
1010
{{ event.piece.html|safe }}
1111
</blockquote>
12-
{% include "event/_post.html" with post=event.reply %}
12+
{% include "_event_post.html" with post=event.reply %}

social/templates/event/mentioned_rating.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
</span>
1010
{{ event.piece.html|safe }}
1111
</blockquote>
12-
{% include "event/_post.html" with post=event.reply %}
12+
{% include "_event_post.html" with post=event.reply %}

social/templates/event/mentioned_review.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
{% blocktrans with item_url=event.item.url item_title=event.item.display_title piece_url=event.piece.url piece_title=event.piece.title %}
33
replied to your review <a href="{{ piece_url }}">{{ piece_title }}</a> on <a href="{{ item_url }}">{{ item_title }}</a>
44
{% endblocktrans %}
5-
{% include "event/_post.html" with post=event.reply %}
5+
{% include "_event_post.html" with post=event.reply %}

social/templates/event/mentioned_shelfmember.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
</span>
1010
{{ event.piece.mark.comment.html|safe }}
1111
</blockquote>
12-
{% include "event/_post.html" with post=event.reply %}
12+
{% include "_event_post.html" with post=event.reply %}

social/templates/notification.html

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
<link href="{{ cdn_url }}/npm/shikwasa@2.2.1/dist/style.min.css"
1616
rel="stylesheet"></link>
1717
<script src="{% static 'js/podcast.js' %}"></script>
18+
<style type="text/css">
19+
.post .avatar {
20+
display: none;
21+
}
22+
blockquote.reply_to_post {
23+
padding-right: 0;
24+
}
25+
</style>
1826
</head>
1927
<body>
2028
{% include "_header.html" %}

social/views.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,7 @@ def __init__(self, tle) -> None:
211211
self.type = tle.type
212212
self.template = tle.type
213213
self.created = tle.created
214-
self.identity = (
215-
APIdentity.objects.filter(pk=tle.subject_identity.pk).first()
216-
if tle.subject_identity
217-
else None
218-
)
214+
self.identity = APIdentity.from_takahe(tle.subject_identity)
219215
self.post = tle.subject_post
220216
if self.type == "mentioned":
221217
# for reply, self.post is the original post
@@ -227,6 +223,7 @@ def __init__(self, tle) -> None:
227223
if self.piece and self.template in ["liked", "boosted", "mentioned"]:
228224
cls = self.piece.__class__.__name__.lower()
229225
self.template += "_" + cls
226+
print(self.type, self.template, tle.subject_identity)
230227

231228

232229
class SearchResultEvent:

users/models/apidentity.py

+15
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,21 @@ class Meta:
4040
def __str__(self):
4141
return f"{self.pk}:{self.username}@{self.domain_name}"
4242

43+
@classmethod
44+
def from_takahe(cls, t):
45+
if not t:
46+
return None
47+
i = cls.objects.get_or_create(
48+
pk=t.pk,
49+
defaults={
50+
"username": t.username,
51+
"domain_name": t.domain_id,
52+
"local": t.local,
53+
"deleted": t.deleted,
54+
},
55+
)[0]
56+
return i
57+
4358
@cached_property
4459
def takahe_identity(self):
4560
return Takahe.get_identity(self.pk)

0 commit comments

Comments
 (0)