Merge branch 'Evarin/various-fixes' into 'master'

Deux petits débugs

See merge request cof-geek/Ernesto!6
This commit is contained in:
Martin Pepin 2018-06-25 14:24:09 +02:00
commit 8d74be936b
2 changed files with 6 additions and 12 deletions

View file

@ -11,14 +11,7 @@
{% endif %}
<form method="post" action="{% url 'login' %}">
{% csrf_token %}
<table>
<tr>
<td><input type="{{ form.username.type }}" name="{{ form.username.name }}" placeholder="Login"/></td>
</tr>
<tr>
<td><input type="password" name="{{ form.password.name }}" placeholder="Password"/></td>
</tr>
</table>
{{ form.as_p }}
<input type="submit" value="Connexion" />
{% if next %}
<input type="hidden" name="next" value={{ next }} />

View file

@ -1,6 +1,7 @@
from django.shortcuts import render, HttpResponse, get_object_or_404
from django.contrib.auth.decorators import login_required
from django.utils.encoding import smart_str
from django.utils.text import slugify
from django.forms.models import modelform_factory
from django.core.files import File
from django.utils.safestring import mark_safe
@ -52,8 +53,8 @@ def see(request, nom, auteur, partition_id):
myfile = File(f)
response = HttpResponse(content=myfile.read())
response["Content-Type"] = "application/pdf"
response["Content-Disposition"] = "inline; filename=%s-%s-%s" % (
nom, auteur, smart_str(os.path.basename(myfile.name)))
response["Content-Disposition"] = "inline; filename=%s_%s_%s.pdf" % (
slugify(nom), slugify(auteur), slugify(partition.nom))
return response
elif ".mp3" == extension:
with open(partition.part.path, 'rb') as f:
@ -77,8 +78,8 @@ def download(request, nom, auteur, partition_id):
response = HttpResponse(content=myfile.read())
typ = os.path.splitext(myfile.name)[1][1:]
response['Content-Type'] = 'application/%s' % (typ, )
response['Content-Disposition'] = 'attachment; filename=%s-%s-%s' % (
nom, auteur, smart_str(os.path.basename(myfile.name)))
response['Content-Disposition'] = 'attachment; filename=%s_%s_%s.%s' % (
slugify(nom), slugify(auteur), slugify(partition.nom), typ)
return response