diff --git a/CTFd/api/v1/awards.py b/CTFd/api/v1/awards.py index 6591c24..a77b36f 100644 --- a/CTFd/api/v1/awards.py +++ b/CTFd/api/v1/awards.py @@ -2,7 +2,8 @@ from flask import request from flask_restplus import Namespace, Resource from CTFd.cache import clear_standings -from CTFd.models import Awards, db +from CTFd.utils.config import is_teams_mode +from CTFd.models import Awards, db, Users from CTFd.schemas.awards import AwardSchema from CTFd.utils.decorators import admins_only @@ -14,6 +15,26 @@ class AwardList(Resource): @admins_only def post(self): req = request.get_json() + + # Force a team_id if in team mode and unspecified + if is_teams_mode(): + team_id = req.get("team_id") + if team_id is None: + user = Users.query.filter_by(id=req["user_id"]).first() + if user.team_id is None: + return ( + { + "success": False, + "errors": { + "team_id": [ + "User doesn't have a team to associate award with" + ] + }, + }, + 400, + ) + req["team_id"] = user.team_id + schema = AwardSchema() response = schema.load(req, session=db.session) diff --git a/CTFd/themes/admin/assets/js/pages/team.js b/CTFd/themes/admin/assets/js/pages/team.js index b0851fb..b89c649 100644 --- a/CTFd/themes/admin/assets/js/pages/team.js +++ b/CTFd/themes/admin/assets/js/pages/team.js @@ -225,6 +225,7 @@ $(() => { e.preventDefault(); const params = $("#user-award-form").serializeJSON(true); params["user_id"] = $("#award-member-input").val(); + params["team_id"] = TEAM_ID; $("#user-award-form > #results").empty(); diff --git a/CTFd/themes/admin/static/js/pages/team.dev.js b/CTFd/themes/admin/static/js/pages/team.dev.js index ff088a0..25ab2c4 100644 --- a/CTFd/themes/admin/static/js/pages/team.dev.js +++ b/CTFd/themes/admin/static/js/pages/team.dev.js @@ -162,7 +162,7 @@ /***/ (function(module, exports, __webpack_require__) { ; -eval("\n\n__webpack_require__(/*! ./main */ \"./CTFd/themes/admin/assets/js/pages/main.js\");\n\nvar _jquery = _interopRequireDefault(__webpack_require__(/*! jquery */ \"./node_modules/jquery/dist/jquery.js\"));\n\nvar _CTFd = _interopRequireDefault(__webpack_require__(/*! core/CTFd */ \"./CTFd/themes/core/assets/js/CTFd.js\"));\n\nvar _utils = __webpack_require__(/*! core/utils */ \"./CTFd/themes/core/assets/js/utils.js\");\n\nvar _ezq = __webpack_require__(/*! core/ezq */ \"./CTFd/themes/core/assets/js/ezq.js\");\n\nvar _graphs = __webpack_require__(/*! core/graphs */ \"./CTFd/themes/core/assets/js/graphs.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction createTeam(event) {\n event.preventDefault();\n var params = (0, _jquery.default)(\"#team-info-create-form\").serializeJSON(true);\n\n _CTFd.default.fetch(\"/api/v1/teams\", {\n method: \"POST\",\n credentials: \"same-origin\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify(params)\n }).then(function (response) {\n return response.json();\n }).then(function (response) {\n if (response.success) {\n var team_id = response.data.id;\n window.location = _CTFd.default.config.urlRoot + \"/admin/teams/\" + team_id;\n } else {\n (0, _jquery.default)(\"#team-info-form > #results\").empty();\n Object.keys(response.errors).forEach(function (key, index) {\n (0, _jquery.default)(\"#team-info-form > #results\").append((0, _ezq.ezBadge)({\n type: \"error\",\n body: response.errors[key]\n }));\n var i = (0, _jquery.default)(\"#team-info-form\").find(\"input[name={0}]\".format(key));\n var input = (0, _jquery.default)(i);\n input.addClass(\"input-filled-invalid\");\n input.removeClass(\"input-filled-valid\");\n });\n }\n });\n}\n\nfunction updateTeam(event) {\n event.preventDefault();\n var params = (0, _jquery.default)(\"#team-info-edit-form\").serializeJSON(true);\n\n _CTFd.default.fetch(\"/api/v1/teams/\" + TEAM_ID, {\n method: \"PATCH\",\n credentials: \"same-origin\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify(params)\n }).then(function (response) {\n return response.json();\n }).then(function (response) {\n if (response.success) {\n window.location.reload();\n } else {\n (0, _jquery.default)(\"#team-info-form > #results\").empty();\n Object.keys(response.errors).forEach(function (key, index) {\n (0, _jquery.default)(\"#team-info-form > #results\").append((0, _ezq.ezBadge)({\n type: \"error\",\n body: response.errors[key]\n }));\n var i = (0, _jquery.default)(\"#team-info-form\").find(\"input[name={0}]\".format(key));\n var input = (0, _jquery.default)(i);\n input.addClass(\"input-filled-invalid\");\n input.removeClass(\"input-filled-valid\");\n });\n }\n });\n}\n\nvar api_funcs = {\n team: [function (x) {\n return _CTFd.default.api.get_team_solves({\n teamId: x\n });\n }, function (x) {\n return _CTFd.default.api.get_team_fails({\n teamId: x\n });\n }, function (x) {\n return _CTFd.default.api.get_team_awards({\n teamId: x\n });\n }],\n user: [function (x) {\n return _CTFd.default.api.get_user_solves({\n userId: x\n });\n }, function (x) {\n return _CTFd.default.api.get_user_fails({\n userId: x\n });\n }, function (x) {\n return _CTFd.default.api.get_user_awards({\n userId: x\n });\n }]\n};\n\nvar createGraphs = function createGraphs(type, id, name, account_id) {\n var _api_funcs$type = _slicedToArray(api_funcs[type], 3),\n solves_func = _api_funcs$type[0],\n fails_func = _api_funcs$type[1],\n awards_func = _api_funcs$type[2];\n\n Promise.all([solves_func(account_id), fails_func(account_id), awards_func(account_id)]).then(function (responses) {\n (0, _graphs.createGraph)(\"score_graph\", \"#score-graph\", responses, type, id, name, account_id);\n (0, _graphs.createGraph)(\"category_breakdown\", \"#categories-pie-graph\", responses, type, id, name, account_id);\n (0, _graphs.createGraph)(\"solve_percentages\", \"#keys-pie-graph\", responses, type, id, name, account_id);\n });\n};\n\nvar updateGraphs = function updateGraphs(type, id, name, account_id) {\n var _api_funcs$type2 = _slicedToArray(api_funcs[type], 3),\n solves_func = _api_funcs$type2[0],\n fails_func = _api_funcs$type2[1],\n awards_func = _api_funcs$type2[2];\n\n Promise.all([solves_func(account_id), fails_func(account_id), awards_func(account_id)]).then(function (responses) {\n (0, _graphs.updateGraph)(\"score_graph\", \"#score-graph\", responses, type, id, name, account_id);\n (0, _graphs.updateGraph)(\"category_breakdown\", \"#categories-pie-graph\", responses, type, id, name, account_id);\n (0, _graphs.updateGraph)(\"solve_percentages\", \"#keys-pie-graph\", responses, type, id, name, account_id);\n });\n};\n\n(0, _jquery.default)(function () {\n (0, _jquery.default)(\"#team-captain-form\").submit(function (e) {\n e.preventDefault();\n var params = (0, _jquery.default)(\"#team-captain-form\").serializeJSON(true);\n\n _CTFd.default.fetch(\"/api/v1/teams/\" + TEAM_ID, {\n method: \"PATCH\",\n credentials: \"same-origin\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify(params)\n }).then(function (response) {\n return response.json();\n }).then(function (response) {\n if (response.success) {\n window.location.reload();\n } else {\n (0, _jquery.default)(\"#team-captain-form > #results\").empty();\n Object.keys(response.errors).forEach(function (key, index) {\n (0, _jquery.default)(\"#team-captain-form > #results\").append((0, _ezq.ezBadge)({\n type: \"error\",\n body: response.errors[key]\n }));\n var i = (0, _jquery.default)(\"#team-captain-form\").find(\"select[name={0}]\".format(key));\n var input = (0, _jquery.default)(i);\n input.addClass(\"input-filled-invalid\");\n input.removeClass(\"input-filled-valid\");\n });\n }\n });\n });\n (0, _jquery.default)(\".edit-team\").click(function (e) {\n (0, _jquery.default)(\"#team-info-edit-modal\").modal(\"toggle\");\n });\n (0, _jquery.default)(\".edit-captain\").click(function (e) {\n (0, _jquery.default)(\"#team-captain-modal\").modal(\"toggle\");\n });\n (0, _jquery.default)(\".award-team\").click(function (e) {\n (0, _jquery.default)(\"#team-award-modal\").modal(\"toggle\");\n });\n (0, _jquery.default)(\"#user-award-form\").submit(function (e) {\n e.preventDefault();\n var params = (0, _jquery.default)(\"#user-award-form\").serializeJSON(true);\n params[\"user_id\"] = (0, _jquery.default)(\"#award-member-input\").val();\n (0, _jquery.default)(\"#user-award-form > #results\").empty();\n\n if (!params[\"user_id\"]) {\n (0, _jquery.default)(\"#user-award-form > #results\").append((0, _ezq.ezBadge)({\n type: \"error\",\n body: \"Please select a team member\"\n }));\n return;\n }\n\n params[\"user_id\"] = parseInt(params[\"user_id\"]);\n\n _CTFd.default.fetch(\"/api/v1/awards\", {\n method: \"POST\",\n credentials: \"same-origin\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify(params)\n }).then(function (response) {\n return response.json();\n }).then(function (response) {\n if (response.success) {\n window.location.reload();\n } else {\n (0, _jquery.default)(\"#user-award-form > #results\").empty();\n Object.keys(response.errors).forEach(function (key, index) {\n (0, _jquery.default)(\"#user-award-form > #results\").append((0, _ezq.ezBadge)({\n type: \"error\",\n body: response.errors[key]\n }));\n var i = (0, _jquery.default)(\"#user-award-form\").find(\"input[name={0}]\".format(key));\n var input = (0, _jquery.default)(i);\n input.addClass(\"input-filled-invalid\");\n input.removeClass(\"input-filled-valid\");\n });\n }\n });\n });\n (0, _jquery.default)(\".delete-member\").click(function (e) {\n e.preventDefault();\n var member_id = (0, _jquery.default)(this).attr(\"member-id\");\n var member_name = (0, _jquery.default)(this).attr(\"member-name\");\n var params = {\n user_id: member_id\n };\n var row = (0, _jquery.default)(this).parent().parent();\n (0, _ezq.ezQuery)({\n title: \"Remove Member\",\n body: \"Are you sure you want to remove {0} from {1}?

All of their challenges solves, attempts, awards, and unlocked hints will also be deleted!\".format(\"\" + (0, _utils.htmlEntities)(member_name) + \"\", \"\" + (0, _utils.htmlEntities)(TEAM_NAME) + \"\"),\n success: function success() {\n _CTFd.default.fetch(\"/api/v1/teams/\" + TEAM_ID + \"/members\", {\n method: \"DELETE\",\n body: JSON.stringify(params)\n }).then(function (response) {\n return response.json();\n }).then(function (response) {\n if (response.success) {\n row.remove();\n }\n });\n }\n });\n });\n (0, _jquery.default)(\".delete-team\").click(function (e) {\n (0, _ezq.ezQuery)({\n title: \"Delete Team\",\n body: \"Are you sure you want to delete {0}\".format(\"\" + (0, _utils.htmlEntities)(TEAM_NAME) + \"\"),\n success: function success() {\n _CTFd.default.fetch(\"/api/v1/teams/\" + TEAM_ID, {\n method: \"DELETE\"\n }).then(function (response) {\n return response.json();\n }).then(function (response) {\n if (response.success) {\n window.location = _CTFd.default.config.urlRoot + \"/admin/teams\";\n }\n });\n }\n });\n });\n (0, _jquery.default)(\".delete-submission\").click(function (e) {\n e.preventDefault();\n var submission_id = (0, _jquery.default)(this).attr(\"submission-id\");\n var submission_type = (0, _jquery.default)(this).attr(\"submission-type\");\n var submission_challenge = (0, _jquery.default)(this).attr(\"submission-challenge\");\n var body = \"Are you sure you want to delete {0} submission from {1} for {2}?\".format((0, _utils.htmlEntities)(submission_type), (0, _utils.htmlEntities)(TEAM_NAME), (0, _utils.htmlEntities)(submission_challenge));\n var row = (0, _jquery.default)(this).parent().parent();\n (0, _ezq.ezQuery)({\n title: \"Delete Submission\",\n body: body,\n success: function success() {\n _CTFd.default.fetch(\"/api/v1/submissions/\" + submission_id, {\n method: \"DELETE\",\n credentials: \"same-origin\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\"\n }\n }).then(function (response) {\n return response.json();\n }).then(function (response) {\n if (response.success) {\n row.remove();\n }\n });\n }\n });\n });\n (0, _jquery.default)(\".delete-award\").click(function (e) {\n e.preventDefault();\n var award_id = (0, _jquery.default)(this).attr(\"award-id\");\n var award_name = (0, _jquery.default)(this).attr(\"award-name\");\n var body = \"Are you sure you want to delete the {0} award from {1}?\".format((0, _utils.htmlEntities)(award_name), (0, _utils.htmlEntities)(TEAM_NAME));\n var row = (0, _jquery.default)(this).parent().parent();\n (0, _ezq.ezQuery)({\n title: \"Delete Award\",\n body: body,\n success: function success() {\n _CTFd.default.fetch(\"/api/v1/awards/\" + award_id, {\n method: \"DELETE\",\n credentials: \"same-origin\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\"\n }\n }).then(function (response) {\n return response.json();\n }).then(function (response) {\n if (response.success) {\n row.remove();\n }\n });\n }\n });\n });\n (0, _jquery.default)(\"#team-info-create-form\").submit(createTeam);\n (0, _jquery.default)(\"#team-info-edit-form\").submit(updateTeam);\n var type, id, name, account_id;\n var _window$stats_data = window.stats_data;\n type = _window$stats_data.type;\n id = _window$stats_data.id;\n name = _window$stats_data.name;\n account_id = _window$stats_data.account_id;\n createGraphs(type, id, name, account_id);\n setInterval(function () {\n updateGraphs(type, id, name, account_id);\n }, 300000);\n});\n\n//# sourceURL=webpack:///./CTFd/themes/admin/assets/js/pages/team.js?"); +eval("\n\n__webpack_require__(/*! ./main */ \"./CTFd/themes/admin/assets/js/pages/main.js\");\n\nvar _jquery = _interopRequireDefault(__webpack_require__(/*! jquery */ \"./node_modules/jquery/dist/jquery.js\"));\n\nvar _CTFd = _interopRequireDefault(__webpack_require__(/*! core/CTFd */ \"./CTFd/themes/core/assets/js/CTFd.js\"));\n\nvar _utils = __webpack_require__(/*! core/utils */ \"./CTFd/themes/core/assets/js/utils.js\");\n\nvar _ezq = __webpack_require__(/*! core/ezq */ \"./CTFd/themes/core/assets/js/ezq.js\");\n\nvar _graphs = __webpack_require__(/*! core/graphs */ \"./CTFd/themes/core/assets/js/graphs.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction createTeam(event) {\n event.preventDefault();\n var params = (0, _jquery.default)(\"#team-info-create-form\").serializeJSON(true);\n\n _CTFd.default.fetch(\"/api/v1/teams\", {\n method: \"POST\",\n credentials: \"same-origin\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify(params)\n }).then(function (response) {\n return response.json();\n }).then(function (response) {\n if (response.success) {\n var team_id = response.data.id;\n window.location = _CTFd.default.config.urlRoot + \"/admin/teams/\" + team_id;\n } else {\n (0, _jquery.default)(\"#team-info-form > #results\").empty();\n Object.keys(response.errors).forEach(function (key, index) {\n (0, _jquery.default)(\"#team-info-form > #results\").append((0, _ezq.ezBadge)({\n type: \"error\",\n body: response.errors[key]\n }));\n var i = (0, _jquery.default)(\"#team-info-form\").find(\"input[name={0}]\".format(key));\n var input = (0, _jquery.default)(i);\n input.addClass(\"input-filled-invalid\");\n input.removeClass(\"input-filled-valid\");\n });\n }\n });\n}\n\nfunction updateTeam(event) {\n event.preventDefault();\n var params = (0, _jquery.default)(\"#team-info-edit-form\").serializeJSON(true);\n\n _CTFd.default.fetch(\"/api/v1/teams/\" + TEAM_ID, {\n method: \"PATCH\",\n credentials: \"same-origin\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify(params)\n }).then(function (response) {\n return response.json();\n }).then(function (response) {\n if (response.success) {\n window.location.reload();\n } else {\n (0, _jquery.default)(\"#team-info-form > #results\").empty();\n Object.keys(response.errors).forEach(function (key, index) {\n (0, _jquery.default)(\"#team-info-form > #results\").append((0, _ezq.ezBadge)({\n type: \"error\",\n body: response.errors[key]\n }));\n var i = (0, _jquery.default)(\"#team-info-form\").find(\"input[name={0}]\".format(key));\n var input = (0, _jquery.default)(i);\n input.addClass(\"input-filled-invalid\");\n input.removeClass(\"input-filled-valid\");\n });\n }\n });\n}\n\nvar api_funcs = {\n team: [function (x) {\n return _CTFd.default.api.get_team_solves({\n teamId: x\n });\n }, function (x) {\n return _CTFd.default.api.get_team_fails({\n teamId: x\n });\n }, function (x) {\n return _CTFd.default.api.get_team_awards({\n teamId: x\n });\n }],\n user: [function (x) {\n return _CTFd.default.api.get_user_solves({\n userId: x\n });\n }, function (x) {\n return _CTFd.default.api.get_user_fails({\n userId: x\n });\n }, function (x) {\n return _CTFd.default.api.get_user_awards({\n userId: x\n });\n }]\n};\n\nvar createGraphs = function createGraphs(type, id, name, account_id) {\n var _api_funcs$type = _slicedToArray(api_funcs[type], 3),\n solves_func = _api_funcs$type[0],\n fails_func = _api_funcs$type[1],\n awards_func = _api_funcs$type[2];\n\n Promise.all([solves_func(account_id), fails_func(account_id), awards_func(account_id)]).then(function (responses) {\n (0, _graphs.createGraph)(\"score_graph\", \"#score-graph\", responses, type, id, name, account_id);\n (0, _graphs.createGraph)(\"category_breakdown\", \"#categories-pie-graph\", responses, type, id, name, account_id);\n (0, _graphs.createGraph)(\"solve_percentages\", \"#keys-pie-graph\", responses, type, id, name, account_id);\n });\n};\n\nvar updateGraphs = function updateGraphs(type, id, name, account_id) {\n var _api_funcs$type2 = _slicedToArray(api_funcs[type], 3),\n solves_func = _api_funcs$type2[0],\n fails_func = _api_funcs$type2[1],\n awards_func = _api_funcs$type2[2];\n\n Promise.all([solves_func(account_id), fails_func(account_id), awards_func(account_id)]).then(function (responses) {\n (0, _graphs.updateGraph)(\"score_graph\", \"#score-graph\", responses, type, id, name, account_id);\n (0, _graphs.updateGraph)(\"category_breakdown\", \"#categories-pie-graph\", responses, type, id, name, account_id);\n (0, _graphs.updateGraph)(\"solve_percentages\", \"#keys-pie-graph\", responses, type, id, name, account_id);\n });\n};\n\n(0, _jquery.default)(function () {\n (0, _jquery.default)(\"#team-captain-form\").submit(function (e) {\n e.preventDefault();\n var params = (0, _jquery.default)(\"#team-captain-form\").serializeJSON(true);\n\n _CTFd.default.fetch(\"/api/v1/teams/\" + TEAM_ID, {\n method: \"PATCH\",\n credentials: \"same-origin\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify(params)\n }).then(function (response) {\n return response.json();\n }).then(function (response) {\n if (response.success) {\n window.location.reload();\n } else {\n (0, _jquery.default)(\"#team-captain-form > #results\").empty();\n Object.keys(response.errors).forEach(function (key, index) {\n (0, _jquery.default)(\"#team-captain-form > #results\").append((0, _ezq.ezBadge)({\n type: \"error\",\n body: response.errors[key]\n }));\n var i = (0, _jquery.default)(\"#team-captain-form\").find(\"select[name={0}]\".format(key));\n var input = (0, _jquery.default)(i);\n input.addClass(\"input-filled-invalid\");\n input.removeClass(\"input-filled-valid\");\n });\n }\n });\n });\n (0, _jquery.default)(\".edit-team\").click(function (e) {\n (0, _jquery.default)(\"#team-info-edit-modal\").modal(\"toggle\");\n });\n (0, _jquery.default)(\".edit-captain\").click(function (e) {\n (0, _jquery.default)(\"#team-captain-modal\").modal(\"toggle\");\n });\n (0, _jquery.default)(\".award-team\").click(function (e) {\n (0, _jquery.default)(\"#team-award-modal\").modal(\"toggle\");\n });\n (0, _jquery.default)(\"#user-award-form\").submit(function (e) {\n e.preventDefault();\n var params = (0, _jquery.default)(\"#user-award-form\").serializeJSON(true);\n params[\"user_id\"] = (0, _jquery.default)(\"#award-member-input\").val();\n params[\"team_id\"] = TEAM_ID;\n (0, _jquery.default)(\"#user-award-form > #results\").empty();\n\n if (!params[\"user_id\"]) {\n (0, _jquery.default)(\"#user-award-form > #results\").append((0, _ezq.ezBadge)({\n type: \"error\",\n body: \"Please select a team member\"\n }));\n return;\n }\n\n params[\"user_id\"] = parseInt(params[\"user_id\"]);\n\n _CTFd.default.fetch(\"/api/v1/awards\", {\n method: \"POST\",\n credentials: \"same-origin\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify(params)\n }).then(function (response) {\n return response.json();\n }).then(function (response) {\n if (response.success) {\n window.location.reload();\n } else {\n (0, _jquery.default)(\"#user-award-form > #results\").empty();\n Object.keys(response.errors).forEach(function (key, index) {\n (0, _jquery.default)(\"#user-award-form > #results\").append((0, _ezq.ezBadge)({\n type: \"error\",\n body: response.errors[key]\n }));\n var i = (0, _jquery.default)(\"#user-award-form\").find(\"input[name={0}]\".format(key));\n var input = (0, _jquery.default)(i);\n input.addClass(\"input-filled-invalid\");\n input.removeClass(\"input-filled-valid\");\n });\n }\n });\n });\n (0, _jquery.default)(\".delete-member\").click(function (e) {\n e.preventDefault();\n var member_id = (0, _jquery.default)(this).attr(\"member-id\");\n var member_name = (0, _jquery.default)(this).attr(\"member-name\");\n var params = {\n user_id: member_id\n };\n var row = (0, _jquery.default)(this).parent().parent();\n (0, _ezq.ezQuery)({\n title: \"Remove Member\",\n body: \"Are you sure you want to remove {0} from {1}?

All of their challenges solves, attempts, awards, and unlocked hints will also be deleted!\".format(\"\" + (0, _utils.htmlEntities)(member_name) + \"\", \"\" + (0, _utils.htmlEntities)(TEAM_NAME) + \"\"),\n success: function success() {\n _CTFd.default.fetch(\"/api/v1/teams/\" + TEAM_ID + \"/members\", {\n method: \"DELETE\",\n body: JSON.stringify(params)\n }).then(function (response) {\n return response.json();\n }).then(function (response) {\n if (response.success) {\n row.remove();\n }\n });\n }\n });\n });\n (0, _jquery.default)(\".delete-team\").click(function (e) {\n (0, _ezq.ezQuery)({\n title: \"Delete Team\",\n body: \"Are you sure you want to delete {0}\".format(\"\" + (0, _utils.htmlEntities)(TEAM_NAME) + \"\"),\n success: function success() {\n _CTFd.default.fetch(\"/api/v1/teams/\" + TEAM_ID, {\n method: \"DELETE\"\n }).then(function (response) {\n return response.json();\n }).then(function (response) {\n if (response.success) {\n window.location = _CTFd.default.config.urlRoot + \"/admin/teams\";\n }\n });\n }\n });\n });\n (0, _jquery.default)(\".delete-submission\").click(function (e) {\n e.preventDefault();\n var submission_id = (0, _jquery.default)(this).attr(\"submission-id\");\n var submission_type = (0, _jquery.default)(this).attr(\"submission-type\");\n var submission_challenge = (0, _jquery.default)(this).attr(\"submission-challenge\");\n var body = \"Are you sure you want to delete {0} submission from {1} for {2}?\".format((0, _utils.htmlEntities)(submission_type), (0, _utils.htmlEntities)(TEAM_NAME), (0, _utils.htmlEntities)(submission_challenge));\n var row = (0, _jquery.default)(this).parent().parent();\n (0, _ezq.ezQuery)({\n title: \"Delete Submission\",\n body: body,\n success: function success() {\n _CTFd.default.fetch(\"/api/v1/submissions/\" + submission_id, {\n method: \"DELETE\",\n credentials: \"same-origin\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\"\n }\n }).then(function (response) {\n return response.json();\n }).then(function (response) {\n if (response.success) {\n row.remove();\n }\n });\n }\n });\n });\n (0, _jquery.default)(\".delete-award\").click(function (e) {\n e.preventDefault();\n var award_id = (0, _jquery.default)(this).attr(\"award-id\");\n var award_name = (0, _jquery.default)(this).attr(\"award-name\");\n var body = \"Are you sure you want to delete the {0} award from {1}?\".format((0, _utils.htmlEntities)(award_name), (0, _utils.htmlEntities)(TEAM_NAME));\n var row = (0, _jquery.default)(this).parent().parent();\n (0, _ezq.ezQuery)({\n title: \"Delete Award\",\n body: body,\n success: function success() {\n _CTFd.default.fetch(\"/api/v1/awards/\" + award_id, {\n method: \"DELETE\",\n credentials: \"same-origin\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\"\n }\n }).then(function (response) {\n return response.json();\n }).then(function (response) {\n if (response.success) {\n row.remove();\n }\n });\n }\n });\n });\n (0, _jquery.default)(\"#team-info-create-form\").submit(createTeam);\n (0, _jquery.default)(\"#team-info-edit-form\").submit(updateTeam);\n var type, id, name, account_id;\n var _window$stats_data = window.stats_data;\n type = _window$stats_data.type;\n id = _window$stats_data.id;\n name = _window$stats_data.name;\n account_id = _window$stats_data.account_id;\n createGraphs(type, id, name, account_id);\n setInterval(function () {\n updateGraphs(type, id, name, account_id);\n }, 300000);\n});\n\n//# sourceURL=webpack:///./CTFd/themes/admin/assets/js/pages/team.js?"); /***/ }) diff --git a/CTFd/themes/admin/static/js/pages/team.min.js b/CTFd/themes/admin/static/js/pages/team.min.js index 69169e2..2fc528b 100644 --- a/CTFd/themes/admin/static/js/pages/team.min.js +++ b/CTFd/themes/admin/static/js/pages/team.min.js @@ -1 +1 @@ -!function(l){function e(e){for(var t,o,n=e[0],s=e[1],a=e[2],i=0,r=[];i #results").empty(),Object.keys(s.errors).forEach(function(e,t){(0,i.default)("#team-info-form > #results").append((0,d.ezBadge)({type:"error",body:s.errors[e]}));var o=(0,i.default)("#team-info-form").find("input[name={0}]".format(e)),n=(0,i.default)(o);n.addClass("input-filled-invalid"),n.removeClass("input-filled-valid")})})}function m(e){e.preventDefault();var t=(0,i.default)("#team-info-edit-form").serializeJSON(!0);r.default.fetch("/api/v1/teams/"+TEAM_ID,{method:"PATCH",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)}).then(function(e){return e.json()}).then(function(s){s.success?window.location.reload():((0,i.default)("#team-info-form > #results").empty(),Object.keys(s.errors).forEach(function(e,t){(0,i.default)("#team-info-form > #results").append((0,d.ezBadge)({type:"error",body:s.errors[e]}));var o=(0,i.default)("#team-info-form").find("input[name={0}]".format(e)),n=(0,i.default)(o);n.addClass("input-filled-invalid"),n.removeClass("input-filled-valid")}))})}var p={team:[function(e){return r.default.api.get_team_solves({teamId:e})},function(e){return r.default.api.get_team_fails({teamId:e})},function(e){return r.default.api.get_team_awards({teamId:e})}],user:[function(e){return r.default.api.get_user_solves({userId:e})},function(e){return r.default.api.get_user_fails({userId:e})},function(e){return r.default.api.get_user_awards({userId:e})}]};(0,i.default)(function(){var e,t,o,n;(0,i.default)("#team-captain-form").submit(function(e){e.preventDefault();var t=(0,i.default)("#team-captain-form").serializeJSON(!0);r.default.fetch("/api/v1/teams/"+TEAM_ID,{method:"PATCH",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)}).then(function(e){return e.json()}).then(function(s){s.success?window.location.reload():((0,i.default)("#team-captain-form > #results").empty(),Object.keys(s.errors).forEach(function(e,t){(0,i.default)("#team-captain-form > #results").append((0,d.ezBadge)({type:"error",body:s.errors[e]}));var o=(0,i.default)("#team-captain-form").find("select[name={0}]".format(e)),n=(0,i.default)(o);n.addClass("input-filled-invalid"),n.removeClass("input-filled-valid")}))})}),(0,i.default)(".edit-team").click(function(e){(0,i.default)("#team-info-edit-modal").modal("toggle")}),(0,i.default)(".edit-captain").click(function(e){(0,i.default)("#team-captain-modal").modal("toggle")}),(0,i.default)(".award-team").click(function(e){(0,i.default)("#team-award-modal").modal("toggle")}),(0,i.default)("#user-award-form").submit(function(e){e.preventDefault();var t=(0,i.default)("#user-award-form").serializeJSON(!0);t.user_id=(0,i.default)("#award-member-input").val(),(0,i.default)("#user-award-form > #results").empty(),t.user_id?(t.user_id=parseInt(t.user_id),r.default.fetch("/api/v1/awards",{method:"POST",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)}).then(function(e){return e.json()}).then(function(s){s.success?window.location.reload():((0,i.default)("#user-award-form > #results").empty(),Object.keys(s.errors).forEach(function(e,t){(0,i.default)("#user-award-form > #results").append((0,d.ezBadge)({type:"error",body:s.errors[e]}));var o=(0,i.default)("#user-award-form").find("input[name={0}]".format(e)),n=(0,i.default)(o);n.addClass("input-filled-invalid"),n.removeClass("input-filled-valid")}))})):(0,i.default)("#user-award-form > #results").append((0,d.ezBadge)({type:"error",body:"Please select a team member"}))}),(0,i.default)(".delete-member").click(function(e){e.preventDefault();var t=(0,i.default)(this).attr("member-id"),o=(0,i.default)(this).attr("member-name"),n={user_id:t},s=(0,i.default)(this).parent().parent();(0,d.ezQuery)({title:"Remove Member",body:"Are you sure you want to remove {0} from {1}?

All of their challenges solves, attempts, awards, and unlocked hints will also be deleted!".format(""+(0,l.htmlEntities)(o)+"",""+(0,l.htmlEntities)(TEAM_NAME)+""),success:function(){r.default.fetch("/api/v1/teams/"+TEAM_ID+"/members",{method:"DELETE",body:JSON.stringify(n)}).then(function(e){return e.json()}).then(function(e){e.success&&s.remove()})}})}),(0,i.default)(".delete-team").click(function(e){(0,d.ezQuery)({title:"Delete Team",body:"Are you sure you want to delete {0}".format(""+(0,l.htmlEntities)(TEAM_NAME)+""),success:function(){r.default.fetch("/api/v1/teams/"+TEAM_ID,{method:"DELETE"}).then(function(e){return e.json()}).then(function(e){e.success&&(window.location=r.default.config.urlRoot+"/admin/teams")})}})}),(0,i.default)(".delete-submission").click(function(e){e.preventDefault();var t=(0,i.default)(this).attr("submission-id"),o=(0,i.default)(this).attr("submission-type"),n=(0,i.default)(this).attr("submission-challenge"),s="Are you sure you want to delete {0} submission from {1} for {2}?".format((0,l.htmlEntities)(o),(0,l.htmlEntities)(TEAM_NAME),(0,l.htmlEntities)(n)),a=(0,i.default)(this).parent().parent();(0,d.ezQuery)({title:"Delete Submission",body:s,success:function(){r.default.fetch("/api/v1/submissions/"+t,{method:"DELETE",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"}}).then(function(e){return e.json()}).then(function(e){e.success&&a.remove()})}})}),(0,i.default)(".delete-award").click(function(e){e.preventDefault();var t=(0,i.default)(this).attr("award-id"),o=(0,i.default)(this).attr("award-name"),n="Are you sure you want to delete the {0} award from {1}?".format((0,l.htmlEntities)(o),(0,l.htmlEntities)(TEAM_NAME)),s=(0,i.default)(this).parent().parent();(0,d.ezQuery)({title:"Delete Award",body:n,success:function(){r.default.fetch("/api/v1/awards/"+t,{method:"DELETE",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"}}).then(function(e){return e.json()}).then(function(e){e.success&&s.remove()})}})}),(0,i.default)("#team-info-create-form").submit(a),(0,i.default)("#team-info-edit-form").submit(m);var s=window.stats_data;e=s.type,t=s.id,o=s.name,n=s.account_id,function(t,o,n,s){var e=u(p[t],3),a=e[0],i=e[1],r=e[2];Promise.all([a(s),i(s),r(s)]).then(function(e){(0,c.createGraph)("score_graph","#score-graph",e,t,o,n,s),(0,c.createGraph)("category_breakdown","#categories-pie-graph",e,t,o,n,s),(0,c.createGraph)("solve_percentages","#keys-pie-graph",e,t,o,n,s)})}(e,t,o,n),setInterval(function(){!function(t,o,n,s){var e=u(p[t],3),a=e[0],i=e[1],r=e[2];Promise.all([a(s),i(s),r(s)]).then(function(e){(0,c.updateGraph)("score_graph","#score-graph",e,t,o,n,s),(0,c.updateGraph)("category_breakdown","#categories-pie-graph",e,t,o,n,s),(0,c.updateGraph)("solve_percentages","#keys-pie-graph",e,t,o,n,s)})}(e,t,o,n)},3e5)})},"./CTFd/themes/admin/assets/js/styles.js":function(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,o("./node_modules/bootstrap/dist/js/bootstrap.bundle.js");var n,s=(n=o("./node_modules/jquery/dist/jquery.js"))&&n.__esModule?n:{default:n};t.default=function(){(0,s.default)(":input").each(function(){(0,s.default)(this).data("initial",(0,s.default)(this).val())}),(0,s.default)(".form-control").bind({focus:function(){(0,s.default)(this).addClass("input-filled-valid")},blur:function(){""===(0,s.default)(this).val()&&(0,s.default)(this).removeClass("input-filled-valid")}}),(0,s.default)(".modal").on("show.bs.modal",function(e){(0,s.default)(".form-control").each(function(){(0,s.default)(this).val()&&(0,s.default)(this).addClass("input-filled-valid")})}),(0,s.default)(function(){(0,s.default)(".form-control").each(function(){(0,s.default)(this).val()&&(0,s.default)(this).addClass("input-filled-valid")}),(0,s.default)("tr[data-href]").click(function(){if(!getSelection().toString()){var e=(0,s.default)(this).attr("data-href");e&&(window.location=e)}return!1}),(0,s.default)("tr[data-href] a, tr[data-href] button").click(function(e){(0,s.default)(this).attr("data-dismiss")||e.stopPropagation()}),(0,s.default)('[data-toggle="tooltip"]').tooltip()})}},"./CTFd/themes/core/assets/js/CTFd.js":function(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=d(o("./CTFd/themes/core/assets/js/fetch.js")),s=d(o("./CTFd/themes/core/assets/js/config.js")),a=o("./CTFd/themes/core/assets/js/api.js");o("./CTFd/themes/core/assets/js/patch.js");var i=d(o("./node_modules/markdown-it/index.js")),r=d(o("./node_modules/jquery/dist/jquery.js")),l=d(o("./CTFd/themes/core/assets/js/ezq.js"));function d(e){return e&&e.__esModule?e:{default:e}}function c(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var u=new a.API("/"),m={},p={ezq:l.default},f={$:r.default,markdown:function(e){var t=function(t){for(var e=1;e".concat(e.body,"

")):o.find(".modal-body").append((0,r.default)(e.body));var n=(0,r.default)(c.format(e.button));return e.success&&(0,r.default)(n).click(function(){e.success()}),e.large&&o.find(".modal-dialog").addClass("modal-lg"),o.find(".modal-footer").append(n),(0,r.default)("main").append(o),o.modal("show"),(0,r.default)(o).on("hidden.bs.modal",function(){(0,r.default)(this).modal("dispose")}),o}function f(e){(0,r.default)("#ezq--notifications-toast-container").length||(0,r.default)("body").append((0,r.default)("
").attr({id:"ezq--notifications-toast-container"}).css({position:"fixed",bottom:"0",right:"0","min-width":"20%"}));var t=l.format(e.title,e.body),o=(0,r.default)(t);if(e.onclose&&(0,r.default)(o).find("button[data-dismiss=toast]").click(function(){e.onclose()}),e.onclick){var n=(0,r.default)(o).find(".toast-body");n.addClass("cursor-pointer"),n.click(function(){e.onclick()})}var s=!1!==e.autohide,a=!1!==e.animation,i=e.delay||1e4;return(0,r.default)("#ezq--notifications-toast-container").prepend(o),o.toast({autohide:s,delay:i,animation:a}),o.toast("show"),o}function j(e){var t=a.format(e.title),o=(0,r.default)(t);"string"==typeof e.body?o.find(".modal-body").append("

".concat(e.body,"

")):o.find(".modal-body").append((0,r.default)(e.body));var n=(0,r.default)(m),s=(0,r.default)(u);return o.find(".modal-footer").append(s),o.find(".modal-footer").append(n),(0,r.default)("main").append(o),(0,r.default)(o).on("hidden.bs.modal",function(){(0,r.default)(this).modal("dispose")}),(0,r.default)(n).click(function(){e.success()}),o.modal("show"),o}function h(e){if(e.target){var t=(0,r.default)(e.target);return t.find(".progress-bar").css("width",e.width+"%"),t}var o=i.format(e.width),n=a.format(e.title),s=(0,r.default)(n);return s.find(".modal-body").append((0,r.default)(o)),(0,r.default)("main").append(s),s.modal("show")}function _(e){var t={success:d,error:s}[e.type].format(e.body);return(0,r.default)(t)}var g={ezAlert:p,ezToast:f,ezQuery:j,ezProgressBar:h,ezBadge:_};t.default=g},"./CTFd/themes/core/assets/js/fetch.js":function(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,o("./node_modules/whatwg-fetch/fetch.js");var n,s=(n=o("./CTFd/themes/core/assets/js/config.js"))&&n.__esModule?n:{default:n};var a=window.fetch;t.default=function(e,t){return void 0===t&&(t={method:"GET",credentials:"same-origin",headers:{}}),e=s.default.urlRoot+e,void 0===t.headers&&(t.headers={}),t.credentials="same-origin",t.headers.Accept="application/json",t.headers["Content-Type"]="application/json",t.headers["CSRF-Token"]=s.default.csrfNonce,a(e,t)}},"./CTFd/themes/core/assets/js/graphs.js":function(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.createGraph=function(e,t,o,n,s,a,i){var r=f[e],l=(0,c.default)(t);if(l.empty(),void 0===l[0])return void console.log("Couldn't find graph target: "+t);l[0].fn=r.fn(n,s,a,i);var d=r.format(n,s,a,i,o);u.default.newPlot(l[0],d,r.layout,j)},t.updateGraph=function(e,t,o,n,s,a,i){var r=f[e],l=(0,c.default)(t),d=r.format(n,s,a,i,o);u.default.update(l[0],d,r.layout,j)};var c=n(o("./node_modules/jquery/dist/jquery.js")),u=n(o("./node_modules/plotly.js-basic-dist/plotly-basic.js")),m=n(o("./node_modules/moment/moment.js")),p=o("./CTFd/themes/core/assets/js/utils.js");function n(e){return e&&e.__esModule?e:{default:e}}var f={score_graph:{layout:{title:"Score over Time",paper_bgcolor:"rgba(0,0,0,0)",plot_bgcolor:"rgba(0,0,0,0)",hovermode:"closest",xaxis:{showgrid:!1,showspikes:!0},yaxis:{showgrid:!1,showspikes:!0},legend:{orientation:"h"}},fn:function(e,t,o,n){return"CTFd_score_".concat(e,"_").concat(o,"_").concat(t,"_").concat((new Date).toISOString().slice(0,19))},format:function(e,t,o,n,s){var a=[],i=[],r=s[0].data,l=s[2].data,d=r.concat(l);d.sort(function(e,t){return new Date(e.date)-new Date(t.date)});for(var c=0;c>8*s&255).toString(16)).substr(-2)}return n},t.htmlEntities=function(e){return(0,a.default)("
").text(e).html()},t.cumulativeSum=function(e){for(var t=e.concat(),o=0;o #results").empty(),Object.keys(s.errors).forEach(function(e,t){(0,i.default)("#team-info-form > #results").append((0,d.ezBadge)({type:"error",body:s.errors[e]}));var o=(0,i.default)("#team-info-form").find("input[name={0}]".format(e)),n=(0,i.default)(o);n.addClass("input-filled-invalid"),n.removeClass("input-filled-valid")})})}function m(e){e.preventDefault();var t=(0,i.default)("#team-info-edit-form").serializeJSON(!0);r.default.fetch("/api/v1/teams/"+TEAM_ID,{method:"PATCH",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)}).then(function(e){return e.json()}).then(function(s){s.success?window.location.reload():((0,i.default)("#team-info-form > #results").empty(),Object.keys(s.errors).forEach(function(e,t){(0,i.default)("#team-info-form > #results").append((0,d.ezBadge)({type:"error",body:s.errors[e]}));var o=(0,i.default)("#team-info-form").find("input[name={0}]".format(e)),n=(0,i.default)(o);n.addClass("input-filled-invalid"),n.removeClass("input-filled-valid")}))})}var p={team:[function(e){return r.default.api.get_team_solves({teamId:e})},function(e){return r.default.api.get_team_fails({teamId:e})},function(e){return r.default.api.get_team_awards({teamId:e})}],user:[function(e){return r.default.api.get_user_solves({userId:e})},function(e){return r.default.api.get_user_fails({userId:e})},function(e){return r.default.api.get_user_awards({userId:e})}]};(0,i.default)(function(){var e,t,o,n;(0,i.default)("#team-captain-form").submit(function(e){e.preventDefault();var t=(0,i.default)("#team-captain-form").serializeJSON(!0);r.default.fetch("/api/v1/teams/"+TEAM_ID,{method:"PATCH",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)}).then(function(e){return e.json()}).then(function(s){s.success?window.location.reload():((0,i.default)("#team-captain-form > #results").empty(),Object.keys(s.errors).forEach(function(e,t){(0,i.default)("#team-captain-form > #results").append((0,d.ezBadge)({type:"error",body:s.errors[e]}));var o=(0,i.default)("#team-captain-form").find("select[name={0}]".format(e)),n=(0,i.default)(o);n.addClass("input-filled-invalid"),n.removeClass("input-filled-valid")}))})}),(0,i.default)(".edit-team").click(function(e){(0,i.default)("#team-info-edit-modal").modal("toggle")}),(0,i.default)(".edit-captain").click(function(e){(0,i.default)("#team-captain-modal").modal("toggle")}),(0,i.default)(".award-team").click(function(e){(0,i.default)("#team-award-modal").modal("toggle")}),(0,i.default)("#user-award-form").submit(function(e){e.preventDefault();var t=(0,i.default)("#user-award-form").serializeJSON(!0);t.user_id=(0,i.default)("#award-member-input").val(),t.team_id=TEAM_ID,(0,i.default)("#user-award-form > #results").empty(),t.user_id?(t.user_id=parseInt(t.user_id),r.default.fetch("/api/v1/awards",{method:"POST",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)}).then(function(e){return e.json()}).then(function(s){s.success?window.location.reload():((0,i.default)("#user-award-form > #results").empty(),Object.keys(s.errors).forEach(function(e,t){(0,i.default)("#user-award-form > #results").append((0,d.ezBadge)({type:"error",body:s.errors[e]}));var o=(0,i.default)("#user-award-form").find("input[name={0}]".format(e)),n=(0,i.default)(o);n.addClass("input-filled-invalid"),n.removeClass("input-filled-valid")}))})):(0,i.default)("#user-award-form > #results").append((0,d.ezBadge)({type:"error",body:"Please select a team member"}))}),(0,i.default)(".delete-member").click(function(e){e.preventDefault();var t=(0,i.default)(this).attr("member-id"),o=(0,i.default)(this).attr("member-name"),n={user_id:t},s=(0,i.default)(this).parent().parent();(0,d.ezQuery)({title:"Remove Member",body:"Are you sure you want to remove {0} from {1}?

All of their challenges solves, attempts, awards, and unlocked hints will also be deleted!".format(""+(0,l.htmlEntities)(o)+"",""+(0,l.htmlEntities)(TEAM_NAME)+""),success:function(){r.default.fetch("/api/v1/teams/"+TEAM_ID+"/members",{method:"DELETE",body:JSON.stringify(n)}).then(function(e){return e.json()}).then(function(e){e.success&&s.remove()})}})}),(0,i.default)(".delete-team").click(function(e){(0,d.ezQuery)({title:"Delete Team",body:"Are you sure you want to delete {0}".format(""+(0,l.htmlEntities)(TEAM_NAME)+""),success:function(){r.default.fetch("/api/v1/teams/"+TEAM_ID,{method:"DELETE"}).then(function(e){return e.json()}).then(function(e){e.success&&(window.location=r.default.config.urlRoot+"/admin/teams")})}})}),(0,i.default)(".delete-submission").click(function(e){e.preventDefault();var t=(0,i.default)(this).attr("submission-id"),o=(0,i.default)(this).attr("submission-type"),n=(0,i.default)(this).attr("submission-challenge"),s="Are you sure you want to delete {0} submission from {1} for {2}?".format((0,l.htmlEntities)(o),(0,l.htmlEntities)(TEAM_NAME),(0,l.htmlEntities)(n)),a=(0,i.default)(this).parent().parent();(0,d.ezQuery)({title:"Delete Submission",body:s,success:function(){r.default.fetch("/api/v1/submissions/"+t,{method:"DELETE",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"}}).then(function(e){return e.json()}).then(function(e){e.success&&a.remove()})}})}),(0,i.default)(".delete-award").click(function(e){e.preventDefault();var t=(0,i.default)(this).attr("award-id"),o=(0,i.default)(this).attr("award-name"),n="Are you sure you want to delete the {0} award from {1}?".format((0,l.htmlEntities)(o),(0,l.htmlEntities)(TEAM_NAME)),s=(0,i.default)(this).parent().parent();(0,d.ezQuery)({title:"Delete Award",body:n,success:function(){r.default.fetch("/api/v1/awards/"+t,{method:"DELETE",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json"}}).then(function(e){return e.json()}).then(function(e){e.success&&s.remove()})}})}),(0,i.default)("#team-info-create-form").submit(a),(0,i.default)("#team-info-edit-form").submit(m);var s=window.stats_data;e=s.type,t=s.id,o=s.name,n=s.account_id,function(t,o,n,s){var e=u(p[t],3),a=e[0],i=e[1],r=e[2];Promise.all([a(s),i(s),r(s)]).then(function(e){(0,c.createGraph)("score_graph","#score-graph",e,t,o,n,s),(0,c.createGraph)("category_breakdown","#categories-pie-graph",e,t,o,n,s),(0,c.createGraph)("solve_percentages","#keys-pie-graph",e,t,o,n,s)})}(e,t,o,n),setInterval(function(){!function(t,o,n,s){var e=u(p[t],3),a=e[0],i=e[1],r=e[2];Promise.all([a(s),i(s),r(s)]).then(function(e){(0,c.updateGraph)("score_graph","#score-graph",e,t,o,n,s),(0,c.updateGraph)("category_breakdown","#categories-pie-graph",e,t,o,n,s),(0,c.updateGraph)("solve_percentages","#keys-pie-graph",e,t,o,n,s)})}(e,t,o,n)},3e5)})},"./CTFd/themes/admin/assets/js/styles.js":function(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,o("./node_modules/bootstrap/dist/js/bootstrap.bundle.js");var n,s=(n=o("./node_modules/jquery/dist/jquery.js"))&&n.__esModule?n:{default:n};t.default=function(){(0,s.default)(":input").each(function(){(0,s.default)(this).data("initial",(0,s.default)(this).val())}),(0,s.default)(".form-control").bind({focus:function(){(0,s.default)(this).addClass("input-filled-valid")},blur:function(){""===(0,s.default)(this).val()&&(0,s.default)(this).removeClass("input-filled-valid")}}),(0,s.default)(".modal").on("show.bs.modal",function(e){(0,s.default)(".form-control").each(function(){(0,s.default)(this).val()&&(0,s.default)(this).addClass("input-filled-valid")})}),(0,s.default)(function(){(0,s.default)(".form-control").each(function(){(0,s.default)(this).val()&&(0,s.default)(this).addClass("input-filled-valid")}),(0,s.default)("tr[data-href]").click(function(){if(!getSelection().toString()){var e=(0,s.default)(this).attr("data-href");e&&(window.location=e)}return!1}),(0,s.default)("tr[data-href] a, tr[data-href] button").click(function(e){(0,s.default)(this).attr("data-dismiss")||e.stopPropagation()}),(0,s.default)('[data-toggle="tooltip"]').tooltip()})}},"./CTFd/themes/core/assets/js/CTFd.js":function(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=d(o("./CTFd/themes/core/assets/js/fetch.js")),s=d(o("./CTFd/themes/core/assets/js/config.js")),a=o("./CTFd/themes/core/assets/js/api.js");o("./CTFd/themes/core/assets/js/patch.js");var i=d(o("./node_modules/markdown-it/index.js")),r=d(o("./node_modules/jquery/dist/jquery.js")),l=d(o("./CTFd/themes/core/assets/js/ezq.js"));function d(e){return e&&e.__esModule?e:{default:e}}function c(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var u=new a.API("/"),m={},p={ezq:l.default},f={$:r.default,markdown:function(e){var t=function(t){for(var e=1;e".concat(e.body,"

")):o.find(".modal-body").append((0,r.default)(e.body));var n=(0,r.default)(c.format(e.button));return e.success&&(0,r.default)(n).click(function(){e.success()}),e.large&&o.find(".modal-dialog").addClass("modal-lg"),o.find(".modal-footer").append(n),(0,r.default)("main").append(o),o.modal("show"),(0,r.default)(o).on("hidden.bs.modal",function(){(0,r.default)(this).modal("dispose")}),o}function f(e){(0,r.default)("#ezq--notifications-toast-container").length||(0,r.default)("body").append((0,r.default)("
").attr({id:"ezq--notifications-toast-container"}).css({position:"fixed",bottom:"0",right:"0","min-width":"20%"}));var t=l.format(e.title,e.body),o=(0,r.default)(t);if(e.onclose&&(0,r.default)(o).find("button[data-dismiss=toast]").click(function(){e.onclose()}),e.onclick){var n=(0,r.default)(o).find(".toast-body");n.addClass("cursor-pointer"),n.click(function(){e.onclick()})}var s=!1!==e.autohide,a=!1!==e.animation,i=e.delay||1e4;return(0,r.default)("#ezq--notifications-toast-container").prepend(o),o.toast({autohide:s,delay:i,animation:a}),o.toast("show"),o}function j(e){var t=a.format(e.title),o=(0,r.default)(t);"string"==typeof e.body?o.find(".modal-body").append("

".concat(e.body,"

")):o.find(".modal-body").append((0,r.default)(e.body));var n=(0,r.default)(m),s=(0,r.default)(u);return o.find(".modal-footer").append(s),o.find(".modal-footer").append(n),(0,r.default)("main").append(o),(0,r.default)(o).on("hidden.bs.modal",function(){(0,r.default)(this).modal("dispose")}),(0,r.default)(n).click(function(){e.success()}),o.modal("show"),o}function h(e){if(e.target){var t=(0,r.default)(e.target);return t.find(".progress-bar").css("width",e.width+"%"),t}var o=i.format(e.width),n=a.format(e.title),s=(0,r.default)(n);return s.find(".modal-body").append((0,r.default)(o)),(0,r.default)("main").append(s),s.modal("show")}function _(e){var t={success:d,error:s}[e.type].format(e.body);return(0,r.default)(t)}var g={ezAlert:p,ezToast:f,ezQuery:j,ezProgressBar:h,ezBadge:_};t.default=g},"./CTFd/themes/core/assets/js/fetch.js":function(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,o("./node_modules/whatwg-fetch/fetch.js");var n,s=(n=o("./CTFd/themes/core/assets/js/config.js"))&&n.__esModule?n:{default:n};var a=window.fetch;t.default=function(e,t){return void 0===t&&(t={method:"GET",credentials:"same-origin",headers:{}}),e=s.default.urlRoot+e,void 0===t.headers&&(t.headers={}),t.credentials="same-origin",t.headers.Accept="application/json",t.headers["Content-Type"]="application/json",t.headers["CSRF-Token"]=s.default.csrfNonce,a(e,t)}},"./CTFd/themes/core/assets/js/graphs.js":function(e,t,o){Object.defineProperty(t,"__esModule",{value:!0}),t.createGraph=function(e,t,o,n,s,a,i){var r=f[e],l=(0,c.default)(t);if(l.empty(),void 0===l[0])return void console.log("Couldn't find graph target: "+t);l[0].fn=r.fn(n,s,a,i);var d=r.format(n,s,a,i,o);u.default.newPlot(l[0],d,r.layout,j)},t.updateGraph=function(e,t,o,n,s,a,i){var r=f[e],l=(0,c.default)(t),d=r.format(n,s,a,i,o);u.default.update(l[0],d,r.layout,j)};var c=n(o("./node_modules/jquery/dist/jquery.js")),u=n(o("./node_modules/plotly.js-basic-dist/plotly-basic.js")),m=n(o("./node_modules/moment/moment.js")),p=o("./CTFd/themes/core/assets/js/utils.js");function n(e){return e&&e.__esModule?e:{default:e}}var f={score_graph:{layout:{title:"Score over Time",paper_bgcolor:"rgba(0,0,0,0)",plot_bgcolor:"rgba(0,0,0,0)",hovermode:"closest",xaxis:{showgrid:!1,showspikes:!0},yaxis:{showgrid:!1,showspikes:!0},legend:{orientation:"h"}},fn:function(e,t,o,n){return"CTFd_score_".concat(e,"_").concat(o,"_").concat(t,"_").concat((new Date).toISOString().slice(0,19))},format:function(e,t,o,n,s){var a=[],i=[],r=s[0].data,l=s[2].data,d=r.concat(l);d.sort(function(e,t){return new Date(e.date)-new Date(t.date)});for(var c=0;c>8*s&255).toString(16)).substr(-2)}return n},t.htmlEntities=function(e){return(0,a.default)("
").text(e).html()},t.cumulativeSum=function(e){for(var t=e.concat(),o=0;o if admin""" app = create_ctfd()