added shell route

master
James Sigurðarson 2016-08-12 12:19:18 +01:00
parent 27c4c97074
commit 8d47355938
5 changed files with 33 additions and 2 deletions

3
app.py
View File

@ -12,7 +12,7 @@ from data.database import db
import data
# Blueprints
from routes import api, admin, teams, users, challenges, tickets, scoreboard
from routes import api, admin, teams, users, challenges, tickets, scoreboard, shell
if config.production:
logging.basicConfig(level=logging.INFO)
@ -30,6 +30,7 @@ app.register_blueprint(users.users)
app.register_blueprint(challenges.challenges)
app.register_blueprint(tickets.tickets)
app.register_blueprint(scoreboard.scoreboard)
app.register_blueprint(shell.shell)
@app.before_request

View File

@ -20,3 +20,9 @@ def assign_shell_account(team):
acct = SshAccount.select().order_by(fn.Random()).get()
acct.team = team
acct.save()
def get_team_account(team):
try:
return team.ssh_account.get()
except SshAccount.DoesNotExist:
return None

View File

@ -53,7 +53,7 @@ def admin_dashboard():
adjustments = ScoreAdjustment.select()
scoredata = scoreboard.get_all_scores(teams, solves, adjustments)
lastsolvedata = scoreboard.get_last_solves(teams, solves)
tickets = list(TroubleTicket.select().where(TroubleTicket.active==True))
tickets = list(TroubleTicket.select().where(TroubleTicket.active == True))
return render_template("admin/dashboard.html", teams=teams, scoredata=scoredata, lastsolvedata=lastsolvedata, tickets=tickets)

12
routes/shell.py Normal file
View File

@ -0,0 +1,12 @@
from flask import Blueprint, g, render_template
from data import ssh
shell = Blueprint("shell", __name__, template_folder="../templates/shell")
@shell.route('/shell/')
def index():
account = ssh.get_team_account(g.team)
return render_template("shell.html", account=account)

View File

@ -0,0 +1,12 @@
{% extends "base.html" %}
{% block content %}
<div class="card orange darken-1">
<div class="card-content">
Username: {{account.username}} Password: {{account.password}} <code> ssh {{account.username}}@{{account.hostname}} -p {{account.port}}</code>
</div>
</div>
<div class="center" style="margin-top: 50px;">
<iframe src="https://shell.icec.tf/wetty" frameBorder="0"></iframe>
</div>
</div>
{% endblock %}