Skip to content

Commit

Permalink
Make better use of many-to-many relationships
Browse files Browse the repository at this point in the history
  • Loading branch information
davorg committed Apr 24, 2019
1 parent e81ef77 commit d539e8b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions in/author.tt
Expand Up @@ -9,10 +9,10 @@
[% IF author.died %]Died: [% author.died.strftime('%m %B %Y'); END %]</p>
[% END %]
<h3>Works</h3>
[% IF author.author_works.size %]
[% IF author.works.size %]
<ul>
[% FOR w IN author.author_works.sort('published') %]
<li><a href="/works/[% w.work.slug %]">[% w.work.title %]</a></li>
[% FOR w IN author.works.sort('published') %]
<li><a href="/works/[% w.slug %]">[% w.title %] ([% w.published.strftime('%Y') %])</a></li>
[% END %]
</ul>
[% ELSE %]
Expand Down
8 changes: 4 additions & 4 deletions in/character.tt
Expand Up @@ -5,12 +5,12 @@
<h1 class="display-3">[% character.name %]</h1>
[% IF character.imdb %]<p><a href="http://imdb.com/character/[% fictionalcharacter.imdb %]">[% fictionalcharacter.name %] on IMDB</a></p>[% END %]
<h3>Appearances</h3>
[% IF character.character_appearances.size %]
[% IF character.works.size %]
<ul>
[% FOR a IN character.character_appearances %]
<li><a href="/works/[% a.work.slug %]">[% a.work.title %]</a>
[% FOR w IN character.works %]
<li><a href="/works/[% w.slug %]">[% w.title %]</a>
by
[% FOR au IN a.work.authors %]
[% FOR au IN w.authors %]
<a href="/authors/[% au.slug %]">[% au.name %]</a>
[% END %]
</li>
Expand Down
6 changes: 3 additions & 3 deletions in/work.tt
Expand Up @@ -5,10 +5,10 @@
<h1 class="display-3">[% work.title %]</h1>
<p>By [% FOR a IN work.authors; '<a href="/authors/'; a.slug; '">'; a.name; '</a> '; END %]</p>
<h3>Characters</h3>
[% IF work.character_appearances.size %]
[% IF work.characters.size %]
<ul>
[% FOR ch IN work.character_appearances %]
<li><a href="/characters/[% ch.character.slug %]">[% ch.character.name %]</a></li>
[% FOR ch IN work.characters %]
<li><a href="/characters/[% ch.slug %]">[% ch.name %]</a></li>
[% END %]
</ul>
[% ELSE %]
Expand Down

0 comments on commit d539e8b

Please sign in to comment.