show crew as pivot aggregated list
This commit is contained in:
parent
0a3def4eeb
commit
9811c3c370
5 changed files with 42 additions and 14 deletions
|
@ -32,6 +32,14 @@ _ACTOR_SCHEMA = {
|
|||
}
|
||||
|
||||
|
||||
def _crew_by_role(crew):
|
||||
roles = set([c["role"] for c in crew if c.get("role")])
|
||||
r = {key: [] for key in roles}
|
||||
for c in crew:
|
||||
r[c["role"]].append(c["name"])
|
||||
return r
|
||||
|
||||
|
||||
class Performance(Item):
|
||||
type = ItemType.Performance
|
||||
child_class = "PerformanceProduction"
|
||||
|
@ -171,6 +179,10 @@ class Performance(Item):
|
|||
.filter(is_deleted=False, merged_to_item=None)
|
||||
)
|
||||
|
||||
@cached_property
|
||||
def crew_by_role(self):
|
||||
return _crew_by_role(self.crew)
|
||||
|
||||
|
||||
class PerformanceProduction(Item):
|
||||
type = ItemType.PerformanceProduction
|
||||
|
@ -327,3 +339,7 @@ class PerformanceProduction(Item):
|
|||
).first()
|
||||
if resource and resource.item:
|
||||
self.show = resource.item
|
||||
|
||||
@cached_property
|
||||
def crew_by_role(self):
|
||||
return _crew_by_role(self.crew)
|
||||
|
|
15
catalog/templates/_actor.html
Normal file
15
catalog/templates/_actor.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
{% if people %}
|
||||
<span>
|
||||
{% if role %}{{ role }}:{% endif %}
|
||||
{% for p in people %}
|
||||
{% if forloop.counter <= max %}
|
||||
{% if not forloop.first %}、{% endif %}
|
||||
<span>{{ p.name }}
|
||||
{% if p.role.strip %}(饰{{ p.role }}){% endif %}
|
||||
</span>
|
||||
{% elif forloop.last %}
|
||||
等
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</span>
|
||||
{% endif %}
|
|
@ -1,15 +1,13 @@
|
|||
{% if people %}
|
||||
<span>
|
||||
{% if role %}{{ role }}:{% endif %}
|
||||
{% for p in people %}
|
||||
{% for role, list in people.items %}
|
||||
<div class="crew-list">
|
||||
{{ role }}:
|
||||
{% for p in list %}
|
||||
{% if forloop.counter <= max %}
|
||||
{% if not forloop.first %}、{% endif %}
|
||||
<span>{{ p.name }}
|
||||
{% if p.role.strip %}({{ p.role }}){% endif %}
|
||||
</span>
|
||||
<span>{{ p }}</span>
|
||||
{% elif forloop.last %}
|
||||
等
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
|
|
@ -25,11 +25,11 @@
|
|||
<div>{% include '_people.html' with people=item.orig_creator role='原作' max=5 %}</div>
|
||||
<div>{% include '_people.html' with people=item.director role='导演' max=5 %}</div>
|
||||
<div>{% include '_people.html' with people=item.playwright role='编剧' max=5 %}</div>
|
||||
<div>{% include '_crew.html' with people=item.actor role='演员' max=10 %}</div>
|
||||
<div>{% include '_actor.html' with people=item.actor role='演员' max=10 %}</div>
|
||||
<div>{% include '_people.html' with people=item.performer role='表演者' max=10 %}</div>
|
||||
<div>{% include '_people.html' with people=item.composer role='作曲' max=5 %}</div>
|
||||
<div>{% include '_people.html' with people=item.choreographer role='编舞' max=5 %}</div>
|
||||
<div>{% include '_crew.html' with people=item.crew role='演职人员' max=10 %}</div>
|
||||
<div>{% include '_crew.html' with people=item.crew_by_role role='演职人员' max=10 %}</div>
|
||||
<div>
|
||||
{% if item.official_site %}
|
||||
{% trans '官方网站' %}: <span>{{ item.official_site|urlizetrunc:24 }}</span>
|
||||
|
@ -59,11 +59,10 @@
|
|||
{% include '_people.html' with people=prod.orig_creator role='原作' max=2 %}
|
||||
{% include '_people.html' with people=prod.director role='导演' max=2 %}
|
||||
{% include '_people.html' with people=prod.playwright role='编剧' max=2 %}
|
||||
{% include '_crew.html' with people=prod.actor role='演员' max=5 %}
|
||||
{% include '_actor.html' with people=prod.actor role='演员' max=5 %}
|
||||
{% include '_people.html' with people=prod.performer role='表演者' max=5 %}
|
||||
{% include '_people.html' with people=prod.composer role='作曲' max=2 %}
|
||||
{% include '_people.html' with people=prod.choreographer role='编舞' max=2 %}
|
||||
{% include '_crew.html' with people=prod.crew role='演职人员' max=5 %}
|
||||
</div>
|
||||
</hgroup>
|
||||
{% endfor %}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<div>{% include '_people.html' with people=item.orig_creator role='原作' max=5 %}</div>
|
||||
<div>{% include '_people.html' with people=item.director role='导演' max=5 %}</div>
|
||||
<div>{% include '_people.html' with people=item.playwright role='编剧' max=5 %}</div>
|
||||
<div>{% include '_crew.html' with people=item.actor role='演员' max=50 %}</div>
|
||||
<div>{% include '_actor.html' with people=item.actor role='演员' max=50 %}</div>
|
||||
<div>{% include '_people.html' with people=item.performer role='表演者' max=50 %}</div>
|
||||
<div>{% include '_people.html' with people=item.composer role='作曲' max=5 %}</div>
|
||||
<div>{% include '_people.html' with people=item.choreographer role='编舞' max=5 %}</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue