Commit 428ed258e9e231b26367a9dd6c04b19fce7cb727
Exists in
master
and in
3 other branches
solved conflict
Showing
5 changed files
with
17 additions
and
5 deletions
Show diff stats
topics/templates/resources/list.html
... | ... | @@ -14,7 +14,9 @@ |
14 | 14 | <input type="hidden" class="url_order" value="{% url 'topics:update_resource_order' %}" /> |
15 | 15 | |
16 | 16 | <h4 class="pull-left list-group-item-heading"> |
17 | - <a href="{% url resource.access_link resource.slug %}" class="resource_link" {% if resource.show_window %}target="_blank"{% endif %} > | |
17 | + | |
18 | + <a href="{% url resource.access_link resource.slug %}" class="resource_link" {% if resource.show_window %}target="_blank"{% endif %}> | |
19 | + | |
18 | 20 | {{ resource.name }} |
19 | 21 | </a> |
20 | 22 | </h4> | ... | ... |
youtube_video/forms.py
... | ... | @@ -63,8 +63,8 @@ class YTVideoForm(forms.ModelForm): |
63 | 63 | def clean_url(self): |
64 | 64 | url = self.cleaned_data.get('url', '') |
65 | 65 | |
66 | - if not 'youtube' in url or not 'embed' in url: | |
67 | - self._errors['url'] = [_('Invalid URL. It should be an embed YouTube link.')] | |
66 | + if not 'youtube' in url: | |
67 | + self._errors['url'] = [_('Invalid URL. It should be an YouTube link.')] | |
68 | 68 | |
69 | 69 | return ValueError |
70 | 70 | ... | ... |
youtube_video/models.py
... | ... | @@ -27,3 +27,13 @@ class YTVideo(Resource): |
27 | 27 | |
28 | 28 | def delete_message(self): |
29 | 29 | return _('Are you sure you want delete the YouTube Video') |
30 | + | |
31 | + def get_embed_url(self): | |
32 | + if not "embed" in self.url: | |
33 | + parts = self.url.split("=") | |
34 | + | |
35 | + if parts[1]: | |
36 | + return "https://www.youtube.com/embed/" + parts[1] | |
37 | + | |
38 | + return self.url | |
39 | + | ... | ... |
youtube_video/templates/youtube/view.html
... | ... | @@ -50,7 +50,7 @@ |
50 | 50 | <input type="hidden" id="log_finish_url" value="{% url 'youtube:finish' youtube.slug %}" /> |
51 | 51 | <input type="hidden" id="log_url" value="{% url 'youtube:watch' youtube.slug %}" /> |
52 | 52 | <input type="hidden" id="log_id" value="" /> |
53 | - <iframe src="{{ youtube.url }}?enablejsapi=1" frameborder="0" allowfullscreen id="video"></iframe> | |
53 | + <iframe src="{{ youtube.get_embed_url }}?enablejsapi=1" frameborder="0" allowfullscreen id="video"></iframe> | |
54 | 54 | </div> |
55 | 55 | </div> |
56 | 56 | ... | ... |
youtube_video/templates/youtube/window_view.html
... | ... | @@ -23,7 +23,7 @@ |
23 | 23 | <input type="hidden" id="log_finish_url" value="{% url 'youtube:finish' youtube.slug %}" /> |
24 | 24 | <input type="hidden" id="log_url" value="{% url 'youtube:watch' youtube.slug %}" /> |
25 | 25 | <input type="hidden" id="log_id" value="" /> |
26 | - <iframe src="{{ youtube.url }}?enablejsapi=1" frameborder="0" allowfullscreen id="video"></iframe> | |
26 | + <iframe src="{{ youtube.get_embed_url }}?enablejsapi=1" frameborder="0" allowfullscreen id="video"></iframe> | |
27 | 27 | |
28 | 28 | <script type="text/javascript" src="{% static 'js/ytvideo.js' %}"></script> |
29 | 29 | <script type="text/javascript"> | ... | ... |