more default quota work

This commit is contained in:
John Supplee 2019-01-31 23:58:10 +02:00
parent d1906bd055
commit 70c607e256
2 changed files with 21 additions and 8 deletions

View File

@ -531,20 +531,22 @@ def privacy_status_set():
@app.route('/system/default-quota', methods=["GET"])
@authorized_personnel_only
def default_quota_get():
return get_default_quota(env)
return json_response({
"default-quota": get_default_quota(env)
})
@app.route('/system/default-quota', methods=["POST"])
@authorized_personnel_only
def default_quota_set():
config = utils.load_settings(env)
try:
config["default-quota"] = validate_quota(request.form.get('default_quota'))
utils.write_settings(config, env)
config = utils.load_settings(env)
try:
config["default-quota"] = validate_quota(request.form.get('default_quota'))
utils.write_settings(config, env)
except ValueError as e:
return ("ERROR: %s" % str(e), 400)
except ValueError as e:
return ("ERROR: %s" % str(e), 400)
return "OK"
return "OK"
# MUNIN

View File

@ -348,4 +348,15 @@ function generate_random_password() {
show_modal_error("Random Password", "<p>Here, try this:</p> <p><code style='font-size: 110%'>" + pw + "</code></pr");
return false; // cancel click
}
$(document).ready(function(){
api(
"/system/default-quota",
"GET",
{},
function(r) {
$('#adduserQuota').val(r['default-quota']);
}
);
});
</script>