diff options
author | coderick14 | 2017-07-04 19:33:17 +0530 |
---|---|---|
committer | coderick14 | 2017-07-04 20:57:40 +0530 |
commit | 6f76f85bc264a58cea717ca8f8bd60b411828dd5 (patch) | |
tree | bcc42ffde20423357da2f56bb380c146db88443d | |
parent | f30025c86b414d6611f86487fb73a287d401536e (diff) | |
download | SBHS-2018-Rpi-6f76f85bc264a58cea717ca8f8bd60b411828dd5.tar.gz SBHS-2018-Rpi-6f76f85bc264a58cea717ca8f8bd60b411828dd5.tar.bz2 SBHS-2018-Rpi-6f76f85bc264a58cea717ca8f8bd60b411828dd5.zip |
Show present MID before updating
-rw-r--r-- | myadmin/views.py | 2 | ||||
-rw-r--r-- | templates/admin/changeMID.html | 15 |
2 files changed, 9 insertions, 8 deletions
diff --git a/myadmin/views.py b/myadmin/views.py index 32fa6d6..4c6ccce 100644 --- a/myadmin/views.py +++ b/myadmin/views.py @@ -143,7 +143,7 @@ def get_allocated_mids(req): def get_users(req): checkadmin(req) try: - users = list(Account.objects.values_list("username", flat=True)) + users = list(Account.objects.select_related().values_list("username", "board__mid")) return HttpResponse(json.dumps({"status_code":200, "message":users}), content_type="application/json") except Exception as e: return HttpResponse(json.dumps({"status_code":500, "message":str(e)}), content_type="application/json") diff --git a/templates/admin/changeMID.html b/templates/admin/changeMID.html index 1ccfea0..b788ff1 100644 --- a/templates/admin/changeMID.html +++ b/templates/admin/changeMID.html @@ -18,7 +18,7 @@ <select id="mid"> {% for mid in mid_count %} <option id = "{{ mid.2 }}"> - {{ mid.0 }}-{{mid.1}} + MID : {{ mid.0 }}   USER COUNT : {{mid.1}} </option> {% endfor %} </select> @@ -31,8 +31,8 @@ function updateMID() { $("#update-btn").prop('disabled',true); -var BASE_URL = window.location.origin + "/sbhs-rpi"; - var username = $("#username").val(); + var BASE_URL = window.location.origin + "/sbhs-rpi"; + var username = $("#username").val().split(" ")[0]; var board_id = $("#mid").children(":selected").attr("id"); if(username == "") @@ -54,6 +54,8 @@ var BASE_URL = window.location.origin + "/sbhs-rpi"; if(data.status_code == 200) { alert(data.message); $("#update-btn").prop('disabled',false); + sessionStorage.setItem("sbhsuser"+username, [username, board_id]); + $("#username").val(""); location.reload(); } else { @@ -84,8 +86,8 @@ var BASE_URL = window.location.origin + "/sbhs-rpi"; } function populateUsers(data) { - for (username of data) { - sessionStorage.setItem("sbhsuser"+username, username); + for (user of data) { + sessionStorage.setItem("sbhsuser"+user[0], [user[0], user[1]]); } } @@ -103,14 +105,13 @@ var BASE_URL = window.location.origin + "/sbhs-rpi"; } options = ""; for (matchedUser of matchedUsers) { - options += "<option>" + matchedUser + "</option>"; + options += "<option>" + matchedUser.split(",")[0] + " (" + matchedUser.split(",")[1] + ")" + "</option>"; } if (options.length != 0) { document.getElementById("users").innerHTML = options; } } } - appendUsers(); </script> </div> |