Skip to content

Commit

Permalink
Merge pull request #363 from EsupPortail/ptitloup/fixbug_redirect_ver…
Browse files Browse the repository at this point in the history
…sion

Ptitloup/fixbug redirect version
  • Loading branch information
ptitloup authored Oct 27, 2020
2 parents 04c5948 + cead0ce commit fa96190
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 39 deletions.
39 changes: 5 additions & 34 deletions pod/enrichment/templates/enrichment/video_enrichment.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,39 +38,6 @@
{% csrf_token %}
</form>

<!--<nav id="navbar-video" class="navbar navbar-light bg-light">
<div class="navbar-brand" >
<div style="display:inline-block; white-space: normal;">({% trans 'Enriched' %}) {{video.title}} {% if video.date_evt %}<small>[{{ video.date_evt }}]</small>{% endif %}</div>
</div>
<div class="list-group col-12">
<fieldset>
<div class="list-group-item">
<div class="form-group ">
<label for="txtintegration">{% trans 'Copy the content of this text box and paste it in the page' %}:</label>
<textarea name="txtintegration" id="txtintegration" class="form-control" rows="4">&lt;iframe src="{% if request.is_secure %}https{% else %}http{% endif %}://{{ request.META.HTTP_HOST }}{% url 'enrichment:video_enrichment' slug=video.slug %}?is_iframe=true" width="640" height="360" style="padding: 0; margin: 0; border:0" allowfullscreen &gt;&lt;/iframe&gt;</textarea>
</div>
</div>
<div class="list-group-item">
<div class="form-group">
<label for="txtpartage">{% trans 'Use this link to share the video' %} :</label>
<input class="form-control" type="text" name="txtpartage" id="txtpartage" value="{% if request.is_secure %}https{% else %}http{% endif %}://{{ request.META.HTTP_HOST }}{% url 'enrichment:video_enrichment' slug=video.slug %}" />
</div>
</div>
<div class="list-group-item">
<div class="form-group">
{% if request.user == video.owner or request.user.is_superuser %}
<a href="{% url 'enrichment:edit_enrichment' slug=video.slug %}" class="btn btn-info btn-sm float-right" title="Back to original video">
{% trans 'Edit enrichment' %}
</a>
{% endif %}
<a href="{% url 'video' slug=video.slug %}" class="btn btn-info btn-sm " title="Back to original video">
{% trans 'Back to original' %}
</a>
</div>
</div>
</fieldset>
</div>
</nav>-->
<h1 class="pt-2">
{% if video.licence %}<a href="https://creativecommons.org/licenses/{{video.licence}}/4.0" title="{{video.get_licence}}" target="_blank"><img src="https://licensebuttons.net/l/{{video.licence}}/4.0/88x31.png"></a>{% endif %} {{video.title|title}}
{% if video.date_evt %}<small>[{{ video.date_evt }}]</small>{% endif %}
Expand Down Expand Up @@ -110,7 +77,11 @@ <h1 class="pt-2">
<i data-feather="layers"></i>&nbsp;<span class="sr-only">{% trans 'Other versions' %}</span>
</a>
<div class="dropdown-menu" >
<a href="{% url 'video' slug=video.slug %}?redirect=false" title="no enrichment" class="dropdown-item" target="_blank">{% trans 'Original version' %}</a>
{% if video.get_hashkey in request.get_full_path %}
<a href="{% url 'video' slug=video.slug %}{{ video.get_hashkey }}/?redirect=false" title="{% trans 'Original version' %}" class="dropdown-item" target="_blank">{% trans 'Original version' %}</a>
{% else %}
<a href="{% url 'video' slug=video.slug %}?redirect=false" title="{% trans 'Original version' %}" class="dropdown-item" target="_blank">{% trans 'Original version' %}</a>
{% endif %}
</div>
</li>
{% if request.user.playlist_set.all and video.is_draft == False %}
Expand Down
8 changes: 7 additions & 1 deletion pod/interactive/templates/interactive/video_interactive.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,13 @@ <h1 class="pt-2">
<i data-feather="layers"></i>&nbsp;<span class="sr-only">{% trans 'Other versions' %}</span>
</a>
<div class="dropdown-menu" >
<a href="{% url 'video' slug=video.slug %}?redirect=false" title="no enrichment" class="dropdown-item" target="_blank">{% trans 'Original version' %}</a>
{% if video.get_hashkey in request.get_full_path %}
<a href="{% url 'video' slug=video.slug %}{{ video.get_hashkey }}/?redirect=false" title="{% trans 'Original version' %}" class="dropdown-item" target="_blank">{% trans 'Original version' %}</a>
{% else %}
<a href="{% url 'video' slug=video.slug %}?redirect=false" title="{% trans 'Original version' %}" class="dropdown-item" target="_blank">{% trans 'Original version' %}</a>
{% endif %}


</div>
</li>
{% if request.user.playlist_set.all and video.is_draft == False %}
Expand Down
7 changes: 5 additions & 2 deletions pod/video/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,10 +743,13 @@ def get_other_version(self):
)
return version

def get_default_version_link(self):
def get_default_version_link(self, slug_private):
for version in self.get_other_version():
if version["link"] == VERSION_CHOICES_DICT[self.get_version]:
return version["url"]
if slug_private:
return version["url"]+slug_private+"/"
else:
return version["url"]

def get_viewcount(self):
count_sum = self.viewcount_set.all().aggregate(Sum('count'))
Expand Down
6 changes: 5 additions & 1 deletion pod/video/templates/videos/video.html
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,19 @@ <h1 class="pt-2">
</a>
</li>
{%endif%}
{% with video.get_other_version as versions %}
{% with video.get_other_version as versions %}
{% if versions|length > 0 %}
<li class="nav-item dropdown" id="list_third_apps">
<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="{% trans 'Other versions' %}">
<i data-feather="layers"></i>&nbsp;<span class="sr-only">{% trans 'Other versions' %}</span>
</a>
<div class="dropdown-menu" >
{% for version in versions %}
{% if video.get_hashkey in request.get_full_path %}
<a href="{{version.url}}{{ video.get_hashkey }}/?redirect=false" title="{{version.app}}" class="dropdown-item" >{{version.link}}</a>
{% else %}
<a href="{{version.url}}?redirect=false" title="{{version.app}}" class="dropdown-item" >{{version.link}}</a>
{% endif %}
{% endfor %}
</div>
</li>
Expand Down
2 changes: 1 addition & 1 deletion pod/video/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ def video(request, slug, slug_c=None, slug_t=None, slug_private=None):
video.get_version != "O" and
request.GET.get('redirect') != "false"
):
return redirect(video.get_default_version_link())
return redirect(video.get_default_version_link(slug_private))
return render_video(request, id, slug_c, slug_t, slug_private,
template_video, params)

Expand Down

0 comments on commit fa96190

Please sign in to comment.