From 46e560cef9f61611af20a5a671d293c6533b54c7 Mon Sep 17 00:00:00 2001 From: Markus Hauschild Date: Sat, 16 Apr 2016 21:03:11 +0200 Subject: [PATCH] Rename function list to list_users. The function list shadowed the built-in type list leading to weird TypeError exceptions in the user creation. While at it list the users cn before the dn to improve readability. --- index.py | 6 +++--- templates/list.html | 12 +++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/index.py b/index.py index 9aee3ce..fbe0e05 100755 --- a/index.py +++ b/index.py @@ -91,7 +91,7 @@ def create(): user_dn = app.config.get('USER_DN').format(**d) attrs = {} for k,v in app.config.get('USER_ATTRS').iteritems(): - if type(v) == str: + if isinstance(v, str): attrs[k] = v.format(**d) elif isinstance(v, list): attrs[k] = [] @@ -142,13 +142,13 @@ def edit(): @app.route('/list') -def list(): +def list_users(): if not isLoggedin(): return render_template('error.html', message="You are not logged in. Please log in first.", nav=buildNav()) l = ldap.initialize(app.config.get('LDAP_URI', 'ldaps://127.0.0.1')) l.simple_bind_s(rdb.hget(session['uuid'], 'user'), rdb.hget(session['uuid'], 'pswd')) - sr = l.search_s(app.config.get('LDAP_BASE'), ldap.SCOPE_SUBTREE, '(objectClass=posixAccount)', ['']) + sr = l.search_s(app.config.get('LDAP_BASE'), ldap.SCOPE_SUBTREE, '(objectClass=posixAccount)', ['cn']) return render_template('list.html', users=sr, nav=buildNav()) diff --git a/templates/list.html b/templates/list.html index 52a1c49..1568386 100644 --- a/templates/list.html +++ b/templates/list.html @@ -5,11 +5,17 @@ - + + + + - {% for dn, _ in users %} - + {% for dn, attr in users %} + + + + {% endfor %}
DN
CNDN
{{ dn }}
{{ attr['cn'][0] }}{{ dn }}