We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 75bc761 commit 30a36eaCopy full SHA for 30a36ea
app/views.py
@@ -324,7 +324,16 @@ def edit(id):
324
user.save()
325
return redirect(url_for('manage_users'))
326
else:
327
- form['quota'].data = str(user.get_quota()) + 'KiB' if user.get_quota() else None
+ quota = user.get_quota()
328
+ if quota:
329
+ units = ['KiB', 'MiB', 'GiB', 'TiB']
330
+ cnt = 0
331
+ while quota & ((1 << 9) - 1) == 0 and cnt < 3:
332
+ quota = quota >> 10
333
+ cnt = cnt + 1
334
+ form['quota'].data = f"{quota}{units[cnt]}"
335
+ else:
336
+ form['quota'].data = None
337
return render_template('edit.html', form=form, email=user.email)
338
339
0 commit comments