summaryrefslogtreecommitdiff
path: root/templates/admin/changeMID.html
blob: 5aff4640a548e0c21930cf00d8d04d3c83e54c98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{% extends "layout.html" %}
{% load staticfiles %}

{% block content %}
<div class="container">
    <div class="row">
        {% include "account/sub_nav.html" %}
        <div class="span12">
            {% include "admin/sub_nav.html" %}

            Username: <br>

            <input id="username" type="text" placeholder="Enter Username">

            <br><br>

            <select id="mid">
                {% for mid in mid_count %}
                <option id = "{{ mid.board_id }}">
                    {{ mid.board__mid }}-{{mid.mcount}}
                </option>
                {% endfor %}
            </select>
            <br>
            <button id="update-btn" class="btn btn-primary" onclick="updateMID()"> Update MID </button>
        </div>
    </div>

    <script type="text/javascript">
        
    function updateMID() {
            $("#update-btn").prop('disabled',true);
            var BASE_URL = window.location.origin;  
            var username = $("#username").val();
            var board_id = $("#mid").children(":selected").attr("id");

            if(username == "")
            {
                alert("Username field must not be empty");
                return;
            }

            var request = $.ajax({
                url:BASE_URL + "/admin/updatemid",
                method : "POST",
                data : {
                    "username" : username,
                    "board_id" : board_id
                }
            });

            request.done(function(data){
                if(data.status_code == 200) {
                    alert(data.message);
                    location.reload();
                }
                else {
                    alert(data.message);
                    $("#update-btn").prop('disabled',false);
                }                
            });


    }

    </script>
</div>
{% endblock %}