remove team.location and finalize team.forum config

closes #9652
team-forum-field
Thibault Duplessis 2021-08-27 10:34:46 +02:00
parent 027582fe0e
commit 6f3eb509bc
7 changed files with 35 additions and 55 deletions

View File

@ -89,7 +89,6 @@ object form {
} }
private def textFields(form: Form[_])(implicit ctx: Context) = frag( 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.group(form("description"), trans.description(), help = markdownAvailable.some)(
form3.textarea(_)(rows := 10) form3.textarea(_)(rows := 10)
), ),
@ -114,7 +113,7 @@ object form {
half = true half = true
), ),
form3.split( 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( form3.select(
f, f,
Seq( 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( form3.select(
f, f,
Seq( Seq(

View File

@ -186,9 +186,6 @@ object show {
st.section(cls := "team-show__desc")( st.section(cls := "team-show__desc")(
markdown { markdown {
t.descPrivate.ifTrue(info.mine) | t.description 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")( t.enabled && info.hasRequests option div(cls := "team-show__requests")(

View File

@ -17,6 +17,5 @@ final class JsonView(lightUserApi: LightUserApi) {
"leaders" -> team.leaders.flatMap(lightUserApi.sync), "leaders" -> team.leaders.flatMap(lightUserApi.sync),
"nbMembers" -> team.nbMembers "nbMembers" -> team.nbMembers
) )
.add("location" -> team.location)
} }
} }

View File

@ -9,7 +9,6 @@ import org.joda.time.Days
case class Team( case class Team(
_id: Team.ID, // also the url slug _id: Team.ID, // also the url slug
name: String, name: String,
location: Option[String],
password: Option[String], password: Option[String],
description: String, description: String,
descPrivate: Option[String], descPrivate: Option[String],
@ -94,7 +93,6 @@ object Team {
def make( def make(
id: String, id: String,
name: String, name: String,
location: Option[String],
password: Option[String], password: Option[String],
description: String, description: String,
descPrivate: Option[String], descPrivate: Option[String],
@ -104,7 +102,6 @@ object Team {
new Team( new Team(
_id = id, _id = id,
name = name, name = name,
location = location,
password = password, password = password,
description = description, description = description,
descPrivate = descPrivate, descPrivate = descPrivate,

View File

@ -43,20 +43,18 @@ final class TeamApi(
def request(id: Team.ID) = requestRepo.coll.byId[Request](id) def request(id: Team.ID) = requestRepo.coll.byId[Request](id)
def create(setup: TeamSetup, me: User): Fu[Team] = { def create(setup: TeamSetup, me: User): Fu[Team] = {
val s = setup.trim val bestId = Team.nameToId(setup.name)
val bestId = Team.nameToId(s.name)
chatApi.exists(bestId) map { chatApi.exists(bestId) map {
case true => Team.randomId() case true => Team.randomId()
case false => bestId case false => bestId
} flatMap { id => } flatMap { id =>
val team = Team.make( val team = Team.make(
id = id, id = id,
name = s.name, name = setup.name,
location = s.location, password = setup.password,
password = s.password, description = setup.description,
description = s.description, descPrivate = setup.descPrivate.filter(_.nonEmpty),
descPrivate = s.descPrivate, open = setup.isOpen,
open = s.isOpen,
createdBy = me createdBy = me
) )
teamRepo.coll.insert.one(team) >> teamRepo.coll.insert.one(team) >>
@ -72,23 +70,20 @@ final class TeamApi(
} }
def update(team: Team, edit: TeamEdit, me: User): Funit = def update(team: Team, edit: TeamEdit, me: User): Funit =
edit.trim pipe { e => team.copy(
team.copy( password = edit.password,
location = e.location, description = edit.description,
password = e.password, descPrivate = edit.descPrivate,
description = e.description, open = edit.isOpen,
descPrivate = e.descPrivate, chat = edit.chat,
open = e.isOpen, forum = edit.forum,
chat = e.chat, hideMembers = Some(edit.hideMembers)
forum = e.forum, ) pipe { team =>
hideMembers = Some(e.hideMembers) teamRepo.coll.update.one($id(team.id), team).void >>
) pipe { team => !team.leaders(me.id) ?? {
teamRepo.coll.update.one($id(team.id), team).void >> modLog.teamEdit(me.id, team.createdBy, team.name)
!team.leaders(me.id) ?? { } >>-
modLog.teamEdit(me.id, team.createdBy, team.name) (indexer ! InsertTeam(team))
} >>-
(indexer ! InsertTeam(team))
}
} }
def mine(me: User): Fu[List[Team]] = def mine(me: User): Fu[List[Team]] =

View File

@ -16,7 +16,6 @@ final private[team] class TeamForm(
private object Fields { private object Fields {
val name = "name" -> cleanText(minLength = 3, maxLength = 60).verifying(mustNotContainLichess(false)) 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)) val password = "password" -> optional(cleanText(maxLength = 60))
def passwordCheck(team: Team) = "password" -> optional(text).verifying( def passwordCheck(team: Team) = "password" -> optional(text).verifying(
"team:incorrectEntryCode", "team:incorrectEntryCode",
@ -38,7 +37,6 @@ final private[team] class TeamForm(
val create = Form( val create = Form(
mapping( mapping(
Fields.name, Fields.name,
Fields.location,
Fields.password, Fields.password,
Fields.description, Fields.description,
Fields.descPrivate, Fields.descPrivate,
@ -53,7 +51,6 @@ final private[team] class TeamForm(
def edit(team: Team) = def edit(team: Team) =
Form( Form(
mapping( mapping(
Fields.location,
Fields.password, Fields.password,
Fields.description, Fields.description,
Fields.descPrivate, Fields.descPrivate,
@ -63,7 +60,6 @@ final private[team] class TeamForm(
Fields.hideMembers Fields.hideMembers
)(TeamEdit.apply)(TeamEdit.unapply) )(TeamEdit.apply)(TeamEdit.unapply)
) fill TeamEdit( ) fill TeamEdit(
location = team.location,
password = team.password, password = team.password,
description = team.description, description = team.description,
descPrivate = team.descPrivate, descPrivate = team.descPrivate,
@ -120,12 +116,11 @@ final private[team] class TeamForm(
) )
private def teamExists(setup: TeamSetup) = 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( private[team] case class TeamSetup(
name: String, name: String,
location: Option[String],
password: Option[String], password: Option[String],
description: String, description: String,
descPrivate: Option[String], descPrivate: Option[String],
@ -133,20 +128,10 @@ private[team] case class TeamSetup(
gameId: String, gameId: String,
move: String move: String
) { ) {
def isOpen = !request 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( private[team] case class TeamEdit(
location: Option[String],
password: Option[String], password: Option[String],
description: String, description: String,
descPrivate: Option[String], descPrivate: Option[String],
@ -160,9 +145,8 @@ private[team] case class TeamEdit(
def trim = def trim =
copy( copy(
location = location map (_.trim) filter (_.nonEmpty), description = description,
description = description.trim, descPrivate = descPrivate.filter(_.nonEmpty)
descPrivate = descPrivate map (_.trim) filter (_.nonEmpty)
) )
} }

View File

@ -27,7 +27,6 @@ final class TeamSearchApi(
Json.obj( Json.obj(
Fields.name -> team.name, Fields.name -> team.name,
Fields.description -> team.description.take(10000), Fields.description -> team.description.take(10000),
Fields.location -> team.location,
Fields.nbMembers -> team.nbMembers Fields.nbMembers -> team.nbMembers
) )