From e31dadad105295bf2dda588084014e9db62aead9 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Thu, 17 Nov 2016 22:35:33 -0200 Subject: [PATCH 1/2] =?UTF-8?q?d=C3=A9tection=20et=20affichage=20capslock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cof/settings_dev.py | 37 +++++++++++++------------- kfet/static/kfet/css/jconfirm-kfet.css | 19 +++++++++++++ kfet/static/kfet/js/kfet.js | 27 ++++++++++++++++++- 3 files changed, 63 insertions(+), 20 deletions(-) diff --git a/cof/settings_dev.py b/cof/settings_dev.py index 17040c38..0ba8d72b 100644 --- a/cof/settings_dev.py +++ b/cof/settings_dev.py @@ -29,9 +29,6 @@ SECRET_KEY = 'q()(zn4m63i%5cp4)f+ww4-28_w+ly3q9=6imw2ciu&_(5_4ah' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = ['127.0.0.1'] - - # Application definition INSTALLED_APPS = ( 'gestioncof', @@ -101,6 +98,7 @@ DATABASES = { 'NAME': os.environ['DBNAME'], 'USER': os.environ['DBUSER'], 'PASSWORD': os.environ['DBPASSWD'], + 'HOST': os.environ.get('DBHOST', 'localhost'), } } @@ -126,7 +124,7 @@ STATIC_URL = '/static/' STATIC_ROOT = '/var/www/static/' STATICFILES_DIRS = ( - os.path.join(BASE_DIR, 'static/'), + os.path.join(BASE_DIR, 'static/'), ) # Media upload (through ImageField, SiteField) @@ -138,31 +136,32 @@ 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" -PETITS_COURS_FROM = "Le COF " -PETITS_COURS_BCC = "archivescof@gmail.com" -PETITS_COURS_REPLYTO = "cof@ens.fr" +MAIL_DATA = { + 'petits_cours': { + 'FROM': "Le COF ", + 'BCC': "archivescof@gmail.com", + 'REPLYTO': "cof@ens.fr"}, + 'rappels': { + 'FROM': 'Le BdA ', + 'REPLYTO': 'Le BdA '}, + 'revente': { + 'FROM': 'BdA-Revente ', + 'REPLYTO': 'BdA-Revente '}, +} -RAPPEL_FROM = 'Le BdA ' -RAPPEL_REPLY_TO = RAPPEL_FROM - -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', 'gestioncof.shared.COFCASBackend', - 'kfet.backends.GenericTeamBackend', ) # EMAIL_HOST="nef.ens.fr" @@ -177,7 +176,7 @@ CHANNEL_LAYERS = { "default": { "BACKEND": "asgi_redis.RedisChannelLayer", "CONFIG": { - "hosts": [("localhost", 6379)], + "hosts": [(os.environ.get("REDIS_HOST", "localhost"), 6379)], }, "ROUTING": "cof.routing.channel_routing", } diff --git a/kfet/static/kfet/css/jconfirm-kfet.css b/kfet/static/kfet/css/jconfirm-kfet.css index 86c7c42b..4269fbcc 100644 --- a/kfet/static/kfet/css/jconfirm-kfet.css +++ b/kfet/static/kfet/css/jconfirm-kfet.css @@ -64,3 +64,22 @@ color:#FFF !important; background:#C8102E !important; } + +.jconfirm .capslock { + position: relative ; +} + +.jconfirm .capslock .glyphicon { + position: absolute; + padding: 10px; + right: 0px; + top: 15px; + font-size: 30px; + display: none ; + margin-left: 60px !important; +} + +.jconfirm .capslock input { + padding-right: 50px; + padding-left: 50px; +} diff --git a/kfet/static/kfet/js/kfet.js b/kfet/static/kfet/js/kfet.js index dbfba0b2..e3e5a6d9 100644 --- a/kfet/static/kfet/js/kfet.js +++ b/kfet/static/kfet/js/kfet.js @@ -88,7 +88,7 @@ function getErrorsHtml(data) { function requestAuth(data, callback, focus_next = null) { var content = getErrorsHtml(data); - content += '', + content += '
', $.confirm({ title: 'Authentification requise', content: content, @@ -102,14 +102,39 @@ function requestAuth(data, callback, focus_next = null) { }, onOpen: function() { var that = this; + var capslock = -1 ; // 1 -> caps on ; 0 -> caps off ; -1 or 2 -> unknown this.$content.find('input').on('keypress', function(e) { if (e.keyCode == 13) that.$confirmButton.click(); + + var s = String.fromCharCode(e.which); + if ((s.toUpperCase() === s && s.toLowerCase() !== s && !e.shiftKey)|| //caps on, shift off + (s.toUpperCase() !== s && s.toLowerCase() === s && e.shiftKey)) { //caps on, shift on + capslock = 1 ; + } else if ((s.toLowerCase() === s && s.toUpperCase() !== s && !e.shiftKey)|| //caps off, shift off + (s.toLowerCase() !== s && s.toUpperCase() === s && e.shiftKey)) { //caps off, shift on + capslock = 0 ; + } + if (capslock == 1) + $('.capslock .glyphicon').show() ; + else if (capslock == 0) + $('.capslock .glyphicon').hide() ; + }); + // Capslock key is not detected by keypress + this.$content.find('input').on('keydown', function(e) { + if (e.which == 20) { + capslock = 1-capslock ; + } + if (capslock == 1) + $('.capslock .glyphicon').show() ; + else if (capslock == 0) + $('.capslock .glyphicon').hide() ; }); }, onClose: function() { if (focus_next) this._lastFocused = focus_next; } + }); } From f741c70c723e92e59b1be7a018c706df878ffa0c Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Thu, 17 Nov 2016 22:44:43 -0200 Subject: [PATCH 2/2] revert settings_dev changes --- cof/settings_dev.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/cof/settings_dev.py b/cof/settings_dev.py index 0ba8d72b..17040c38 100644 --- a/cof/settings_dev.py +++ b/cof/settings_dev.py @@ -29,6 +29,9 @@ SECRET_KEY = 'q()(zn4m63i%5cp4)f+ww4-28_w+ly3q9=6imw2ciu&_(5_4ah' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True +ALLOWED_HOSTS = ['127.0.0.1'] + + # Application definition INSTALLED_APPS = ( 'gestioncof', @@ -98,7 +101,6 @@ DATABASES = { 'NAME': os.environ['DBNAME'], 'USER': os.environ['DBUSER'], 'PASSWORD': os.environ['DBPASSWD'], - 'HOST': os.environ.get('DBHOST', 'localhost'), } } @@ -124,7 +126,7 @@ STATIC_URL = '/static/' STATIC_ROOT = '/var/www/static/' STATICFILES_DIRS = ( - os.path.join(BASE_DIR, 'static/'), + os.path.join(BASE_DIR, 'static/'), ) # Media upload (through ImageField, SiteField) @@ -136,32 +138,31 @@ 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" -MAIL_DATA = { - 'petits_cours': { - 'FROM': "Le COF ", - 'BCC': "archivescof@gmail.com", - 'REPLYTO': "cof@ens.fr"}, - 'rappels': { - 'FROM': 'Le BdA ', - 'REPLYTO': 'Le BdA '}, - 'revente': { - 'FROM': 'BdA-Revente ', - 'REPLYTO': 'BdA-Revente '}, -} +PETITS_COURS_FROM = "Le COF " +PETITS_COURS_BCC = "archivescof@gmail.com" +PETITS_COURS_REPLYTO = "cof@ens.fr" -LOGIN_URL = "cof-login" -LOGIN_REDIRECT_URL = "home" +RAPPEL_FROM = 'Le BdA ' +RAPPEL_REPLY_TO = RAPPEL_FROM + +LOGIN_URL = "/gestion/login" +LOGIN_REDIRECT_URL = "/gestion/" CAS_SERVER_URL = 'https://cas.eleves.ens.fr/' CAS_IGNORE_REFERER = True -CAS_REDIRECT_URL = '/' +CAS_REDIRECT_URL = '/gestion/' CAS_EMAIL_FORMAT = "%s@clipper.ens.fr" AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', 'gestioncof.shared.COFCASBackend', + 'kfet.backends.GenericTeamBackend', ) # EMAIL_HOST="nef.ens.fr" @@ -176,7 +177,7 @@ CHANNEL_LAYERS = { "default": { "BACKEND": "asgi_redis.RedisChannelLayer", "CONFIG": { - "hosts": [(os.environ.get("REDIS_HOST", "localhost"), 6379)], + "hosts": [("localhost", 6379)], }, "ROUTING": "cof.routing.channel_routing", }