summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--myadmin/views.py2
-rw-r--r--templates/admin/changeMID.html15
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 }} &emsp;&emsp;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>