Commits

Benjamin Klüglein committed ddeff09

Added a check if the file is existing to the view func and changed the view to be a table

  • Participants
  • Parent commits fbea7fd

Comments (0)

Files changed (2)

File templates/upload/show_download.html

 <div>
-{{ download.id }}
-{{ download.name }}
 
-{{ download.description }}
-
-{{ download.filename }}
 {{ download.download_password }}
 
-{{ download.is_password_protected }}
-
-{{ download.created_at }}
+<table>
+<tr><td>Datei:</td><td>{{ download.name }}</td></tr>
+<tr><td>Beschreibung:</td><td>{{ download.description }}</td></tr>
+<tr><td>Dateiname:</td><td>{{ download.filename }}</td></tr>
+<tr><td>Passwort notwendig?</td><td>{{ download.is_password_protected }}</td></tr>
+<tr><td>Hinzugefügt:</td><td>{{ download.created_at }}</td></tr>
+</table>
 
 {% if form %}
 <form action="/download/{{ download.id }}/" method="post">

File upload/views.py

 from mimetypes import guess_type
+import os.path
 
 from django.core.files import File as DjangoFile
 from django.http import HttpResponse, Http404, HttpResponseForbidden
         return render_to_response("templates/upload/show_download.html", {"download" : f, 
             'form': form})
     elif request.method == 'POST':
+        if not os.path.isfile(f.file_on_fs.name):
+            raise Http404("Datei konnte nicht gefunden werden")
         form = DownloadFileForm(request.POST)
         if form.is_valid() and form.cleaned_data['password'] == f.download_password:
             file_to_download = DjangoFile(f.file_on_fs)