fix other title display
This commit is contained in:
parent
6f7043e54f
commit
5d040cc650
26 changed files with 42 additions and 36 deletions
|
@ -605,14 +605,19 @@ class Item(PolymorphicModel):
|
||||||
if v:
|
if v:
|
||||||
return v
|
return v
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
def display_title(self) -> str:
|
def display_title(self) -> str:
|
||||||
# return title in current locale if possible, otherwise any title
|
# return title in current locale if possible, otherwise any title
|
||||||
return (self.get_localized_title() or self.title) or (
|
return (self.get_localized_title() or self.title) or (
|
||||||
self.localized_title[0]["text"] if self.localized_title else ""
|
self.localized_title[0]["text"] if self.localized_title else ""
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@cached_property
|
||||||
|
def additional_title(self) -> list[str]:
|
||||||
|
title = self.display_title
|
||||||
|
return [t["text"] for t in self.localized_title if t["text"] != title]
|
||||||
|
|
||||||
|
@cached_property
|
||||||
def display_description(self) -> str:
|
def display_description(self) -> str:
|
||||||
return (
|
return (
|
||||||
self.get_localized_description()
|
self.get_localized_description()
|
||||||
|
|
|
@ -52,9 +52,9 @@ class Command(BaseCommand):
|
||||||
self.stdout.write(self.style.SUCCESS(f"Done."))
|
self.stdout.write(self.style.SUCCESS(f"Done."))
|
||||||
|
|
||||||
def localize(self):
|
def localize(self):
|
||||||
for i in tqdm(
|
c = Item.objects.all().count()
|
||||||
Item.objects.filter(is_deleted=False, merged_to_item__isnull=True)
|
qs = Item.objects.filter(is_deleted=False, merged_to_item__isnull=True)
|
||||||
):
|
for i in tqdm(qs.iterator(), total=c):
|
||||||
localized_title = [{"lang": detect_language(i.title), "text": i.title}]
|
localized_title = [{"lang": detect_language(i.title), "text": i.title}]
|
||||||
if i.__class__ != Edition:
|
if i.__class__ != Edition:
|
||||||
if hasattr(i, "orig_title") and i.orig_title: # type:ignore
|
if hasattr(i, "orig_title") and i.orig_title: # type:ignore
|
||||||
|
@ -78,7 +78,7 @@ class Command(BaseCommand):
|
||||||
else []
|
else []
|
||||||
)
|
)
|
||||||
lang = i.metadata.get("language")
|
lang = i.metadata.get("language")
|
||||||
if isinstance(lang, str):
|
if isinstance(lang, str) and lang:
|
||||||
i.metadata["language"] = [lang]
|
i.metadata["language"] = [lang]
|
||||||
i.localized_title = uniq(localized_title)
|
i.localized_title = uniq(localized_title)
|
||||||
localized_desc = [{"lang": detect_language(i.brief), "text": i.brief}]
|
localized_desc = [{"lang": detect_language(i.brief), "text": i.brief}]
|
||||||
|
|
|
@ -31,11 +31,6 @@
|
||||||
</div>
|
</div>
|
||||||
{% endblock brief %}
|
{% endblock brief %}
|
||||||
{% block full %}
|
{% block full %}
|
||||||
{% comment %} {% if item.actor %}
|
|
||||||
{% include '_people.html' with people=item.actor role='actor' max=2 %}
|
|
||||||
<br>
|
|
||||||
{% endif %} {% endcomment %}
|
|
||||||
{% include '_people.html' with people=item.other_title role='other title' max=2 %}
|
|
||||||
<div>
|
<div>
|
||||||
{% if not hide_brief %}{{ item.brief | linebreaksbr }}{% endif %}
|
{% if not hide_brief %}{{ item.brief | linebreaksbr }}{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
{% if item.rating %}
|
{% if item.rating %}
|
||||||
<span class="solo-hidden">{{ item.rating | floatformat:1 }} <small>({{ item.rating_count }} {% trans "ratings" %})</small></span>
|
<span class="solo-hidden">{{ item.rating | floatformat:1 }} <small>({{ item.rating_count }} {% trans "ratings" %})</small></span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% include '_people.html' with people=item.other_title role='other title' max=2 %}
|
{% include '_people.html' with people=item.additional_title role='other title' max=2 %}
|
||||||
{% if item.release_date %}<span>{{ item.release_date }}</span>{% endif %}
|
{% if item.release_date %}<span>{{ item.release_date }}</span>{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock brief %}
|
{% endblock brief %}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
</div>
|
</div>
|
||||||
{% endblock brief %}
|
{% endblock brief %}
|
||||||
{% block full %}
|
{% block full %}
|
||||||
<div class="multi-fields">{% include '_people.html' with people=item.other_title role='other title' max=2 %}</div>
|
<div class="multi-fields">{% include '_people.html' with people=item.additional_title role='other title' max=2 %}</div>
|
||||||
<div>
|
<div>
|
||||||
{% if not hide_brief %}{{ item.brief | linebreaksbr }}{% endif %}
|
{% if not hide_brief %}{{ item.brief | linebreaksbr }}{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
{% endblock brief %}
|
{% endblock brief %}
|
||||||
{% block full %}
|
{% block full %}
|
||||||
<div class="multi-fields">
|
<div class="multi-fields">
|
||||||
{% include '_people.html' with people=item.other_title role='other title' max=2 %}
|
{% include '_people.html' with people=item.additional_title role='other title' max=2 %}
|
||||||
{% include '_people.html' with people=item.language role='language' max=5 %}
|
{% include '_people.html' with people=item.language role='language' max=5 %}
|
||||||
{% include '_people.html' with people=item.troupe role='troupe' max=2 %}
|
{% include '_people.html' with people=item.troupe role='troupe' max=2 %}
|
||||||
{% include '_people.html' with people=item.location role='theater' max=2 %}
|
{% include '_people.html' with people=item.location role='theater' max=2 %}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
{% endblock brief %}
|
{% endblock brief %}
|
||||||
{% block full %}
|
{% block full %}
|
||||||
<div class="multi-fields">
|
<div class="multi-fields">
|
||||||
{% include '_people.html' with people=item.other_title role='other title' max=2 %}
|
{% include '_people.html' with people=item.additional_title role='other title' max=2 %}
|
||||||
{% include '_people.html' with people=item.playwright role='playwright' max=2 %}
|
{% include '_people.html' with people=item.playwright role='playwright' max=2 %}
|
||||||
{% include '_people.html' with people=item.composer role='composer' max=2 %}
|
{% include '_people.html' with people=item.composer role='composer' max=2 %}
|
||||||
{% include '_people.html' with people=item.choreographer role='choreographer' max=2 %}
|
{% include '_people.html' with people=item.choreographer role='choreographer' max=2 %}
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
</div>
|
</div>
|
||||||
{% endblock brief %}
|
{% endblock brief %}
|
||||||
{% block full %}
|
{% block full %}
|
||||||
<div class="multi-fields">{% include '_people.html' with people=item.other_title role='other title' max=2 %}</div>
|
|
||||||
<div>
|
<div>
|
||||||
{% if not hide_brief %}{{ item.brief | linebreaksbr }}{% endif %}
|
{% if not hide_brief %}{{ item.brief | linebreaksbr }}{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
</div>
|
</div>
|
||||||
{% endblock brief %}
|
{% endblock brief %}
|
||||||
{% block full %}
|
{% block full %}
|
||||||
<div class="multi-fields">{% include '_people.html' with people=item.other_title role='other title' max=2 %}</div>
|
<div class="multi-fields">{% include '_people.html' with people=item.additional_title role='other title' max=2 %}</div>
|
||||||
<div>
|
<div>
|
||||||
{% if not hide_brief %}{{ item.brief | linebreaksbr }}{% endif %}
|
{% if not hide_brief %}{{ item.brief | linebreaksbr }}{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
</div>
|
</div>
|
||||||
{% endblock brief %}
|
{% endblock brief %}
|
||||||
{% block full %}
|
{% block full %}
|
||||||
<div class="multi-fields">{% include '_people.html' with people=item.other_title role='other title' max=2 %}</div>
|
<div class="multi-fields">{% include '_people.html' with people=item.additional_title role='other title' max=2 %}</div>
|
||||||
<div>
|
<div>
|
||||||
{% if not hide_brief %}{{ item.brief | linebreaksbr }}{% endif %}
|
{% if not hide_brief %}{{ item.brief | linebreaksbr }}{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
{% load duration %}
|
{% load duration %}
|
||||||
<!-- class specific details -->
|
<!-- class specific details -->
|
||||||
{% block details %}
|
{% block details %}
|
||||||
<div>{% include '_people.html' with people=item.other_title role='other title' max=5 %}</div>
|
<div>{% include '_people.html' with people=item.additional_title role='other title' max=5 %}</div>
|
||||||
<div>{% include '_people.html' with people=item.artist role='artist' max=5 %}</div>
|
<div>{% include '_people.html' with people=item.artist role='artist' max=5 %}</div>
|
||||||
<div>{% include '_people.html' with people=item.company role='publisher' max=5 %}</div>
|
<div>{% include '_people.html' with people=item.company role='publisher' max=5 %}</div>
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -42,11 +42,7 @@
|
||||||
{% trans 'series' %}: {{ item.series }}
|
{% trans 'series' %}: {{ item.series }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>{% include '_people.html' with people=item.language role='language' max=10 %}</div>
|
||||||
{% if item.language %}
|
|
||||||
{% trans 'language' %}: {{ item.get_language_display }}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
<div>
|
<div>
|
||||||
{% if item.binding %}
|
{% if item.binding %}
|
||||||
{% trans 'binding' %}: {{ item.binding }}
|
{% trans 'binding' %}: {{ item.binding }}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<!-- class specific details -->
|
<!-- class specific details -->
|
||||||
{% block details %}
|
{% block details %}
|
||||||
<div class="tldr-2" _="on click toggle .tldr-2 on me">
|
<div class="tldr-2" _="on click toggle .tldr-2 on me">
|
||||||
{% include '_people.html' with people=item.other_title _role='other title' max=99 %}
|
{% include '_people.html' with people=item.additional_title _role='other title' max=99 %}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{% if item.release_date %}
|
{% if item.release_date %}
|
||||||
|
|
|
@ -198,7 +198,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="item-title-more" class="middle">
|
<div id="item-title-more" class="middle">
|
||||||
<hgroup>
|
<hgroup>
|
||||||
{% if item.subtitle %}<p>{{ item.subtitle }}</p>{% endif %}
|
{% if item.display_subtitle %}<p>{{ item.display_subtitle }}</p>{% endif %}
|
||||||
{% if item.orig_title %}
|
{% if item.orig_title %}
|
||||||
<p>
|
<p>
|
||||||
{{ item.orig_title }}
|
{{ item.orig_title }}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
{% load thumb %}
|
{% load thumb %}
|
||||||
<!-- class specific details -->
|
<!-- class specific details -->
|
||||||
{% block details %}
|
{% block details %}
|
||||||
<div>{% include '_people.html' with people=item.other_title role='other title' max=5 %}</div>
|
<div>{% include '_people.html' with people=item.additional_title role='other title' max=5 %}</div>
|
||||||
<div>{% include '_people.html' with people=item.director role='director' max=5 %}</div>
|
<div>{% include '_people.html' with people=item.director role='director' max=5 %}</div>
|
||||||
<div>{% include '_people.html' with people=item.playwright role='playwright' max=5 %}</div>
|
<div>{% include '_people.html' with people=item.playwright role='playwright' max=5 %}</div>
|
||||||
<div>{% include '_people.html' with people=item.actor role='actor' max=5 %}</div>
|
<div>{% include '_people.html' with people=item.actor role='actor' max=5 %}</div>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
{% load thumb %}
|
{% load thumb %}
|
||||||
<!-- class specific details -->
|
<!-- class specific details -->
|
||||||
{% block details %}
|
{% block details %}
|
||||||
<div>{% include '_people.html' with people=item.other_title _role='other title' max=5 %}</div>
|
<div>{% include '_people.html' with people=item.additional_title _role='other title' max=5 %}</div>
|
||||||
<div>
|
<div>
|
||||||
{% if item.opening_date %}
|
{% if item.opening_date %}
|
||||||
{% trans "opening date" %}:
|
{% trans "opening date" %}:
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
{% if item.closing_date %}~ <span>{{ item.closing_date }}</span>{% endif %}
|
{% if item.closing_date %}~ <span>{{ item.closing_date }}</span>{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div>{% include '_people.html' with people=item.other_title _role='other title' max=5 %}</div>
|
<div>{% include '_people.html' with people=item.additional_title _role='other title' max=5 %}</div>
|
||||||
<div>{% include '_people.html' with people=item.genre role='genre' max=5 %}</div>
|
<div>{% include '_people.html' with people=item.genre role='genre' max=5 %}</div>
|
||||||
<div>{% include '_people.html' with people=item.troupe role='troupe' max=5 %}</div>
|
<div>{% include '_people.html' with people=item.troupe role='troupe' max=5 %}</div>
|
||||||
<div>{% include '_people.html' with people=item.location role='theater' max=5 %}</div>
|
<div>{% include '_people.html' with people=item.location role='theater' max=5 %}</div>
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
<div>{% include '_people.html' with people=item.other_title role='other title' max=5 %}</div>
|
|
||||||
<div>{% include '_people.html' with people=item.director role='director' max=5 %}</div>
|
<div>{% include '_people.html' with people=item.director role='director' max=5 %}</div>
|
||||||
<div>{% include '_people.html' with people=item.playwright role='playwright' max=5 %}</div>
|
<div>{% include '_people.html' with people=item.playwright role='playwright' max=5 %}</div>
|
||||||
<div>{% include '_people.html' with people=item.actor role='actor' max=5 %}</div>
|
<div>{% include '_people.html' with people=item.actor role='actor' max=5 %}</div>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
{% load thumb %}
|
{% load thumb %}
|
||||||
<!-- class specific details -->
|
<!-- class specific details -->
|
||||||
{% block details %}
|
{% block details %}
|
||||||
<div>{% include '_people.html' with people=item.other_title role='other title' max=5 %}</div>
|
<div>{% include '_people.html' with people=item.additional_title role='other title' max=5 %}</div>
|
||||||
<div>{% include '_people.html' with people=item.director role='director' max=5 %}</div>
|
<div>{% include '_people.html' with people=item.director role='director' max=5 %}</div>
|
||||||
<div>{% include '_people.html' with people=item.playwright role='playwright' max=5 %}</div>
|
<div>{% include '_people.html' with people=item.playwright role='playwright' max=5 %}</div>
|
||||||
<div>{% include '_people.html' with people=item.actor role='actor' max=5 %}</div>
|
<div>{% include '_people.html' with people=item.actor role='actor' max=5 %}</div>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
{% load thumb %}
|
{% load thumb %}
|
||||||
<!-- class specific details -->
|
<!-- class specific details -->
|
||||||
{% block details %}
|
{% block details %}
|
||||||
<div>{% include '_people.html' with people=item.other_title role='other title' max=5 %}</div>
|
<div>{% include '_people.html' with people=item.additional_title role='other title' max=5 %}</div>
|
||||||
<div>{% include '_people.html' with people=item.author role='author' max=5 %}</div>
|
<div>{% include '_people.html' with people=item.author role='author' max=5 %}</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block left_sidebar %}
|
{% block left_sidebar %}
|
||||||
|
|
|
@ -400,17 +400,24 @@ class TVSeason(Item):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def display_title(self):
|
def display_title(self):
|
||||||
if self.season_number and not re.match(r"^.+第.+季$", self.title):
|
if self.season_number and self.parent_item:
|
||||||
if self.parent_item and (
|
if self.parent_item and (
|
||||||
self.parent_item.season_count == 1 or not self.parent_item.season_count
|
self.parent_item.season_count == 1 or not self.parent_item.season_count
|
||||||
):
|
):
|
||||||
return self.title
|
return self.parent_item.display_title
|
||||||
else:
|
else:
|
||||||
return _("{show_title} S{season_number}").format(
|
return _("{show_title} S{season_number}").format(
|
||||||
show_title=self.title, season_number=self.season_number
|
show_title=self.parent_item.display_title,
|
||||||
|
season_number=self.season_number,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return self.title
|
return super().display_title
|
||||||
|
|
||||||
|
@property
|
||||||
|
def display_subtitle(self):
|
||||||
|
return (
|
||||||
|
super().display_title if self.season_number and self.parent_item else None
|
||||||
|
)
|
||||||
|
|
||||||
def update_linked_items_from_external_resource(self, resource):
|
def update_linked_items_from_external_resource(self, resource):
|
||||||
for w in resource.required_resources:
|
for w in resource.required_resources:
|
||||||
|
|
1
test_data/https___api_bgm_tv_v0_subjects_431295
Normal file
1
test_data/https___api_bgm_tv_v0_subjects_431295
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"date":"2023-09-05","platform":"游戏","images":{"small":"https://lain.bgm.tv/r/200/pic/cover/l/2b/c1/431295_09pv7.jpg","grid":"https://lain.bgm.tv/r/100/pic/cover/l/2b/c1/431295_09pv7.jpg","large":"https://lain.bgm.tv/pic/cover/l/2b/c1/431295_09pv7.jpg","medium":"https://lain.bgm.tv/r/800/pic/cover/l/2b/c1/431295_09pv7.jpg","common":"https://lain.bgm.tv/r/400/pic/cover/l/2b/c1/431295_09pv7.jpg"},"summary":"寻觅往昔的只言片语,揭示过去的秘密。\r\n\r\n自从创世之初,高塔各族便已分隔,彼此不再有言语往来,只是据说某日,某位旅人获得了智慧,能够推倒高墙,恢复天道。走进引人入胜的世界,探索缤纷诗意的设定,感受巴别塔传说的奇妙,帮人们忆起往事。置身庞大的迷宫之中,走过无穷无尽的阶梯,揭示苦涩的真相,揭晓迷人世界的秘密。在这里,你会发现:古老的语言既是锁头,也是钥匙。\r\n\r\n踏上别有天地的旅途,破译有趣的古代文字。\r\n\r\n• 探索美妙而又迷人的世界,体验扎实的叙事,以不同的形式领略巴别塔的神话。\r\n• 仔细观察周围环境,破解谜题,揭开身边的秘密。\r\n• 利用潜行和智慧巧胜卫兵,穿过常人不可入内的禁区。\r\n• 破译古代文字,令高塔各族恢复联系与交流。","name":"Chants of Sennaar","name_cn":"巴别塔圣歌","tags":[{"name":"解谜","count":48},{"name":"独立游戏","count":37},{"name":"2023","count":26},{"name":"PC","count":23},{"name":"语言","count":18},{"name":"文字","count":13},{"name":"AVG","count":11},{"name":"PUZ","count":10},{"name":"推理","count":7},{"name":"FocusEntertainment","count":6},{"name":"小作","count":4},{"name":"NS","count":4},{"name":"STEAM","count":4},{"name":"XGP","count":2},{"name":"盗版","count":1},{"name":"s语言学","count":1},{"name":"主角无性别","count":1},{"name":"2020+","count":1},{"name":"本世代","count":1},{"name":"Click","count":1},{"name":"视频通关","count":1},{"name":"EN","count":1},{"name":"八星","count":1},{"name":"let","count":1},{"name":"艺术","count":1},{"name":"PS4","count":1},{"name":"破解","count":1},{"name":"无修","count":1},{"name":"Switch","count":1},{"name":"NintendoSwitch","count":1}],"infobox":[{"key":"中文名","value":"巴别塔圣歌"},{"key":"平台","value":[{"v":"PS4"},{"v":"Xbox One"},{"v":"Nintendo Switch"},{"v":"PC"}]},{"key":"游戏类型","value":"AVG、PUZ"},{"key":"游戏引擎","value":"Unity 2021"},{"key":"游玩人数","value":"1"},{"key":"发行日期","value":"2023年9月5日"},{"key":"售价","value":"80元"},{"key":"website","value":"https://www.focus-entmt.com/en/games/chants-of-sennaar"},{"key":"游戏开发商","value":"Rundisc"},{"key":"发行","value":"Focus Entertainment"}],"rating":{"rank":900,"total":133,"count":{"1":0,"2":0,"3":0,"4":3,"5":1,"6":5,"7":32,"8":64,"9":27,"10":1},"score":7.8},"total_episodes":0,"collection":{"on_hold":14,"dropped":7,"wish":116,"collect":154,"doing":13},"id":431295,"eps":0,"volumes":0,"series":false,"locked":false,"nsfw":false,"type":4}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue