not sure if this works or not but whatever
This commit is contained in:
parent
353b639cbe
commit
9b80a01e10
5 changed files with 79 additions and 66 deletions
|
@ -51,7 +51,8 @@ class Teams(db.Model):
|
|||
members.append({
|
||||
"username": member.username,
|
||||
"name": member.name,
|
||||
"captain": member.uid == self.owner
|
||||
"captain": member.uid == self.owner,
|
||||
"type": member.utype
|
||||
})
|
||||
return members
|
||||
|
||||
|
@ -63,7 +64,7 @@ class Teams(db.Model):
|
|||
else:
|
||||
return 0
|
||||
|
||||
def place(self):
|
||||
def place(self, ranked=True):
|
||||
score = db.func.sum(Problems.value).label("score")
|
||||
quickest = db.func.max(Solves.date).label("quickest")
|
||||
teams = db.session.query(Solves.tid).join(Teams).join(Problems).filter().group_by(Solves.tid).order_by(score.desc(), quickest).all()
|
||||
|
@ -112,6 +113,13 @@ class Teams(db.Model):
|
|||
})
|
||||
return result
|
||||
|
||||
def is_observer(self):
|
||||
members = get_members()
|
||||
for member in members:
|
||||
if member["observer"] == True:
|
||||
return True
|
||||
return False
|
||||
|
||||
class Problems(db.Model):
|
||||
pid = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String(128))
|
||||
|
|
|
@ -12,8 +12,11 @@ blueprint = Blueprint("stats", __name__)
|
|||
def all_teams_stats():
|
||||
teams = team.get_team().all()
|
||||
result = [ ]
|
||||
count = 0
|
||||
for _team in teams:
|
||||
count += 1
|
||||
result.append({
|
||||
"rank": count,
|
||||
"teamname": _team.teamname,
|
||||
"tid": _team.tid,
|
||||
"school": _team.school,
|
||||
|
|
|
@ -169,6 +169,7 @@ def team_info():
|
|||
in_team = False
|
||||
owner = False
|
||||
_user = None
|
||||
teamdata = { }
|
||||
search = { }
|
||||
teamname = utils.flat_multi(request.args).get("teamname")
|
||||
if teamname:
|
||||
|
@ -179,6 +180,7 @@ def team_info():
|
|||
if "teamname_lower" not in search:
|
||||
search.update({ "tid": _user.tid })
|
||||
in_team = True
|
||||
if bool(search) != False:
|
||||
team = get_team(**search).first()
|
||||
teamdata = get_team_info(**search)
|
||||
if logged_in:
|
||||
|
|
|
@ -240,7 +240,7 @@ var register_form = function() {
|
|||
$(input).removeAttr("disabled");
|
||||
});
|
||||
}
|
||||
}).fail(function(jqXHR, status, error) {
|
||||
}, function(jqXHR, status, error) {
|
||||
var result = JSON.parse(jqXHR["responseText"]);
|
||||
display_message("register_msg", "danger", "Error " + jqXHR["status"] + ": " + result["message"], function() {
|
||||
$(input).removeAttr("disabled");
|
||||
|
@ -260,7 +260,7 @@ var request_reset_form = function() {
|
|||
$(input).removeAttr("disabled");
|
||||
});
|
||||
}
|
||||
}).fail(function(jqXHR, status, error) {
|
||||
}, function(jqXHR, status, error) {
|
||||
var result = JSON.parse(jqXHR["responseText"]);
|
||||
display_message("reset_msg", "danger", "Error " + jqXHR["status"] + ": " + result["message"], function() {
|
||||
$(input).removeAttr("disabled");
|
||||
|
@ -284,7 +284,7 @@ var reset_form = function() {
|
|||
$(input).removeAttr("disabled");
|
||||
});
|
||||
}
|
||||
}).fail(function(jqXHR, status, error) {
|
||||
}, function(jqXHR, status, error) {
|
||||
var result = JSON.parse(jqXHR["responseText"]);
|
||||
display_message("reset_msg", "danger", "Error " + jqXHR["status"] + ": " + result["message"], function() {
|
||||
$(input).removeAttr("disabled");
|
||||
|
@ -306,7 +306,7 @@ var login_form = function() {
|
|||
$(input).removeAttr("disabled");
|
||||
});
|
||||
}
|
||||
}).fail(function(jqXHR, status, error) {
|
||||
}, function(jqXHR, status, error) {
|
||||
var result = JSON.parse(jqXHR["responseText"]);
|
||||
display_message("login_msg", "danger", "Error " + jqXHR["status"] + ": " + result["message"], function() {
|
||||
$(input).removeAttr("disabled");
|
||||
|
@ -328,7 +328,7 @@ var create_team = function() {
|
|||
$(input).removeAttr("disabled");
|
||||
});
|
||||
}
|
||||
}).fail(function(jqXHR, status, error) {
|
||||
}, function(jqXHR, status, error) {
|
||||
var result = JSON.parse(jqXHR["responseText"]);
|
||||
display_message("create_team_msg", "danger", "Error " + jqXHR["status"] + ": " + result["message"], function() {
|
||||
$(input).removeAttr("disabled");
|
||||
|
@ -346,7 +346,7 @@ var add_member = function() {
|
|||
} else {
|
||||
$(input).removeAttr("disabled");
|
||||
}
|
||||
}).fail(function(jqXHR, status, error) {
|
||||
}, function(jqXHR, status, error) {
|
||||
var result = JSON.parse(jqXHR["responseText"]);
|
||||
display_message("create_team_msg", "danger", "Error " + jqXHR["status"] + ": " + result["message"], function() {
|
||||
$(input).removeAttr("disabled");
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="team in scoreboard">
|
||||
<td></td>
|
||||
<td>{{ team['rank'] }}</td>
|
||||
<td><a ng-href="/team/{{ team['teamname'] }}">{{ team['teamname'] }}</a></td>
|
||||
<td>{{ team['school'] }}</td>
|
||||
<td>{{ team['points'] }}</td>
|
||||
|
|
Loading…
Reference in a new issue