team tournaments page
parent
184db2d66d
commit
6bdf567bf2
|
@ -82,6 +82,16 @@ final class Team(
|
|||
}
|
||||
}
|
||||
|
||||
def tournaments(teamId: String) = Open { implicit ctx =>
|
||||
env.team.teamRepo.enabled(teamId) flatMap {
|
||||
_ ?? { team =>
|
||||
env.tournament.tournamentRepo.visibleByTeam(team.id, team.leaders, 50) map { tours =>
|
||||
Ok(html.team.bits.tournaments(team, tours))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def edit(id: String) = Auth { implicit ctx => _ =>
|
||||
WithOwnedTeam(id) { team =>
|
||||
fuccess(html.team.form.edit(team, forms edit team))
|
||||
|
|
|
@ -11,7 +11,10 @@ object bits {
|
|||
import trans.team._
|
||||
|
||||
def link(teamId: lila.team.Team.ID): Frag =
|
||||
a(href := routes.Simul.show(teamId))(teamIdToName(teamId))
|
||||
a(href := routes.Team.show(teamId))(teamIdToName(teamId))
|
||||
|
||||
def link(team: lila.team.Team): Frag =
|
||||
a(href := routes.Team.show(team.id))(team.name)
|
||||
|
||||
def menu(currentTab: Option[String])(implicit ctx: Context) = ~currentTab |> { tab =>
|
||||
st.nav(cls := "page-menu__menu subnav")(
|
||||
|
@ -33,6 +36,23 @@ object bits {
|
|||
)
|
||||
}
|
||||
|
||||
def tournaments(t: lila.team.Team, tours: List[lila.tournament.Tournament])(implicit ctx: Context) = {
|
||||
bits.layout(title = s"${t.name} • ${trans.team.teamLeaders.txt()}") {
|
||||
main(cls := "page-small")(
|
||||
div(cls := "box box-pad")(
|
||||
h1(
|
||||
link(t),
|
||||
" • ",
|
||||
trans.tournaments()
|
||||
),
|
||||
div(cls := "team-tournaments")(
|
||||
views.html.tournament.bits.forTeam(tours)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private[team] def teamTr(t: lila.team.Team)(implicit ctx: Context) = tr(cls := "paginated")(
|
||||
td(cls := "subject")(
|
||||
a(
|
||||
|
|
|
@ -157,8 +157,8 @@ object show {
|
|||
),
|
||||
div(cls := "team-show__tour-forum")(
|
||||
info.tournaments.nonEmpty option frag(
|
||||
st.section(cls := "team-show__tour")(
|
||||
h2(trans.tournaments()),
|
||||
st.section(cls := "team-show__tour team-tournaments")(
|
||||
h2(a(href := routes.Team.tournaments(t.id))(trans.tournaments())),
|
||||
info.tournaments.span(_.isCreated) match {
|
||||
case (created, started) =>
|
||||
views.html.tournament.bits.forTeam(created.sortBy(_.startsAt) ::: started)
|
||||
|
|
|
@ -283,6 +283,7 @@ GET /team/:id/leaders controllers.Team.leadersForm(id: S
|
|||
POST /team/:id/leaders controllers.Team.leaders(id: String)
|
||||
POST /team/:id/close controllers.Team.close(id: String)
|
||||
GET /team/:id/users controllers.Team.legacyUsers(id: String)
|
||||
GET /team/:id/tournaments controllers.Team.tournaments(id: String)
|
||||
GET /team/:id/pm-all controllers.Team.pmAll(id: String)
|
||||
POST /team/:id/pm-all controllers.Team.pmAllSubmit(id: String)
|
||||
# Team API
|
||||
|
|
|
@ -19,7 +19,7 @@ final private[team] class PaginatorBuilder(
|
|||
def popularTeams(page: Int): Fu[Paginator[Team]] = Paginator(
|
||||
adapter = new Adapter(
|
||||
collection = teamRepo.coll,
|
||||
selector = teamRepo.enabledQuery,
|
||||
selector = teamRepo.enabledSelect,
|
||||
projection = none,
|
||||
sort = teamRepo.sortPopular
|
||||
),
|
||||
|
|
|
@ -17,6 +17,8 @@ final class TeamRepo(val coll: Coll)(implicit ec: scala.concurrent.ExecutionCont
|
|||
def byLeader(id: Team.ID, leaderId: User.ID): Fu[Option[Team]] =
|
||||
coll.one[Team]($id(id) ++ $doc("leaders" -> leaderId))
|
||||
|
||||
def enabled(id: Team.ID) = coll.one[Team]($id(id) ++ enabledSelect)
|
||||
|
||||
def teamIdsByLeader(userId: User.ID): Fu[List[String]] =
|
||||
coll.distinctEasy[String, List]("_id", $doc("leaders" -> userId))
|
||||
|
||||
|
@ -57,10 +59,10 @@ final class TeamRepo(val coll: Coll)(implicit ec: scala.concurrent.ExecutionCont
|
|||
|
||||
def cursor =
|
||||
coll.ext
|
||||
.find($doc("enabled" -> true))
|
||||
.find(enabledSelect)
|
||||
.cursor[Team](ReadPreference.secondaryPreferred)
|
||||
|
||||
val enabledQuery = $doc("enabled" -> true)
|
||||
private[team] val enabledSelect = $doc("enabled" -> true)
|
||||
|
||||
val sortPopular = $sort desc "nbMembers"
|
||||
private[team] val sortPopular = $sort desc "nbMembers"
|
||||
}
|
||||
|
|
|
@ -133,6 +133,12 @@ final class TournamentRepo(val coll: Coll, playerCollName: CollName)(
|
|||
}
|
||||
.map(_.flatMap(_.string("_id")))
|
||||
|
||||
def visibleByTeam(
|
||||
teamId: TeamID,
|
||||
leaderIds: Set[User.ID],
|
||||
nb: Int
|
||||
): Fu[List[Tournament]] = idsVisibleByTeam(teamId, leaderIds, nb) flatMap byOrderedIds
|
||||
|
||||
private[tournament] def withdrawableIds(userId: User.ID): Fu[List[Tournament.ID]] =
|
||||
coll
|
||||
.aggregateList(Int.MaxValue, readPreference = ReadPreference.secondaryPreferred) { implicit framework =>
|
||||
|
|
|
@ -81,51 +81,6 @@ $section-margin-more: 5vh;
|
|||
}
|
||||
&__tour {
|
||||
margin-bottom: $section-margin-more;
|
||||
.slist {
|
||||
td {
|
||||
padding: .5rem 1rem;
|
||||
&.duration {
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
.header {
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
a {
|
||||
padding: 1em;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
a {
|
||||
color: $c-font;
|
||||
&:hover {
|
||||
color: $c-link;
|
||||
}
|
||||
}
|
||||
.name {
|
||||
font-size: 1.2em;
|
||||
display: block;
|
||||
}
|
||||
.setup {
|
||||
color: $c-font-dim;
|
||||
}
|
||||
.icon {
|
||||
text-align: center;
|
||||
i {
|
||||
font-size: 2em;
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
.enterable {
|
||||
.icon i {
|
||||
color: $c-brag;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
.soon {
|
||||
border: 1px solid $c-brag;
|
||||
}
|
||||
}
|
||||
}
|
||||
&__requests {
|
||||
margin-bottom: $section-margin-more;
|
||||
|
@ -180,3 +135,48 @@ $section-margin-more: 5vh;
|
|||
}
|
||||
}
|
||||
}
|
||||
.team-tournaments .slist {
|
||||
td {
|
||||
padding: .5rem 1rem;
|
||||
&.duration {
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
.header {
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
a {
|
||||
padding: 1em;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
a {
|
||||
color: $c-font;
|
||||
&:hover {
|
||||
color: $c-link;
|
||||
}
|
||||
}
|
||||
.name {
|
||||
font-size: 1.2em;
|
||||
display: block;
|
||||
}
|
||||
.setup {
|
||||
color: $c-font-dim;
|
||||
}
|
||||
.icon {
|
||||
text-align: center;
|
||||
i {
|
||||
font-size: 2em;
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
.enterable {
|
||||
.icon i {
|
||||
color: $c-brag;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
.soon {
|
||||
border: 1px solid $c-brag;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue