From 574b5186de4186fbcfc3c6ab4dc4f522c39f8cb1 Mon Sep 17 00:00:00 2001 From: Evarin Date: Sun, 24 Jun 2018 22:24:24 +0200 Subject: [PATCH 1/2] =?UTF-8?q?R=C3=A9pare=20le=20probl=C3=A8me=20avec=20l?= =?UTF-8?q?es=20espaces=20et=20extensions=20de=20fichier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- partitions/views.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/partitions/views.py b/partitions/views.py index e4e9b4d..4127ea5 100644 --- a/partitions/views.py +++ b/partitions/views.py @@ -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 From d50dff0c2881b78747a7d50e45ba60b2f07f2f40 Mon Sep 17 00:00:00 2001 From: Evarin Date: Sun, 24 Jun 2018 22:38:53 +0200 Subject: [PATCH 2/2] =?UTF-8?q?Fix=20pour=20la=20d=C3=A9tection=20du=20cha?= =?UTF-8?q?mp=20username=20par=20Firefox?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Étrangement, sur firefox, le mot de passe s'enregistre mais pas le nom d'utilisateur, c'est peu pratique. Avec ces changement, c'est réparé. --- gestion/templates/gestion/login.html | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/gestion/templates/gestion/login.html b/gestion/templates/gestion/login.html index 241f6ac..060e308 100644 --- a/gestion/templates/gestion/login.html +++ b/gestion/templates/gestion/login.html @@ -11,14 +11,7 @@ {% endif %}
{% csrf_token %} - - - - - - - -
+{{ form.as_p }} {% if next %}