diff options
Diffstat (limited to 'ogcp/views.py')
-rw-r--r-- | ogcp/views.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/ogcp/views.py b/ogcp/views.py index ab75280..e41e242 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -99,6 +99,9 @@ class ServerErrorCode(Exception): def normalize_mac(mac): return mac.replace(':', '').replace('-', '').replace('.', '').lower() +def prettify_mac(mac): + return (':'.join(mac[i:i+2] for i in range(0, 12, 2))).lower() + def ogserver_down(view): flash(_('Cannot talk to ogserver. Is ogserver down?'), category='error') return redirect(url_for(view)) @@ -494,7 +497,7 @@ def get_client_mac(): resp = server.get('/client/info', payload) client_info = resp.json() mac = client_info.get('mac') - pretty_mac = (':'.join(mac[i:i+2] for i in range(0, 12, 2))).upper() + pretty_mac = prettify_mac(mac) return jsonify(pretty_mac) @@ -1216,7 +1219,7 @@ def action_client_info(): form.name.render_kw = {'readonly': True} form.ip.data = db_client['ip'] form.ip.render_kw = {'readonly': True} - form.mac.data = db_client['mac'] + form.mac.data = prettify_mac(db_client['mac']) form.mac.render_kw = {'readonly': True} form.serial_number.data = db_client['serial_number'] form.serial_number.render_kw = {'readonly': True} @@ -1340,7 +1343,7 @@ def action_client_update(): form.ip.data = db_client['ip'] form.ip.render_kw = {'readonly': True} form.name.data = db_client['name'] - form.mac.data = db_client['mac'] + form.mac.data = prettify_mac(db_client['mac']) form.serial_number.data = db_client['serial_number'] form.livedir.render_kw = {'readonly': True} form.remote.data = db_client['remote'] @@ -1590,7 +1593,7 @@ def action_client_add(): available_modes.extend([(mode, mode) for mode in r.json()['modes'] if mode != 'pxe']) form.boot.choices = list(available_modes) - form.mac.render_kw = {'placeholder': 'aabbccddeeaa'} + form.mac.render_kw = {'placeholder': 'aa:bb:cc:dd:ee:aa'} r = server.get('/scopes') if not r: |