show all scheduled tournaments

This commit is contained in:
Thibault Duplessis 2014-04-10 23:01:45 +02:00
parent 7924c546c9
commit eaa55eafe7
4 changed files with 34 additions and 11 deletions

View file

@ -24,22 +24,22 @@ object Tournament extends LilaController {
}
val home = Open { implicit ctx =>
tournaments zip UserRepo.allSortToints(10) map {
case (((created, started), finished), leaderboard) =>
Ok(html.tournament.home(created, started, finished, leaderboard))
fetchTournaments zip repo.scheduled zip UserRepo.allSortToints(10) map {
case ((((created, started), finished), scheduled), leaderboard) =>
Ok(html.tournament.home(created, started, finished, scheduled, leaderboard))
}
}
val faq = Open { implicit ctx => Ok(html.tournament.faqPage()).fuccess }
val homeReload = Open { implicit ctx =>
tournaments map {
fetchTournaments map {
case ((created, started), finished) =>
Ok(html.tournament.homeInner(created, started, finished))
}
}
private def tournaments =
private def fetchTournaments =
repo.enterable zip repo.started zip repo.finished(20)
def show(id: String) = Open { implicit ctx =>

View file

@ -1,4 +1,4 @@
@(createds: List[lila.tournament.Created], starteds: List[lila.tournament.Started], finisheds: List[lila.tournament.Finished], leaderboard: List[User])(implicit ctx: Context)
@(createds: List[lila.tournament.Created], starteds: List[lila.tournament.Started], finisheds: List[lila.tournament.Finished], scheduled: List[lila.tournament.Created], leaderboard: List[User])(implicit ctx: Context)
@goodies = {
<div class="tournament_links">
@ -6,9 +6,20 @@
</div>
<h2 class="leaderboard_title">@trans.leaderboard()</h2>
<ol class="tournament_leaderboard">
@leaderboard.map { user =>
<li>@userLink(user, withOnline = false, text = Some(user.username + " [" + user.toints.localize + "]"))</li>
}
@leaderboard.map { user =>
<li>@userLink(user, withOnline = false, text = Some(user.username + " [" + user.toints.localize + "]"))</li>
}
</ol>
<h2 class="leaderboard_title">Lichess tournaments</h2>
<ol class="scheduled_tournaments">
@scheduled.map { tour =>
@tour.schedule.map { s =>
<li>
<a href="@routes.Tournament.show(tour.id)">@tour.name</a><br />
@momentFormat(s.at, "calendar")
</li>
}
}
</ol>
}
@ -16,6 +27,6 @@
title = trans.tournaments.str(),
goodies = goodies.some) {
<div id="tournament" data-href="@routes.Tournament.homeReload()">
@tournament.homeInner(createds, starteds, finisheds)
@tournament.homeInner(createds, starteds, finisheds)
</div>
}

View file

@ -68,7 +68,9 @@ object TournamentRepo {
$query(Json.obj(
"status" -> Status.Created.id,
"schedule" -> $exists(true)
))
)) sort BSONDocument(
"schedule.at" -> 1
)
) map { _.map(asCreated).flatten }
def withdraw(userId: String): Fu[List[String]] = for {

View file

@ -170,3 +170,13 @@ ol.tournament_leaderboard li {
ol.tournament_leaderboard a {
text-decoration: none;
}
ol.scheduled_tournaments li {
padding: 5px 0;
}
ol.scheduled_tournaments a {
font-weight: bold;
text-decoration: none;
}
ol.scheduled_tournaments a:hover {
text-decoration: underline;
}