[Directory] don't fail on missing random podcast
[mygpo.git] / mygpo / directory / templates / directory.html
blob966b3dfb3a38f5ed1f9cc9e39b71eb8477e70094
1 {% extends "base.html" %}
3 {% load i18n %}
4 {% load podcasts %}
5 {% load charts %}
6 {% load math %}
7 {% load utils %}
9 {% load menu %}
10 {% block mainmenu %}{{ "/directory/"|main_menu }}{% endblock %}
11 {% block sectionmenu %}{{ "/directory/"|section_menu }}{% endblock %}
13 {% block title %}{% trans "Podcast Directory" %}{% endblock %}
15 {% block header %}
16 <h1>{% trans "Podcast Directory" %}</h1>
17 {% endblock %}
20 {% block content %}
21 {% for c in topics.categories %}
23 {% if forloop.counter0|divisibleby:"2" %}
24 <div class="row">
25 {% endif %}
27 <div class="col-md-6">
28 {% if c.cls == "PodcastList" %}
29 {% url "user" c.username as user-lists-url %}
30 <h2>{% blocktrans with c.title as listtitle and c.username as username %}{{ listtitle }} <span class="by-user">by <a href="{{ user-lists-url }}">{{ username }}</a></span>{% endblocktrans %}</h2>
31 {% else %}
32 <h2>{{ c.title }}</h2>
33 {% endif %}
35 <table class="list">
36 {% for entry in c.podcasts|slice:":10" %}
37 <tr>
38 <td class="logo">{{ entry.podcast|podcast_logo }}</td>
39 <td>{% podcast_group_link entry.podcast %}</td>
40 </tr>
41 {% endfor %}
42 <tr>
43 <td></td>
44 <td>
45 {% if c.cls == "PodcastList" %}
46 <a href="{% url "list-show" c.username c.slug %}">{% trans "more..." %}</a>
47 {% else %}
48 <a href="{% url "directory" c.clean_title %}">{% trans "more..." %}</a>
49 {% endif %}
50 <td></td>
51 </tr>
52 </table>
53 </div>
55 {% if forloop.counter|divisibleby:"2" %}
56 </div>
57 {% endif %}
59 {% endfor %}
61 <hr style="clear: both;"/>
63 <div id="tagcloud">
64 {% for category in topics.tagcloud %}
65 <span style="font-size: {% smartwidthratio category.num_entries topics.min_entries topics.max_entries 4 1 %}em">
66 <a href="{% url "directory" category.clean_title %}">{{ category.title }}</a>
67 </span>
68 {% endfor %}
69 </div>
70 {% endblock %}
73 {% block sidebar %}
75 {% for podcastlist in podcastlists %}
76 {% if podcastlist and podcastlist.user.username %}
77 <div class="well">
78 <h4>
79 <a href="{% url "list-show" podcastlist.user.username podcastlist.slug %}">
80 {{ podcastlist.title }}
81 </a>
82 <small>{% trans "Podcast List by" %}
83 <a href="{% url "lists-user" podcastlist.user.username %}">
84 {{ podcastlist.user.username }}
85 </a>
86 </small>
87 </h4>
89 <div class="logo-group">
90 {% for podcast in podcastlist.podcasts %}
92 <a href="{% podcast_link_target podcast %}">
93 {{ podcast|podcast_logo }}
94 </a>
96 {% endfor %}
98 {% if podcastlist.more_podcasts %}
99 {% blocktrans with podcastlist.more_podcasts as more %}and {{ more }} more{% endblocktrans %}
100 {% endif %}
101 </div>
103 <div class="btn-group">
104 <a class="btn btn-primary" href="{% url "lists-overview" %}">
105 {% trans "Create a Podcast List" %}
106 </a>
107 </div>
109 </div>
110 {% endif %}
111 {% endfor %}
113 {% if random_podcast %}
114 <div class="well">
116 <h4><small>{% trans "Random" %}</small></h4>
119 <a href="{% podcast_link_target random_podcast %}">
120 <div id="podcastlogo">{{ random_podcast|podcast_logo_medium }}</div>
121 </a>
123 <h4>{{ random_podcast.title }}</h4>
125 <p class="description">
126 {{ random_podcast.description|default:""|truncatewords:"50" }}
127 </p>
130 <a href="{% podcast_link_target random_podcast %}">{% trans "more..." %}</a>
131 </p>
133 </div>
134 {% endif %}
136 {% endblock %}