added shell route
parent
27c4c97074
commit
8d47355938
3
app.py
3
app.py
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
|
@ -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 %}
|
Loading…
Reference in New Issue