From d77a4dde3e342cec3668e972a4bdce19c627fefb Mon Sep 17 00:00:00 2001 From: Basile Clement Date: Sun, 6 Nov 2016 01:36:10 +0100 Subject: [PATCH 1/3] GestioCOF devrait fonctionner sur / aussi bien que sur /gestion --- cof/settings_dev.py | 10 +++------- cof/urls.py | 20 ++++++++------------ kfet/routing.py | 4 +--- provisioning/apache.conf | 10 ++++++++++ provisioning/bootstrap.sh | 2 +- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/cof/settings_dev.py b/cof/settings_dev.py index 6747963b..11c2faf9 100644 --- a/cof/settings_dev.py +++ b/cof/settings_dev.py @@ -135,10 +135,6 @@ MEDIA_URL = '/media/' # Various additional settings SITE_ID = 1 -# URL prefix for admin static files -- CSS, JavaScript and images. -# Make sure to use a trailing slash. -# Examples: "http://foo.com/static/admin/", "/static/admin/". -ADMIN_MEDIA_PREFIX = '/static/grappelli/' GRAPPELLI_ADMIN_HEADLINE = "GestioCOF" GRAPPELLI_ADMIN_TITLE = "GestioCOF" @@ -155,12 +151,12 @@ MAIL_DATA = { 'REPLYTO': 'BdA-Revente '}, } -LOGIN_URL = "/gestion/login" -LOGIN_REDIRECT_URL = "/gestion/" +LOGIN_URL = "cof-login" +LOGIN_REDIRECT_URL = "home" CAS_SERVER_URL = 'https://cas.eleves.ens.fr/' CAS_IGNORE_REFERER = True -CAS_REDIRECT_URL = '/gestion/' +CAS_REDIRECT_URL = '/' CAS_EMAIL_FORMAT = "%s@clipper.ens.fr" AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', diff --git a/cof/urls.py b/cof/urls.py index 263fc3a0..f3d6905e 100644 --- a/cof/urls.py +++ b/cof/urls.py @@ -24,7 +24,7 @@ from gestioncof.autocomplete import autocomplete autocomplete_light.autodiscover() admin.autodiscover() -my_urlpatterns = [ +urlpatterns = [ # Page d'accueil url(r'^$', gestioncof_views.home, name='home'), # Le BdA @@ -48,7 +48,7 @@ my_urlpatterns = [ url(r'^cas/logout$', django_cas_views.logout), url(r'^outsider/login$', gestioncof_views.login_ext), url(r'^outsider/logout$', django_views.logout, {'next_page': 'home'}), - url(r'^login$', gestioncof_views.login), + url(r'^login$', gestioncof_views.login, name="cof-login"), url(r'^logout$', gestioncof_views.logout), # Infos persos url(r'^profile$', gestioncof_views.profile), @@ -81,14 +81,10 @@ my_urlpatterns = [ url(r'^utile_bda/bda_diff$', gestioncof_views.liste_bdadiff), url(r'^utile_cof/diff_cof$', gestioncof_views.liste_diffcof), url(r'^utile_bda/bda_revente$', gestioncof_views.liste_bdarevente), - url(r'^k-fet/', include('kfet.urls')) -] + \ - (static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) - if settings.DEBUG - else []) -# Si on est en production, MEDIA_ROOT est servi par Apache. -# Il faut dire à Django de servir MEDIA_ROOT lui-même en développement. - -urlpatterns = [ - url(r'^gestion/', include(my_urlpatterns)) + url(r'^k-fet/', include('kfet.urls')), ] + +if settings.DEBUG: + # Si on est en production, MEDIA_ROOT est servi par Apache. + # Il faut dire à Django de servir MEDIA_ROOT lui-même en développement. + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/kfet/routing.py b/kfet/routing.py index 9c816c92..63e0c963 100644 --- a/kfet/routing.py +++ b/kfet/routing.py @@ -8,7 +8,5 @@ from channels.routing import route, route_class from kfet import consumers channel_routing = [ - route_class(consumers.KPsul, path=r"^/gestion/ws/k-fet/k-psul/$"), - #route("websocket.connect", ws_kpsul_history_connect), - #route('websocket.receive', ws_message) + route_class(consumers.KPsul, path=r"^ws/k-fet/k-psul/$"), ] diff --git a/provisioning/apache.conf b/provisioning/apache.conf index 001c6ec9..cc815592 100644 --- a/provisioning/apache.conf +++ b/provisioning/apache.conf @@ -6,6 +6,16 @@ ProxyRequests Off ProxyPass /static/ ! ProxyPass /media/ ! + # Pour utiliser un sous-dossier (typiquement /gestion/), il faut faire a la + # place des lignes suivantes: + # + # RequestHeader set Daphne-Root-Path /gestion + # ProxyPass /gestion/ws/ ws://127.0.0.1:8001/gestion/ws/ + # ProxyPass /gestion http://127.0.0.1:8001/gestion + # ProxyPassReverse /gestion http://127.0.0.1:8001/gestion + # + # Penser egalement a changer les /static/ et /media/ dans la config apache + # ainsi que dans les settings django. ProxyPass /ws/ ws://127.0.0.1:8001/ws/ ProxyPass / http://127.0.0.1:8001/ ProxyPassReverse / http://127.0.0.1:8001/ diff --git a/provisioning/bootstrap.sh b/provisioning/bootstrap.sh index f072e6fc..152e903a 100644 --- a/provisioning/bootstrap.sh +++ b/provisioning/bootstrap.sh @@ -23,7 +23,7 @@ mysql -uroot -p$DBPASSWD -e "CREATE DATABASE $DBNAME; GRANT ALL PRIVILEGES ON $D # Installation et configuration d'Apache apt-get install -y apache2 -a2enmod proxy proxy_http +a2enmod proxy proxy_http proxy_wstunnel headers cp /vagrant/provisioning/apache.conf /etc/apache2/sites-available/gestiocof.conf a2ensite gestiocof a2dissite 000-default From a63f1da2e11c7ce172229af1140ffd466508632f Mon Sep 17 00:00:00 2001 From: Basile Clement Date: Sun, 6 Nov 2016 19:44:05 +0100 Subject: [PATCH 2/3] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20django=5Fdebug?= =?UTF-8?q?=5Ftoolbar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cof/settings_dev.py | 1 + cof/urls.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/cof/settings_dev.py b/cof/settings_dev.py index 11c2faf9..8a622318 100644 --- a/cof/settings_dev.py +++ b/cof/settings_dev.py @@ -53,6 +53,7 @@ INSTALLED_APPS = ( ) MIDDLEWARE_CLASSES = ( + 'debug_toolbar.middleware.DebugToolbarMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', diff --git a/cof/urls.py b/cof/urls.py index f3d6905e..5134456a 100644 --- a/cof/urls.py +++ b/cof/urls.py @@ -85,6 +85,11 @@ urlpatterns = [ ] if settings.DEBUG: + import debug_toolbar + urlpatterns += [ + url(r'^__debug__/', include(debug_toolbar.urls)), + ] + # Si on est en production, MEDIA_ROOT est servi par Apache. # Il faut dire à Django de servir MEDIA_ROOT lui-même en développement. urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) From 107079ce1f4c0986a17843b8cfc379263775e4a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Mon, 14 Nov 2016 06:39:55 +0100 Subject: [PATCH 3/3] Fix pip version --- provisioning/bootstrap.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/provisioning/bootstrap.sh b/provisioning/bootstrap.sh index 152e903a..a873973f 100644 --- a/provisioning/bootstrap.sh +++ b/provisioning/bootstrap.sh @@ -10,6 +10,7 @@ DBPASSWD="4KZt3nGPLVeWSvtBZPSM3fSzXpzEU4" # Installation de paquets utiles apt-get update && apt-get install -y mercurial python-pip python-dev \ libmysqlclient-dev libjpeg-dev git redis-server +pip install -U pip # Configuration et installation de mysql. Le mot de passe root est le même que # le mot de passe pour l'utilisateur local - pour rappel, ceci est une instance