diff --git a/catalog/performance/models.py b/catalog/performance/models.py index 4ddbe861..92c1861b 100644 --- a/catalog/performance/models.py +++ b/catalog/performance/models.py @@ -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) diff --git a/catalog/templates/_actor.html b/catalog/templates/_actor.html new file mode 100644 index 00000000..bc47eeee --- /dev/null +++ b/catalog/templates/_actor.html @@ -0,0 +1,15 @@ +{% if people %} + + {% if role %}{{ role }}:{% endif %} + {% for p in people %} + {% if forloop.counter <= max %} + {% if not forloop.first %}、{% endif %} + {{ p.name }} + {% if p.role.strip %}(饰{{ p.role }}){% endif %} + + {% elif forloop.last %} + 等 + {% endif %} + {% endfor %} + +{% endif %} diff --git a/catalog/templates/_crew.html b/catalog/templates/_crew.html index 595ff495..9cb7fd5f 100644 --- a/catalog/templates/_crew.html +++ b/catalog/templates/_crew.html @@ -1,15 +1,13 @@ -{% if people %} - - {% if role %}{{ role }}:{% endif %} - {% for p in people %} +{% for role, list in people.items %} +
+ {{ role }}: + {% for p in list %} {% if forloop.counter <= max %} {% if not forloop.first %}、{% endif %} - {{ p.name }} - {% if p.role.strip %}({{ p.role }}){% endif %} - + {{ p }} {% elif forloop.last %} 等 {% endif %} {% endfor %} - -{% endif %} +
+{% endfor %} diff --git a/catalog/templates/performance.html b/catalog/templates/performance.html index e2e183ae..1841fc4b 100644 --- a/catalog/templates/performance.html +++ b/catalog/templates/performance.html @@ -25,11 +25,11 @@
{% include '_people.html' with people=item.orig_creator role='原作' max=5 %}
{% include '_people.html' with people=item.director role='导演' max=5 %}
{% include '_people.html' with people=item.playwright role='编剧' max=5 %}
-
{% include '_crew.html' with people=item.actor role='演员' max=10 %}
+
{% include '_actor.html' with people=item.actor role='演员' max=10 %}
{% include '_people.html' with people=item.performer role='表演者' max=10 %}
{% include '_people.html' with people=item.composer role='作曲' max=5 %}
{% include '_people.html' with people=item.choreographer role='编舞' max=5 %}
-
{% include '_crew.html' with people=item.crew role='演职人员' max=10 %}
+
{% include '_crew.html' with people=item.crew_by_role role='演职人员' max=10 %}
{% if item.official_site %} {% trans '官方网站' %}: {{ item.official_site|urlizetrunc:24 }} @@ -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 %}
{% endfor %} diff --git a/catalog/templates/performanceproduction.html b/catalog/templates/performanceproduction.html index 6abcdea6..5258de5e 100644 --- a/catalog/templates/performanceproduction.html +++ b/catalog/templates/performanceproduction.html @@ -30,7 +30,7 @@
{% include '_people.html' with people=item.orig_creator role='原作' max=5 %}
{% include '_people.html' with people=item.director role='导演' max=5 %}
{% include '_people.html' with people=item.playwright role='编剧' max=5 %}
-
{% include '_crew.html' with people=item.actor role='演员' max=50 %}
+
{% include '_actor.html' with people=item.actor role='演员' max=50 %}
{% include '_people.html' with people=item.performer role='表演者' max=50 %}
{% include '_people.html' with people=item.composer role='作曲' max=5 %}
{% include '_people.html' with people=item.choreographer role='编舞' max=5 %}