parent
027582fe0e
commit
6f3eb509bc
|
@ -89,7 +89,6 @@ object form {
|
|||
}
|
||||
|
||||
private def textFields(form: Form[_])(implicit ctx: Context) = frag(
|
||||
form3.group(form("location"), trans.location())(form3.input(_)),
|
||||
form3.group(form("description"), trans.description(), help = markdownAvailable.some)(
|
||||
form3.textarea(_)(rows := 10)
|
||||
),
|
||||
|
@ -114,7 +113,7 @@ object form {
|
|||
half = true
|
||||
),
|
||||
form3.split(
|
||||
form3.group(form("chat"), frag("Team chat")) { f =>
|
||||
form3.group(form("chat"), frag("Team chat"), help = frag("Who can use the team chat?").some) { f =>
|
||||
form3.select(
|
||||
f,
|
||||
Seq(
|
||||
|
@ -124,7 +123,17 @@ object form {
|
|||
)
|
||||
)
|
||||
},
|
||||
form3.group(form("forum"), frag("Team forum")) { f =>
|
||||
form3.group(
|
||||
form("forum"),
|
||||
frag("Team forum"),
|
||||
help = frag(
|
||||
"Who can see the team forum on the team page?",
|
||||
br,
|
||||
"Note that the forum remains accessible through direct URL access or forum search.",
|
||||
br,
|
||||
"Only team members can post in the team forum."
|
||||
).some
|
||||
) { f =>
|
||||
form3.select(
|
||||
f,
|
||||
Seq(
|
||||
|
|
|
@ -186,9 +186,6 @@ object show {
|
|||
st.section(cls := "team-show__desc")(
|
||||
markdown {
|
||||
t.descPrivate.ifTrue(info.mine) | t.description
|
||||
},
|
||||
t.location.map { loc =>
|
||||
frag(br, trans.location(), ": ", richText(loc))
|
||||
}
|
||||
),
|
||||
t.enabled && info.hasRequests option div(cls := "team-show__requests")(
|
||||
|
|
|
@ -17,6 +17,5 @@ final class JsonView(lightUserApi: LightUserApi) {
|
|||
"leaders" -> team.leaders.flatMap(lightUserApi.sync),
|
||||
"nbMembers" -> team.nbMembers
|
||||
)
|
||||
.add("location" -> team.location)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.joda.time.Days
|
|||
case class Team(
|
||||
_id: Team.ID, // also the url slug
|
||||
name: String,
|
||||
location: Option[String],
|
||||
password: Option[String],
|
||||
description: String,
|
||||
descPrivate: Option[String],
|
||||
|
@ -94,7 +93,6 @@ object Team {
|
|||
def make(
|
||||
id: String,
|
||||
name: String,
|
||||
location: Option[String],
|
||||
password: Option[String],
|
||||
description: String,
|
||||
descPrivate: Option[String],
|
||||
|
@ -104,7 +102,6 @@ object Team {
|
|||
new Team(
|
||||
_id = id,
|
||||
name = name,
|
||||
location = location,
|
||||
password = password,
|
||||
description = description,
|
||||
descPrivate = descPrivate,
|
||||
|
|
|
@ -43,20 +43,18 @@ final class TeamApi(
|
|||
def request(id: Team.ID) = requestRepo.coll.byId[Request](id)
|
||||
|
||||
def create(setup: TeamSetup, me: User): Fu[Team] = {
|
||||
val s = setup.trim
|
||||
val bestId = Team.nameToId(s.name)
|
||||
val bestId = Team.nameToId(setup.name)
|
||||
chatApi.exists(bestId) map {
|
||||
case true => Team.randomId()
|
||||
case false => bestId
|
||||
} flatMap { id =>
|
||||
val team = Team.make(
|
||||
id = id,
|
||||
name = s.name,
|
||||
location = s.location,
|
||||
password = s.password,
|
||||
description = s.description,
|
||||
descPrivate = s.descPrivate,
|
||||
open = s.isOpen,
|
||||
name = setup.name,
|
||||
password = setup.password,
|
||||
description = setup.description,
|
||||
descPrivate = setup.descPrivate.filter(_.nonEmpty),
|
||||
open = setup.isOpen,
|
||||
createdBy = me
|
||||
)
|
||||
teamRepo.coll.insert.one(team) >>
|
||||
|
@ -72,23 +70,20 @@ final class TeamApi(
|
|||
}
|
||||
|
||||
def update(team: Team, edit: TeamEdit, me: User): Funit =
|
||||
edit.trim pipe { e =>
|
||||
team.copy(
|
||||
location = e.location,
|
||||
password = e.password,
|
||||
description = e.description,
|
||||
descPrivate = e.descPrivate,
|
||||
open = e.isOpen,
|
||||
chat = e.chat,
|
||||
forum = e.forum,
|
||||
hideMembers = Some(e.hideMembers)
|
||||
) pipe { team =>
|
||||
teamRepo.coll.update.one($id(team.id), team).void >>
|
||||
!team.leaders(me.id) ?? {
|
||||
modLog.teamEdit(me.id, team.createdBy, team.name)
|
||||
} >>-
|
||||
(indexer ! InsertTeam(team))
|
||||
}
|
||||
team.copy(
|
||||
password = edit.password,
|
||||
description = edit.description,
|
||||
descPrivate = edit.descPrivate,
|
||||
open = edit.isOpen,
|
||||
chat = edit.chat,
|
||||
forum = edit.forum,
|
||||
hideMembers = Some(edit.hideMembers)
|
||||
) pipe { team =>
|
||||
teamRepo.coll.update.one($id(team.id), team).void >>
|
||||
!team.leaders(me.id) ?? {
|
||||
modLog.teamEdit(me.id, team.createdBy, team.name)
|
||||
} >>-
|
||||
(indexer ! InsertTeam(team))
|
||||
}
|
||||
|
||||
def mine(me: User): Fu[List[Team]] =
|
||||
|
|
|
@ -16,7 +16,6 @@ final private[team] class TeamForm(
|
|||
|
||||
private object Fields {
|
||||
val name = "name" -> cleanText(minLength = 3, maxLength = 60).verifying(mustNotContainLichess(false))
|
||||
val location = "location" -> optional(cleanText(minLength = 3, maxLength = 80))
|
||||
val password = "password" -> optional(cleanText(maxLength = 60))
|
||||
def passwordCheck(team: Team) = "password" -> optional(text).verifying(
|
||||
"team:incorrectEntryCode",
|
||||
|
@ -38,7 +37,6 @@ final private[team] class TeamForm(
|
|||
val create = Form(
|
||||
mapping(
|
||||
Fields.name,
|
||||
Fields.location,
|
||||
Fields.password,
|
||||
Fields.description,
|
||||
Fields.descPrivate,
|
||||
|
@ -53,7 +51,6 @@ final private[team] class TeamForm(
|
|||
def edit(team: Team) =
|
||||
Form(
|
||||
mapping(
|
||||
Fields.location,
|
||||
Fields.password,
|
||||
Fields.description,
|
||||
Fields.descPrivate,
|
||||
|
@ -63,7 +60,6 @@ final private[team] class TeamForm(
|
|||
Fields.hideMembers
|
||||
)(TeamEdit.apply)(TeamEdit.unapply)
|
||||
) fill TeamEdit(
|
||||
location = team.location,
|
||||
password = team.password,
|
||||
description = team.description,
|
||||
descPrivate = team.descPrivate,
|
||||
|
@ -120,12 +116,11 @@ final private[team] class TeamForm(
|
|||
)
|
||||
|
||||
private def teamExists(setup: TeamSetup) =
|
||||
teamRepo.coll.exists($id(Team nameToId setup.trim.name))
|
||||
teamRepo.coll.exists($id(Team nameToId setup.name))
|
||||
}
|
||||
|
||||
private[team] case class TeamSetup(
|
||||
name: String,
|
||||
location: Option[String],
|
||||
password: Option[String],
|
||||
description: String,
|
||||
descPrivate: Option[String],
|
||||
|
@ -133,20 +128,10 @@ private[team] case class TeamSetup(
|
|||
gameId: String,
|
||||
move: String
|
||||
) {
|
||||
|
||||
def isOpen = !request
|
||||
|
||||
def trim =
|
||||
copy(
|
||||
name = name.trim,
|
||||
location = location map (_.trim) filter (_.nonEmpty),
|
||||
description = description.trim,
|
||||
descPrivate = descPrivate map (_.trim) filter (_.nonEmpty)
|
||||
)
|
||||
}
|
||||
|
||||
private[team] case class TeamEdit(
|
||||
location: Option[String],
|
||||
password: Option[String],
|
||||
description: String,
|
||||
descPrivate: Option[String],
|
||||
|
@ -160,9 +145,8 @@ private[team] case class TeamEdit(
|
|||
|
||||
def trim =
|
||||
copy(
|
||||
location = location map (_.trim) filter (_.nonEmpty),
|
||||
description = description.trim,
|
||||
descPrivate = descPrivate map (_.trim) filter (_.nonEmpty)
|
||||
description = description,
|
||||
descPrivate = descPrivate.filter(_.nonEmpty)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ final class TeamSearchApi(
|
|||
Json.obj(
|
||||
Fields.name -> team.name,
|
||||
Fields.description -> team.description.take(10000),
|
||||
Fields.location -> team.location,
|
||||
Fields.nbMembers -> team.nbMembers
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue