Commit bb27521a authored by Vladislav Rykov's avatar Vladislav Rykov
Browse files

range id fixed

parent eeac5cff
File added
......@@ -6,3 +6,36 @@ def rand_str(length):
return hexlify(os.urandom(length//2))
else:
return hexlify(os.urandom(length//2 + 1))
def prep_id_range(devlist):
r = range(1,255)
for dev in devlist:
del r[r.index(dev[1])]
s = ''
inr = False
for i in range(len(r)-1):
if r[i+1] - r[i] > 1:
if inr:
s += str(r[i])+'], '
inr = False
else:
s += str(r[i])+', '
else:
if not inr:
s += '['+str(r[i])+'-'
inr = True
if r[-1] - r[-2] > 1:
if inr:
s += str(r[-1])+']'
else:
s += str(r[-1])
else:
if not inr:
s += str(r[-1])
else:
s += str(r[-1])+']'
return s
No preview for this file type
......@@ -10,10 +10,6 @@ APP_KEY_LEN = 8
server = Flask(__name__, template_folder='templates/')
def prep_ids(dev_list):
return "any"
@server.route('/')
def index():
if 'name' in session and len(session['name']) > 0:
......@@ -145,8 +141,6 @@ def delete_app():
@server.route('/add-dev')
def new_dev():
free_ids = 'whatever'
dh = dd.DeviceDao()
dev_list = dh.get_list(session['appkey'])
......@@ -155,7 +149,7 @@ def new_dev():
if not dev_list[0]:
return render_template('add-dev.html', feedback=dev_list[1])
else:
return render_template('add-dev.html', free_ids=prep_ids(dev_list[1]))
return render_template('add-dev.html', free_ids=misc.prep_id_range(dev_list[1]))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment