mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-18 14:34:21 +01:00
Handle special casing of affiliation and website
This commit is contained in:
@@ -2,7 +2,7 @@ from flask import Blueprint, redirect, render_template, request, url_for
|
|||||||
|
|
||||||
from CTFd.cache import clear_team_session, clear_user_session
|
from CTFd.cache import clear_team_session, clear_user_session
|
||||||
from CTFd.models import TeamFieldEntries, TeamFields, Teams, db
|
from CTFd.models import TeamFieldEntries, TeamFields, Teams, db
|
||||||
from CTFd.utils import config, get_config
|
from CTFd.utils import config, get_config, validators
|
||||||
from CTFd.utils.crypto import verify_password
|
from CTFd.utils.crypto import verify_password
|
||||||
from CTFd.utils.decorators import authed_only, ratelimit
|
from CTFd.utils.decorators import authed_only, ratelimit
|
||||||
from CTFd.utils.decorators.modes import require_team_mode
|
from CTFd.utils.decorators.modes import require_team_mode
|
||||||
@@ -125,6 +125,9 @@ def new():
|
|||||||
passphrase = request.form.get("password", "").strip()
|
passphrase = request.form.get("password", "").strip()
|
||||||
errors = get_errors()
|
errors = get_errors()
|
||||||
|
|
||||||
|
website = request.form.get("website")
|
||||||
|
affiliation = request.form.get("affiliation")
|
||||||
|
|
||||||
user = get_current_user()
|
user = get_current_user()
|
||||||
|
|
||||||
existing_team = Teams.query.filter_by(name=teamname).first()
|
existing_team = Teams.query.filter_by(name=teamname).first()
|
||||||
@@ -158,27 +161,30 @@ def new():
|
|||||||
else:
|
else:
|
||||||
entries[field_id] = value
|
entries[field_id] = value
|
||||||
|
|
||||||
# if website:
|
if website:
|
||||||
# valid_website = validators.validate_url(website)
|
valid_website = validators.validate_url(website)
|
||||||
# else:
|
else:
|
||||||
# valid_website = True
|
valid_website = True
|
||||||
|
|
||||||
# if affiliation:
|
if affiliation:
|
||||||
# valid_affiliation = len(affiliation) < 128
|
valid_affiliation = len(affiliation) < 128
|
||||||
# else:
|
else:
|
||||||
# valid_affiliation = True
|
valid_affiliation = True
|
||||||
|
|
||||||
|
if valid_website is False:
|
||||||
|
errors.append("Websites must be a proper URL starting with http or https")
|
||||||
|
if valid_affiliation is False:
|
||||||
|
errors.append("Please provide a shorter affiliation")
|
||||||
|
|
||||||
if errors:
|
if errors:
|
||||||
return render_template("teams/new_team.html", errors=errors)
|
return render_template("teams/new_team.html", errors=errors)
|
||||||
|
|
||||||
team = Teams(name=teamname, password=passphrase, captain_id=user.id)
|
team = Teams(name=teamname, password=passphrase, captain_id=user.id)
|
||||||
|
|
||||||
# if website:
|
if website:
|
||||||
# user.website = website
|
team.website = website
|
||||||
# if affiliation:
|
if affiliation:
|
||||||
# user.affiliation = affiliation
|
team.affiliation = affiliation
|
||||||
# if country:
|
|
||||||
# user.country = country
|
|
||||||
|
|
||||||
db.session.add(team)
|
db.session.add(team)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|||||||
@@ -49,7 +49,9 @@ function createTeam(event) {
|
|||||||
body: response.errors[key]
|
body: response.errors[key]
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
const i = $("#team-info-create-form").find("input[name={0}]".format(key));
|
const i = $("#team-info-create-form").find(
|
||||||
|
"input[name={0}]".format(key)
|
||||||
|
);
|
||||||
const input = $(i);
|
const input = $(i);
|
||||||
input.addClass("input-filled-invalid");
|
input.addClass("input-filled-invalid");
|
||||||
input.removeClass("input-filled-valid");
|
input.removeClass("input-filled-valid");
|
||||||
|
|||||||
Reference in New Issue
Block a user