Fix potential api glitches and fix team creation error rendering

This commit is contained in:
Kevin Chung
2020-08-20 16:51:53 -04:00
parent 2022af2433
commit 647ca185bd
4 changed files with 10 additions and 6 deletions

View File

@@ -211,7 +211,9 @@ class TeamSchema(ma.ModelSchema):
else:
target_team = current_team
if self.view == "admin":
# We are editting an existing
if self.view == "admin" and self.instance:
target_team = self.instance
provided_ids = []
for f in fields:
f.pop("id", None)

View File

@@ -205,7 +205,9 @@ class UserSchema(ma.ModelSchema):
else:
target_user = current_user
if self.view == "admin":
# We are editting an existing user
if self.view == "admin" and self.instance:
target_user = self.instance
provided_ids = []
for f in fields:
f.pop("id", None)

View File

@@ -41,15 +41,15 @@ function createTeam(event) {
const team_id = response.data.id;
window.location = CTFd.config.urlRoot + "/admin/teams/" + team_id;
} else {
$("#team-info-form > #results").empty();
$("#team-info-create-form > #results").empty();
Object.keys(response.errors).forEach(function(key, _index) {
$("#team-info-form > #results").append(
$("#team-info-create-form > #results").append(
ezBadge({
type: "error",
body: response.errors[key]
})
);
const i = $("#team-info-form").find("input[name={0}]".format(key));
const i = $("#team-info-create-form").find("input[name={0}]".format(key));
const input = $(i);
input.addClass("input-filled-invalid");
input.removeClass("input-filled-valid");

File diff suppressed because one or more lines are too long