Commit fd09be3f8b1c87aeb3f206627baa6df528866f15
1 parent
b10e1ae1
Exists in
master
and in
2 other branches
Changing filepath 'calculation' in download function in bulletin
Showing
1 changed file
with
3 additions
and
5 deletions
Show diff stats
bulletin/views.py
... | ... | @@ -6,8 +6,6 @@ from django.utils.translation import ugettext_lazy as _ |
6 | 6 | from django.contrib.auth.mixins import LoginRequiredMixin |
7 | 7 | from django.http import JsonResponse |
8 | 8 | |
9 | -from os import path | |
10 | - | |
11 | 9 | from amadeus.permissions import has_subject_permissions, has_resource_permissions |
12 | 10 | from .utils import brodcast_dificulties |
13 | 11 | from goals.models import Goals,GoalItem,MyGoals |
... | ... | @@ -408,9 +406,9 @@ class CreateView(LoginRequiredMixin, LogMixin, generic.edit.CreateView): |
408 | 406 | return success_url |
409 | 407 | |
410 | 408 | def download_excel(request, file): |
411 | - filepath = 'bulletin/sheets/xls/' + file + '.xls' | |
409 | + filepath = os.path.join('bulletin', os.path.join('sheets', os.path.join('xls', file + '.xls'))) | |
412 | 410 | |
413 | - if not path.exists(filepath): | |
411 | + if not os.path.exists(filepath): | |
414 | 412 | raise Http404() |
415 | 413 | |
416 | 414 | response = HttpResponse(open(filepath, 'rb').read()) |
... | ... | @@ -420,7 +418,7 @@ def download_excel(request, file): |
420 | 418 | response['Cache-Control'] = 'must-revalidate, post-check=0, pre-check=0' |
421 | 419 | response['Content-Disposition'] = 'attachment; filename=%s' % (file + '.xls') |
422 | 420 | response['Content-Transfer-Encoding'] = 'binary' |
423 | - response['Content-Length'] = str(path.getsize(filepath)) | |
421 | + response['Content-Length'] = str(os.path.getsize(filepath)) | |
424 | 422 | |
425 | 423 | return response |
426 | 424 | ... | ... |