From c2509f112e8b30176301557b473588a96c0ce404 Mon Sep 17 00:00:00 2001 From: alazo Date: Thu, 20 Apr 2017 18:08:40 +0200 Subject: [PATCH] UploadDocs --- cms/models.py | 3 +++ common/urls.py | 2 +- common/wsgi.py | 30 +++++++++++++++++++++++++++--- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/cms/models.py b/cms/models.py index cbcfc3f..17aa28e 100644 --- a/cms/models.py +++ b/cms/models.py @@ -207,6 +207,9 @@ class Document(models.Model): class UploadDoc(models.Model): + class Meta: + verbose_name= 'UploadDoc' + docfile = models.FileField(upload_to='doc/') titre = models.CharField(max_length=100, blank=False) published = models.BooleanField(default=False) diff --git a/common/urls.py b/common/urls.py index 4d1ea3a..b65ec71 100644 --- a/common/urls.py +++ b/common/urls.py @@ -40,4 +40,4 @@ urlpatterns = [ url(r'^document/(?P\d+)$', views.DocumentDetailView.as_view(), name='document-detail'), url(r'^upload/(?P\d+)$', views.UploadDetailView.as_view(), name='upload-detail'), url(r'^tinymce/', include('tinymce.urls'), name='tinymce-js'), -] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) +] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT ) diff --git a/common/wsgi.py b/common/wsgi.py index 6f24829..99fc410 100644 --- a/common/wsgi.py +++ b/common/wsgi.py @@ -9,8 +9,32 @@ https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/ import os -from django.core.wsgi import get_wsgi_application +UPGRADING = False -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "common.settings") -application = get_wsgi_application() +def upgrade_in_progress(environ, start_response): + response_headers = [('Content-type','text/html')] + response = """ + +

This site is in maintenance mode; please come back in some minutes.

+

Ce site est actuellement en maintenance; merci de revenir dans quelques minutes.

+ + """ + if environ['REQUEST_METHOD'] == 'GET': + status = '200 OK' + else: + status = '403 Forbidden' + start_response(status, response_headers) + return [response.encode('utf-8')] + +if UPGRADING: + application = upgrade_in_progress +else: + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "common.settings") + + # This application object is used by any WSGI server configured to use this + # file. This includes Django's development server, if the WSGI_APPLICATION + # setting points here. + from django.core.wsgi import get_wsgi_application + application = get_wsgi_application() +