feat: open pdfs in new tab in browser instead of download (#136)

closes #127

Reviewed-on: #136
Reviewed-by: Christian Merten <christian@merten.dev>
Co-authored-by: marius.klein <marius.klein@alpenverein-heidelberg.de>
Co-committed-by: marius.klein <marius.klein@alpenverein-heidelberg.de>
pull/133/head
marius.klein 10 months ago committed by Christian Merten
parent bffacf7808
commit 7a9c6f9d85

@ -30,7 +30,9 @@ def serve_media(filename, content_type):
with open(media_path(filename), 'rb') as f: with open(media_path(filename), 'rb') as f:
response = HttpResponse(FileWrapper(f)) response = HttpResponse(FileWrapper(f))
response['Content-Type'] = content_type response['Content-Type'] = content_type
response['Content-Disposition'] = 'attachment; filename='+filename # download other files than pdf, show pdfs in the browser
response['Content-Disposition'] = 'filename='+filename if content_type == 'application/pdf' else 'attachment; filename='+filename
return response return response

@ -57,7 +57,7 @@ This also includes a detailed, tabularized time schedule and is produced as an e
{% blocktrans %}A cost and participants overview. This is not required for the actual application, but is provided for convience as a PDF document.{% endblocktrans %} {% blocktrans %}A cost and participants overview. This is not required for the actual application, but is provided for convience as a PDF document.{% endblocktrans %}
</td> </td>
<td> <td>
<a href="{% url 'admin:members_freizeit_download_ljp_costs_participants' memberlist.pk %}" class="button">{% translate "Download" %}</a> <a href="{% url 'admin:members_freizeit_download_ljp_costs_participants' memberlist.pk %}" class="button" target="_blank">{% translate "Download" %}</a>
</td> </td>
</tr> </tr>
</table> </table>

@ -30,7 +30,7 @@
{% blocktrans %}The application needs to be complemented with an invoice from the trip as proof.{% endblocktrans %} {% blocktrans %}The application needs to be complemented with an invoice from the trip as proof.{% endblocktrans %}
</p> </p>
<form action="" method="post"> <form action="" method="post" target="_blank">
{% csrf_token %} {% csrf_token %}
<p> <p>
<table> <table>

@ -4,7 +4,7 @@
{% block object-tools-items %} {% block object-tools-items %}
<li> <li>
<form method="post" action="{% url 'admin:members_freizeit_action' original.pk %}"> <form method="post" action="{% url 'admin:members_freizeit_action' original.pk %}" target="_blank">
{% csrf_token %} {% csrf_token %}
<input type="submit" name="crisis_intervention_list" value="{% trans 'Generate crisis intervention list' %}"> <input type="submit" name="crisis_intervention_list" value="{% trans 'Generate crisis intervention list' %}">
</form> </form>
@ -25,7 +25,7 @@
</li> </li>
<li> <li>
<form method="post" action="{% url 'admin:members_freizeit_action' original.pk %}"> <form method="post" action="{% url 'admin:members_freizeit_action' original.pk %}" target="_blank">
{% csrf_token %} {% csrf_token %}
<input type="submit" name="notes_list" value="{% trans 'Generate overview' %}"> <input type="submit" name="notes_list" value="{% trans 'Generate overview' %}">
</form> </form>

Loading…
Cancel
Save