Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix the video page to use the proper title/description.

  • Loading branch information...
commit 7f1f3be654429372607a68bae8c4b4839e8ae407 1 parent 72df3d9
@sjl sjl authored
Showing with 32 additions and 7 deletions.
  1. +23 −0 apps/videos/models.py
  2. +9 −7 templates/videos/video-view.html
View
23 apps/videos/models.py
@@ -707,6 +707,29 @@ def policy(self):
return self._cached_policy
+ def get_title_display(self):
+ """Return a suitable title to display to a user for this video.
+
+ This will use the most specific title if it's present, but if it's blank
+ it will fall back to the less-specific-but-at-least-it-exists video
+ title instead.
+
+ """
+ l = self.subtitle_language()
+ return l.get_title_display() if l else self.title
+
+ def get_description_display(self):
+ """Return a suitable description to display to a user for this video.
+
+ This will use the most specific description if it's present, but if it's
+ blank it will fall back to the less-specific-but-at-least-it-exists
+ video description instead.
+
+ """
+ l = self.subtitle_language()
+ return l.get_description_display() if l else self.description
+
+
@property
def is_moderated(self):
return bool(self.moderated_by_id)
View
16 templates/videos/video-view.html
@@ -58,14 +58,16 @@
<h2 class="main-title">
<a href="{{share_panel_permalink}}" title="Video permalink">{{ video }}</a>
</h2>
- <div id="description"{% if video.description|length > 300 %} class="abbr collapsed"{% endif %}>
- <div>
- {{ video.description|urlize|linebreaks }}
+ {% with video.get_description_display as description %}
+ <div id="description"{% if description|length > 300 %} class="abbr collapsed"{% endif %}>
+ <div>
+ {{ description|urlize|linebreaks }}
+ </div>
+ {% if description|length > 300 %}
+ <a class="expand" href="#">Show all ↓</a>
+ {% endif %}
</div>
- {% if video.description|length > 300 %}
- <a class="expand" href="#">Show all ↓</a>
- {% endif %}
- </div>
+ {% endwith %}
<ul class="metrics">
<li>
<div>
Please sign in to comment.
Something went wrong with that request. Please try again.