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 %} 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