show class menu to all titled players - for #6524

pull/6529/head
Thibault Duplessis 2020-05-01 13:13:01 -06:00
parent 3ab230e1f2
commit 13e1927bde
3 changed files with 5 additions and 7 deletions

View File

@ -12,7 +12,7 @@ object topnav {
if (ctx.blind) h3(name) else a(href := url)(name)
private def canSeeClasMenu(implicit ctx: Context) =
ctx.hasClas || ctx.me.exists(_.roles contains "ROLE_COACH")
ctx.hasClas || ctx.me.exists(u => u.hasTitle || u.roles.contains("ROLE_COACH"))
def apply()(implicit ctx: Context) = st.nav(id := "topnav", cls := "hover")(
st.section(

View File

@ -30,8 +30,6 @@ final class TeamApi(
import BSONHandlers._
val creationPeriod = Period weeks 1
def team(id: Team.ID) = teamRepo.coll.byId[Team](id)
def light(id: Team.ID) = teamRepo.coll.byId[LightTeam](id, $doc("name" -> true))
@ -81,8 +79,8 @@ final class TeamApi(
def hasTeams(me: User): Fu[Boolean] = cached.teamIds(me.id).map(_.value.nonEmpty)
def hasCreatedRecently(me: User): Fu[Boolean] =
teamRepo.userHasCreatedSince(me.id, creationPeriod)
def countCreatedRecently(me: User): Fu[Int] =
teamRepo.countCreatedSince(me.id, Period weeks 1)
def requestsWithUsers(team: Team): Fu[List[RequestWithUser]] =
for {

View File

@ -53,8 +53,8 @@ final class TeamRepo(val coll: Coll)(implicit ec: scala.concurrent.ExecutionCont
def name(id: String): Fu[Option[String]] =
coll.primitiveOne[String]($id(id), "name")
def userHasCreatedSince(userId: String, duration: Period): Fu[Boolean] =
coll.exists(
private[team] def countCreatedSince(userId: String, duration: Period): Fu[Int] =
coll.countSel(
$doc(
"createdAt" $gt DateTime.now.minus(duration),
"createdBy" -> userId