fix action label in feed
This commit is contained in:
parent
e8f8d3c908
commit
3783e345dd
3 changed files with 19 additions and 6 deletions
|
@ -619,12 +619,15 @@ class ShelfManager:
|
|||
# )
|
||||
# return shelf.members.all().order_by
|
||||
|
||||
def get_title(self, shelf_type, item_category):
|
||||
ic = ItemCategory(item_category).label
|
||||
def get_action_label(self, shelf_type, item_category):
|
||||
sts = [
|
||||
n[2] for n in ShelfTypeNames if n[0] == item_category and n[1] == shelf_type
|
||||
]
|
||||
st = sts[0] if sts else shelf_type
|
||||
return sts[0] if sts else shelf_type
|
||||
|
||||
def get_label(self, shelf_type, item_category):
|
||||
ic = ItemCategory(item_category).label
|
||||
st = self.get_action_label(shelf_type, item_category)
|
||||
return _("{shelf_label}的{item_category}").format(
|
||||
shelf_label=st, item_category=ic
|
||||
)
|
||||
|
@ -838,10 +841,20 @@ class Mark:
|
|||
def shelf_type(self):
|
||||
return self.shelfmember.parent.shelf_type if self.shelfmember else None
|
||||
|
||||
@property
|
||||
def action_label(self):
|
||||
return (
|
||||
self.owner.shelf_manager.get_action_label(
|
||||
self.shelf_type, self.item.category
|
||||
)
|
||||
if self.shelfmember
|
||||
else None
|
||||
)
|
||||
|
||||
@property
|
||||
def shelf_label(self):
|
||||
return (
|
||||
self.owner.shelf_manager.get_title(self.shelf_type, self.item.category)
|
||||
self.owner.shelf_manager.get_label(self.shelf_type, self.item.category)
|
||||
if self.shelfmember
|
||||
else None
|
||||
)
|
||||
|
|
|
@ -569,7 +569,7 @@ def profile(request, user_name):
|
|||
.order_by("-created_time")
|
||||
)
|
||||
shelf_list[category][shelf_type] = {
|
||||
"title": user.shelf_manager.get_title(shelf_type, category),
|
||||
"title": user.shelf_manager.get_label(shelf_type, category),
|
||||
"count": members.count(),
|
||||
"members": members[:5].prefetch_related("item"),
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
</span>
|
||||
</div>
|
||||
<span class="entity-list__entity-info" style="top:0px;">
|
||||
<a href="{% url 'journal:user_profile' activity.owner.mastodon_username %}">{{ activity.owner.display_name }}</a> {{ activity.action_object.parent.shelf_label }}
|
||||
<a href="{% url 'journal:user_profile' activity.owner.mastodon_username %}">{{ activity.owner.display_name }}</a> {{ activity.action_object.mark.action_label }}
|
||||
</span>
|
||||
<div class="entity-list__entity-title">
|
||||
<a href="{{ activity.action_object.item.url }}" class="entity-list__entity-link" style="font-weight:bold;">{{ activity.action_object.item.title }}
|
||||
|
|
Loading…
Add table
Reference in a new issue