diff --git a/gestioncof/autocomplete.py b/gestioncof/autocomplete.py index 1eae6920..a9abbad7 100644 --- a/gestioncof/autocomplete.py +++ b/gestioncof/autocomplete.py @@ -56,22 +56,24 @@ def autocomplete(request): # Fetching data from the SPI if hasattr(settings, 'LDAP_SERVER_URL'): # Fetching - ldap_query = '(|{:s})'.format(''.join( - ['(cn=*{bit:s}*)(uid=*{bit:s}*)'.format(**{"bit": bit}) - for bit in bits] + ldap_query = '(&{:s})'.format(''.join( + '(|(cn=*{bit:s}*)(uid=*{bit:s}*))'.format(bit=bit) + for bit in bits if bit.isalnum() )) - with Connection(settings.LDAP_SERVER_URL) as conn: - conn.search( - 'dc=spi,dc=ens,dc=fr', ldap_query, - attributes=['uid', 'cn'] - ) - queries['clippers'] = conn.entries - # Clearing redundancies - queries['clippers'] = [ - Clipper(clipper.uid, clipper.cn) - for clipper in queries['clippers'] - if str(clipper.uid) not in usernames - ] + if ldap_query != "(&)": + # If none of the bits were legal, we do not perform the query + with Connection(settings.LDAP_SERVER_URL) as conn: + conn.search( + 'dc=spi,dc=ens,dc=fr', ldap_query, + attributes=['uid', 'cn'] + ) + queries['clippers'] = conn.entries + # Clearing redundancies + queries['clippers'] = [ + Clipper(clipper.uid, clipper.cn) + for clipper in queries['clippers'] + if str(clipper.uid) not in usernames + ] # Resulting data data.update(queries) diff --git a/gestioncof/static/css/cof.css b/gestioncof/static/css/cof.css index 269736d0..fda55d98 100644 --- a/gestioncof/static/css/cof.css +++ b/gestioncof/static/css/cof.css @@ -800,7 +800,7 @@ input#search_autocomplete { height: 40px; padding: 10px 8px; margin: 0 auto; - margin-top: 20px; + margin-top: 0px; display: block; color: #aaa; } @@ -1119,3 +1119,10 @@ div.messages div.alert-success div.container { div.messages div.alert div.container a { color: inherit; } + +/* Help text */ + +p.help-block { + margin: 5px auto; + width: 90%; +} diff --git a/gestioncof/templates/registration.html b/gestioncof/templates/registration.html index 769808de..8f05dfb0 100644 --- a/gestioncof/templates/registration.html +++ b/gestioncof/templates/registration.html @@ -9,7 +9,9 @@ {% block realcontent %}
Les mots contenant des caractères non alphanumériques seront ignorés
+