Temporarily disable button to prevent multiple submissions
This commit is contained in:
parent
dcc557fd89
commit
796fac7f85
4 changed files with 53 additions and 14 deletions
|
@ -34,7 +34,7 @@ def team_create():
|
|||
db.session.commit()
|
||||
Users.query.filter_by(uid=_user.uid).update({ "tid": team.tid })
|
||||
db.session.commit()
|
||||
|
||||
|
||||
return { "success": 1, "message": "Success!" }
|
||||
|
||||
@blueprint.route("/invite", methods=["POST"])
|
||||
|
@ -149,4 +149,4 @@ def get_team(tid=None, teamname=None, teamname_lower=None, owner=None):
|
|||
match.update({ "tid": _user.tid })
|
||||
with app.app_context():
|
||||
result = Teams.query.filter_by(**match)
|
||||
return result
|
||||
return result
|
||||
|
|
|
@ -214,30 +214,42 @@ $.fn.serializeObject = function() {
|
|||
var register_form = function() {
|
||||
var input = "#register_form input";
|
||||
var data = $("#register_form").serializeObject();
|
||||
var button = $("#register_form").find(":submit");
|
||||
button.prop("disabled", true);
|
||||
api_call("POST", "/api/user/register", data, function(result) {
|
||||
if (result["success"] == 1) {
|
||||
location.href = "/profile";
|
||||
} else {
|
||||
display_message("register_msg", "danger", result["message"]);
|
||||
display_message("register_msg", "danger", result["message"], function() {
|
||||
button.removeAttr("disabled");
|
||||
});
|
||||
}
|
||||
}).fail(function(jqXHR, status, error) {
|
||||
var result = JSON.parse(jqXHR["responseText"]);
|
||||
display_message("register_msg", "danger", "Error " + jqXHR["status"] + ": " + result["message"]);
|
||||
display_message("register_msg", "danger", "Error " + jqXHR["status"] + ": " + result["message"], function() {
|
||||
button.removeAttr("disabled");
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// password reset
|
||||
var request_reset_form = function() {
|
||||
var data = $("#request_reset_form").serializeObject();
|
||||
var button = $("#request_reset_form").find(":submit");
|
||||
button.prop("disabled", true);
|
||||
api_call("POST", "/api/user/forgot", data, function(result) {
|
||||
if (result["success"] == 1) {
|
||||
display_message("reset_msg", "success", result["message"]);
|
||||
} else {
|
||||
display_message("reset_msg", "danger", result["message"]);
|
||||
display_message("reset_msg", "danger", result["message"], function() {
|
||||
button.removeAttr("disabled");
|
||||
});
|
||||
}
|
||||
}).fail(function(jqXHR, status, error) {
|
||||
var result = JSON.parse(jqXHR["responseText"]);
|
||||
display_message("reset_msg", "danger", "Error " + jqXHR["status"] + ": " + result["message"]);
|
||||
display_message("reset_msg", "danger", "Error " + jqXHR["status"] + ": " + result["message"], function() {
|
||||
button.removeAttr("disabled");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -246,17 +258,23 @@ var reset_form = function() {
|
|||
data["csrf_token"] = $.cookie("csrf_token");
|
||||
var url = window.location.href;
|
||||
var token = url.substr(url.lastIndexOf("/")+1);
|
||||
var button = $("#reset_form").find(":submit");
|
||||
button.prop("disabled", true);
|
||||
api_call("POST", "/api/user/forgot/" + token, data, function(result) {
|
||||
if (result["success"] == 1) {
|
||||
display_message("reset_msg", "success", result["message"], function() {
|
||||
location.href = "/login";
|
||||
});
|
||||
} else {
|
||||
display_message("reset_msg", "danger", result["message"]);
|
||||
display_message("reset_msg", "danger", result["message"], function() {
|
||||
button.removeAttr("disabled");
|
||||
});
|
||||
}
|
||||
}).fail(function(jqXHR, status, error) {
|
||||
var result = JSON.parse(jqXHR["responseText"]);
|
||||
display_message("reset_msg", "danger", "Error " + jqXHR["status"] + ": " + result["message"]);
|
||||
display_message("reset_msg", "danger", "Error " + jqXHR["status"] + ": " + result["message"], function() {
|
||||
button.removeAttr("disabled");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -265,15 +283,21 @@ var reset_form = function() {
|
|||
var login_form = function() {
|
||||
var input = "#login_form input";
|
||||
var data = $("#login_form").serializeObject();
|
||||
var button = $("#login_form").find(":submit");
|
||||
button.prop("disabled", true);
|
||||
api_call("POST", "/api/user/login", data, function(result) {
|
||||
if (result["success"] == 1) {
|
||||
location.href = "/profile";
|
||||
} else {
|
||||
display_message("login_msg", "danger", result["message"]);
|
||||
display_message("login_msg", "danger", result["message"], function() {
|
||||
button.removeAttr("disabled");
|
||||
});
|
||||
}
|
||||
}).fail(function(jqXHR, status, error) {
|
||||
var result = JSON.parse(jqXHR["responseText"]);
|
||||
display_message("login_msg", "danger", "Error " + jqXHR["status"] + ": " + result["message"]);
|
||||
display_message("login_msg", "danger", "Error " + jqXHR["status"] + ": " + result["message"], function() {
|
||||
button.removeAttr("disabled");
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -282,24 +306,39 @@ var login_form = function() {
|
|||
var create_team = function() {
|
||||
var input = "#create_team input";
|
||||
var data = $("#create_team").serializeObject();
|
||||
var button = $("#create_team").find(":submit");
|
||||
button.prop("disabled", true);
|
||||
api_call("POST", "/api/team/create", data, function(result) {
|
||||
if (result["success"] == 1) {
|
||||
location.reload(true);
|
||||
} else {
|
||||
display_message("create_team_msg", "danger", result["message"]);
|
||||
display_message("create_team_msg", "danger", result["message"], function() {
|
||||
button.removeAttr("disabled");
|
||||
});
|
||||
}
|
||||
}).fail(function(jqXHR, status, error) {
|
||||
var result = JSON.parse(jqXHR["responseText"]);
|
||||
display_message("create_team_msg", "danger", "Error " + jqXHR["status"] + ": " + result["message"]);
|
||||
display_message("create_team_msg", "danger", "Error " + jqXHR["status"] + ": " + result["message"], function() {
|
||||
button.removeAttr("disabled");
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var add_member = function() {
|
||||
var input = "#add_member input";
|
||||
var data = $("#add_member").serializeObject();
|
||||
var button = $("#add_member").find(":submit");
|
||||
button.prop("disabled", true);
|
||||
api_call("POST", "/api/team/invite", data, function(result) {
|
||||
if (result["success"] == 1) {
|
||||
location.reload(true);
|
||||
} else {
|
||||
button.removeAtr("disabled");
|
||||
}
|
||||
}).fail(function(jqXHR, status, error) {
|
||||
var result = JSON.parse(jqXHR["responseText"]);
|
||||
display_message("create_team_msg", "danger", "Error " + jqXHR["status"] + ": " + result["message"], function() {
|
||||
button.removeAttr("disabled");
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -51,4 +51,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -157,4 +157,4 @@
|
|||
}
|
||||
});
|
||||
$("[data-toggle=tooltip]").tooltip();
|
||||
</script>
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue