some fixes

master
James Sigurðarson 2016-08-05 20:08:25 +00:00
parent 1e98f823b8
commit 08602b5bc7
5 changed files with 13 additions and 5 deletions

1
.gitignore vendored
View File

@ -102,5 +102,6 @@ tags
dev.db
dump.rdb
/problems
/problem_static
/secrets
/database

View File

@ -7,7 +7,7 @@ BASE_DIR = os.path.dirname(os.path.abspath(__file__))
ctf_name = "IceCTF"
eligibility = "In order to be eligible for prizes, all members of your team must be Icelandic residents, and you must not have more than three team members."
tagline = "The Icelandic Hacking Competition"
#IRC Channel
# IRC Channel
ctf_chat_channel = "#IceCTF"
ctf_home_url = "https://icec.tf"
@ -32,8 +32,8 @@ immediate_scoreboard = False
disallowed_domain = "icec.tf"
# Where the static stuff is stored
static_prefix = "http://127.0.0.1/static/"
static_dir = "{}/static/".format(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
static_prefix = "/problem-static/"
static_dir = "{}/problem_static/".format(os.path.dirname(os.path.abspath(__file__)))
custom_stylesheet = "css/main.css"
# Shell accounts?
@ -42,7 +42,7 @@ enable_shell = True
shell_port = 22
shell_user_prefixes = ["ctf-"]
shell_user_prefixes = ["ctf-"]
shell_password_length = 6
shell_free_acounts = 10
shell_max_accounts = 99999

View File

@ -107,6 +107,7 @@ def scan_challenges_problem(d, files):
def scan_challenges_stage(d, files):
with open(os.path.join(d, "stage.yml")) as f:
data = yaml.load(f)
query = Stage.select().where(Stage.alias == data["alias"])
@ -121,6 +122,7 @@ def scan_challenges(args):
path = args.path
n = 0
os.makedirs(config.static_dir, exist_ok=True)
for root, dirs, files in os.walk(path):
if "problem.yml" in files:
n += 1

View File

@ -36,6 +36,7 @@ def get_solve_counts():
d[k.id] = get_solve_count(k.id)
return d
def get_solve_count(chall_id):
s = g.redis.hget("solves", chall_id)
if s is not None:
@ -60,6 +61,10 @@ def get_solved(team):
return Challenge.select().join(ChallengeSolve).where(ChallengeSolve.team == g.team)
def get_solves(team):
return ChallengeSolve.select(ChallengeSolve, Challenge).join(Challenge).where(ChallengeSolve.team == g.team)
def get_adjustments(team):
return ScoreAdjustment.select().where(ScoreAdjustment.team == team)

View File

@ -17,7 +17,7 @@ teams = Blueprint("teams", __name__, template_folder="../templates/teams")
@ratelimit.ratelimit(limit=6, per=120)
def dashboard():
if request.method == "GET":
team_solves = challenge.get_solved(g.team)
team_solves = challenge.get_solves(g.team)
team_adjustments = challenge.get_adjustments(g.team)
team_score = sum([i.challenge.points for i in team_solves] + [i.value for i in team_adjustments])
return render_template("team.html", team_solves=team_solves, team_adjustments=team_adjustments, team_score=team_score)