diff --git a/.gitignore b/.gitignore index 078ba94..9d72eee 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,7 @@ db.eds db.* *.sql *.csv +*.xls +*.xlsx .* + diff --git a/cms/views.py b/cms/views.py index be93bb0..8282827 100644 --- a/cms/views.py +++ b/cms/views.py @@ -397,29 +397,10 @@ def Download(request, file_name): def pdf_view(request): - with open('/home/alzo/dev/eds/media/media/EDS_Calendrier_2017.pdf', 'r') as pdf: + with open(settings.MEDIA_ROOT + '/media/EDS_Calendrier_2017.pdf', 'r') as pdf: response = HttpResponse(pdf.read().decode('latin-1') , content_type='application/pdf') response['Content-Disposition'] = 'inline;filename=some_file.pdf' return response pdf.closed - -def import_xls_file(request): - import xlrd - - if request.method == 'POST': - xlspath = '/home/alzo/Export_CLOEE_FE.xls' - with xlrd.open_workbook(xlspath) as book: - sheet = book.sheet_by_index(0) - print(sheet.ncols) - print(sheet.nrows) - - - if request.method == 'GET': - xlspath = '/home/alzo/Export_CLOEE_FE.xls' - with xlrd.open_workbook(xlspath) as book: - sheet = book.sheet_by_index(0) - for rownum in range(1,sheet.nrows): - print(int(sheet.row_values(rownum)[0])) - - + \ No newline at end of file diff --git a/common/settings.py b/common/settings.py index 2027172..87e7aa2 100644 --- a/common/settings.py +++ b/common/settings.py @@ -112,10 +112,10 @@ USE_TZ = True # https://docs.djangoproject.com/en/1.10/howto/static-files/ STATIC_URL = '/static/' -STATIC_ROOT = os.path.join(BASE_DIR, 'static') +STATIC_ROOT = os.path.join(BASE_DIR, 'static/') MEDIA_URL = '/media/' -MEDIA_ROOT = os.path.join(BASE_DIR, 'media') +MEDIA_ROOT = os.path.join(BASE_DIR, 'media/') STUDENT_IMPORT_MAPPING = { 'Num élève': 'id_ext', diff --git a/common/urls.py b/common/urls.py index aa8639a..940d4f4 100644 --- a/common/urls.py +++ b/common/urls.py @@ -38,6 +38,5 @@ urlpatterns = [ url(r'^module_pdf/(?P\d+)$', views.ModulePDF.as_view(), name='module-pdf'), url(r'^documents/$', views.DocumentListView.as_view(), name='document-list'), url(r'^document/(?P\d+)$', views.DocumentDetailView.as_view(), name='document-detail'), - url(r'^import/$', views.import_xls_file), url(r'^tinymce/', include('tinymce.urls'), name='tinymce-js'), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)