rename all DataForm
parent
a51f6b7f72
commit
0ba2c7cafd
|
@ -6,7 +6,7 @@ import scala.annotation.nowarn
|
||||||
|
|
||||||
import lila.api.Context
|
import lila.api.Context
|
||||||
import lila.app._
|
import lila.app._
|
||||||
import lila.security.DataForm.Reopen
|
import lila.security.SecurityForm.Reopen
|
||||||
import lila.user.{ User => UserModel, TotpSecret }
|
import lila.user.{ User => UserModel, TotpSecret }
|
||||||
import views.html
|
import views.html
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import scala.util.Try
|
||||||
import lila.api.Context
|
import lila.api.Context
|
||||||
import lila.app._
|
import lila.app._
|
||||||
import lila.common.{ EmailAddress, HTTPRequest }
|
import lila.common.{ EmailAddress, HTTPRequest }
|
||||||
import lila.security.DataForm.{ MagicLink, PasswordReset }
|
import lila.security.SecurityForm.{ MagicLink, PasswordReset }
|
||||||
import lila.security.{ FingerPrint, Signup }
|
import lila.security.{ FingerPrint, Signup }
|
||||||
import lila.user.{ User => UserModel, PasswordHasher }
|
import lila.user.{ User => UserModel, PasswordHasher }
|
||||||
import UserModel.ClearPassword
|
import UserModel.ClearPassword
|
||||||
|
|
|
@ -189,7 +189,7 @@ final class Challenge(
|
||||||
if (isMine(c))
|
if (isMine(c))
|
||||||
Form(
|
Form(
|
||||||
single(
|
single(
|
||||||
"username" -> lila.user.DataForm.historicalUsernameField
|
"username" -> lila.user.UserForm.historicalUsernameField
|
||||||
)
|
)
|
||||||
).bindFromRequest()
|
).bindFromRequest()
|
||||||
.fold(
|
.fold(
|
||||||
|
|
|
@ -168,7 +168,7 @@ final class Mod(
|
||||||
def setTitle(username: String) =
|
def setTitle(username: String) =
|
||||||
SecureBody(_.SetTitle) { implicit ctx => me =>
|
SecureBody(_.SetTitle) { implicit ctx => me =>
|
||||||
implicit def req = ctx.body
|
implicit def req = ctx.body
|
||||||
lila.user.DataForm.title
|
lila.user.UserForm.title
|
||||||
.bindFromRequest()
|
.bindFromRequest()
|
||||||
.fold(
|
.fold(
|
||||||
_ => fuccess(redirect(username, mod = true)),
|
_ => fuccess(redirect(username, mod = true)),
|
||||||
|
|
|
@ -199,7 +199,7 @@ final class Plan(env: Env)(implicit system: akka.actor.ActorSystem) extends Lila
|
||||||
def payPalIpn =
|
def payPalIpn =
|
||||||
Action.async { implicit req =>
|
Action.async { implicit req =>
|
||||||
import lila.plan.Patron.PayPal
|
import lila.plan.Patron.PayPal
|
||||||
lila.plan.DataForm.ipn
|
lila.plan.PlanForm.ipn
|
||||||
.bindFromRequest()
|
.bindFromRequest()
|
||||||
.fold(
|
.fold(
|
||||||
err => {
|
err => {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import views._
|
||||||
final class Pref(env: Env) extends LilaController(env) {
|
final class Pref(env: Env) extends LilaController(env) {
|
||||||
|
|
||||||
private def api = env.pref.api
|
private def api = env.pref.api
|
||||||
private def forms = lila.pref.DataForm
|
private def forms = lila.pref.PrefForm
|
||||||
|
|
||||||
def apiGet =
|
def apiGet =
|
||||||
Scoped(_.Preference.Read) { _ => me =>
|
Scoped(_.Preference.Read) { _ => me =>
|
||||||
|
@ -33,7 +33,7 @@ final class Pref(env: Env) extends LilaController(env) {
|
||||||
|
|
||||||
def formApply =
|
def formApply =
|
||||||
AuthBody { implicit ctx => _ =>
|
AuthBody { implicit ctx => _ =>
|
||||||
def onSuccess(data: lila.pref.DataForm.PrefData) = api.setPref(data(ctx.pref)) inject Ok("saved")
|
def onSuccess(data: lila.pref.PrefForm.PrefData) = api.setPref(data(ctx.pref)) inject Ok("saved")
|
||||||
implicit val req = ctx.body
|
implicit val req = ctx.body
|
||||||
forms.pref
|
forms.pref
|
||||||
.bindFromRequest()
|
.bindFromRequest()
|
||||||
|
|
|
@ -266,7 +266,7 @@ final class Study(
|
||||||
def createAs =
|
def createAs =
|
||||||
AuthBody { implicit ctx => me =>
|
AuthBody { implicit ctx => me =>
|
||||||
implicit val req = ctx.body
|
implicit val req = ctx.body
|
||||||
lila.study.DataForm.importGame.form
|
lila.study.StudyForm.importGame.form
|
||||||
.bindFromRequest()
|
.bindFromRequest()
|
||||||
.fold(
|
.fold(
|
||||||
_ => Redirect(routes.Study.byOwnerDefault(me.username)).fuccess,
|
_ => Redirect(routes.Study.byOwnerDefault(me.username)).fuccess,
|
||||||
|
@ -284,7 +284,7 @@ final class Study(
|
||||||
def create =
|
def create =
|
||||||
AuthBody { implicit ctx => me =>
|
AuthBody { implicit ctx => me =>
|
||||||
implicit val req = ctx.body
|
implicit val req = ctx.body
|
||||||
lila.study.DataForm.importGame.form
|
lila.study.StudyForm.importGame.form
|
||||||
.bindFromRequest()
|
.bindFromRequest()
|
||||||
.fold(
|
.fold(
|
||||||
_ => Redirect(routes.Study.byOwnerDefault(me.username)).fuccess,
|
_ => Redirect(routes.Study.byOwnerDefault(me.username)).fuccess,
|
||||||
|
@ -292,7 +292,7 @@ final class Study(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private def createStudy(data: lila.study.DataForm.importGame.Data, me: lila.user.User)(implicit
|
private def createStudy(data: lila.study.StudyForm.importGame.Data, me: lila.user.User)(implicit
|
||||||
ctx: Context
|
ctx: Context
|
||||||
) =
|
) =
|
||||||
env.study.api.importGame(lila.study.StudyMaker.ImportGame(data), me) flatMap {
|
env.study.api.importGame(lila.study.StudyMaker.ImportGame(data), me) flatMap {
|
||||||
|
@ -319,7 +319,7 @@ final class Study(
|
||||||
AuthBody { implicit ctx => me =>
|
AuthBody { implicit ctx => me =>
|
||||||
implicit val req = ctx.body
|
implicit val req = ctx.body
|
||||||
get("sri") ?? { sri =>
|
get("sri") ?? { sri =>
|
||||||
lila.study.DataForm.importPgn.form
|
lila.study.StudyForm.importPgn.form
|
||||||
.bindFromRequest()
|
.bindFromRequest()
|
||||||
.fold(
|
.fold(
|
||||||
jsonFormError,
|
jsonFormError,
|
||||||
|
@ -507,7 +507,7 @@ final class Study(
|
||||||
env.study.topicApi.popular(50) zip
|
env.study.topicApi.popular(50) zip
|
||||||
ctx.me.??(u => env.study.topicApi.userTopics(u.id) dmap some) map {
|
ctx.me.??(u => env.study.topicApi.userTopics(u.id) dmap some) map {
|
||||||
case (popular, mine) =>
|
case (popular, mine) =>
|
||||||
val form = mine map lila.study.DataForm.topicsForm
|
val form = mine map lila.study.StudyForm.topicsForm
|
||||||
Ok(html.study.topic.index(popular, mine, form))
|
Ok(html.study.topic.index(popular, mine, form))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -515,7 +515,7 @@ final class Study(
|
||||||
def setTopics =
|
def setTopics =
|
||||||
AuthBody { implicit ctx => me =>
|
AuthBody { implicit ctx => me =>
|
||||||
implicit val req = ctx.body
|
implicit val req = ctx.body
|
||||||
lila.study.DataForm.topicsForm
|
lila.study.StudyForm.topicsForm
|
||||||
.bindFromRequest()
|
.bindFromRequest()
|
||||||
.fold(
|
.fold(
|
||||||
_ => Redirect(routes.Study.topics()).fuccess,
|
_ => Redirect(routes.Study.topics()).fuccess,
|
||||||
|
|
|
@ -13,7 +13,7 @@ object create {
|
||||||
submitButton(name := "as", value := s.id.value, cls := "submit button")(s.name.value)
|
submitButton(name := "as", value := s.id.value, cls := "submit button")(s.name.value)
|
||||||
|
|
||||||
def apply(
|
def apply(
|
||||||
data: lila.study.DataForm.importGame.Data,
|
data: lila.study.StudyForm.importGame.Data,
|
||||||
owner: List[Study.IdName],
|
owner: List[Study.IdName],
|
||||||
contrib: List[Study.IdName]
|
contrib: List[Study.IdName]
|
||||||
)(implicit ctx: Context) =
|
)(implicit ctx: Context) =
|
||||||
|
|
|
@ -5,7 +5,7 @@ import play.api.data.Form
|
||||||
import controllers.routes
|
import controllers.routes
|
||||||
import lila.api.Context
|
import lila.api.Context
|
||||||
import lila.app.templating.Environment._
|
import lila.app.templating.Environment._
|
||||||
import lila.tournament.{ DataForm => TourForm }
|
import lila.tournament.TournamentForm
|
||||||
import lila.swiss.{ Swiss, SwissForm }
|
import lila.swiss.{ Swiss, SwissForm }
|
||||||
import lila.app.ui.ScalatagsTemplate._
|
import lila.app.ui.ScalatagsTemplate._
|
||||||
import lila.hub.LightTeam.TeamID
|
import lila.hub.LightTeam.TeamID
|
||||||
|
@ -134,7 +134,7 @@ final private class SwissFields(form: Form[_])(implicit ctx: Context) {
|
||||||
form3.select(_, SwissForm.clockLimitChoices)
|
form3.select(_, SwissForm.clockLimitChoices)
|
||||||
),
|
),
|
||||||
form3.group(form("clock.increment"), trans.clockIncrement(), half = true)(
|
form3.group(form("clock.increment"), trans.clockIncrement(), half = true)(
|
||||||
form3.select(_, TourForm.clockIncrementChoices)
|
form3.select(_, TournamentForm.clockIncrementChoices)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
def roundInterval =
|
def roundInterval =
|
||||||
|
|
|
@ -8,7 +8,7 @@ import lila.app.templating.Environment._
|
||||||
import lila.app.ui.ScalatagsTemplate._
|
import lila.app.ui.ScalatagsTemplate._
|
||||||
import lila.common.paginator.Paginator
|
import lila.common.paginator.Paginator
|
||||||
import lila.tournament.crud.CrudForm
|
import lila.tournament.crud.CrudForm
|
||||||
import lila.tournament.{ DataForm, Tournament }
|
import lila.tournament.{ TournamentForm, Tournament }
|
||||||
|
|
||||||
import controllers.routes
|
import controllers.routes
|
||||||
|
|
||||||
|
@ -104,10 +104,10 @@ object crud {
|
||||||
),
|
),
|
||||||
form3.split(
|
form3.split(
|
||||||
form3.group(form("clockTime"), raw("Clock time"), half = true)(
|
form3.group(form("clockTime"), raw("Clock time"), half = true)(
|
||||||
form3.select(_, DataForm.clockTimeChoices)
|
form3.select(_, TournamentForm.clockTimeChoices)
|
||||||
),
|
),
|
||||||
form3.group(form("clockIncrement"), raw("Clock increment"), half = true)(
|
form3.group(form("clockIncrement"), raw("Clock increment"), half = true)(
|
||||||
form3.select(_, DataForm.clockIncrementChoices)
|
form3.select(_, TournamentForm.clockIncrementChoices)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
form3.split(
|
form3.split(
|
||||||
|
|
|
@ -8,7 +8,7 @@ import lila.api.Context
|
||||||
import lila.app.templating.Environment._
|
import lila.app.templating.Environment._
|
||||||
import lila.app.ui.ScalatagsTemplate._
|
import lila.app.ui.ScalatagsTemplate._
|
||||||
import lila.hub.LeaderTeam
|
import lila.hub.LeaderTeam
|
||||||
import lila.tournament.{ Condition, DataForm, Tournament }
|
import lila.tournament.{ Condition, TournamentForm, Tournament }
|
||||||
|
|
||||||
object form {
|
object form {
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ object form {
|
||||||
fields.startPosition,
|
fields.startPosition,
|
||||||
fields.clock,
|
fields.clock,
|
||||||
form3.split(
|
form3.split(
|
||||||
if (DataForm.minutes contains tour.minutes) form3.split(fields.minutes)
|
if (TournamentForm.minutes contains tour.minutes) form3.split(fields.minutes)
|
||||||
else
|
else
|
||||||
form3.group(form("minutes"), trans.duration(), half = true)(
|
form3.group(form("minutes"), trans.duration(), half = true)(
|
||||||
form3.input(_)(tpe := "number")
|
form3.input(_)(tpe := "number")
|
||||||
|
@ -258,19 +258,19 @@ final private class TourFields(form: Form[_], tour: Option[Tournament])(implicit
|
||||||
def clock =
|
def clock =
|
||||||
form3.split(
|
form3.split(
|
||||||
form3.group(form("clockTime"), trans.clockInitialTime(), half = true)(
|
form3.group(form("clockTime"), trans.clockInitialTime(), half = true)(
|
||||||
form3.select(_, DataForm.clockTimeChoices, disabled = disabledAfterStart)
|
form3.select(_, TournamentForm.clockTimeChoices, disabled = disabledAfterStart)
|
||||||
),
|
),
|
||||||
form3.group(form("clockIncrement"), trans.clockIncrement(), half = true)(
|
form3.group(form("clockIncrement"), trans.clockIncrement(), half = true)(
|
||||||
form3.select(_, DataForm.clockIncrementChoices, disabled = disabledAfterStart)
|
form3.select(_, TournamentForm.clockIncrementChoices, disabled = disabledAfterStart)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
def minutes =
|
def minutes =
|
||||||
form3.group(form("minutes"), trans.duration(), half = true)(
|
form3.group(form("minutes"), trans.duration(), half = true)(
|
||||||
form3.select(_, DataForm.minuteChoices)
|
form3.select(_, TournamentForm.minuteChoices)
|
||||||
)
|
)
|
||||||
def waitMinutes =
|
def waitMinutes =
|
||||||
form3.group(form("waitMinutes"), trans.timeBeforeTournamentStarts(), half = true)(
|
form3.group(form("waitMinutes"), trans.timeBeforeTournamentStarts(), half = true)(
|
||||||
form3.select(_, DataForm.waitMinuteChoices)
|
form3.select(_, TournamentForm.waitMinuteChoices)
|
||||||
)
|
)
|
||||||
def description =
|
def description =
|
||||||
form3.group(
|
form3.group(
|
||||||
|
|
|
@ -156,7 +156,7 @@ object mod {
|
||||||
isGranted(_.SetTitle) option {
|
isGranted(_.SetTitle) option {
|
||||||
postForm(cls := "fide_title", action := routes.Mod.setTitle(u.username))(
|
postForm(cls := "fide_title", action := routes.Mod.setTitle(u.username))(
|
||||||
form3.select(
|
form3.select(
|
||||||
lila.user.DataForm.title.fill(u.title.map(_.value))("title"),
|
lila.user.UserForm.title.fill(u.title.map(_.value))("title"),
|
||||||
lila.user.Title.acronyms.map(t => t -> t),
|
lila.user.Title.acronyms.map(t => t -> t),
|
||||||
"".some
|
"".some
|
||||||
)
|
)
|
||||||
|
|
|
@ -9,7 +9,7 @@ import lila.user.User
|
||||||
|
|
||||||
final class ClasForm(
|
final class ClasForm(
|
||||||
lightUserAsync: lila.common.LightUser.Getter,
|
lightUserAsync: lila.common.LightUser.Getter,
|
||||||
securityForms: lila.security.DataForm,
|
securityForms: lila.security.SecurityForm,
|
||||||
nameGenerator: NameGenerator
|
nameGenerator: NameGenerator
|
||||||
)(implicit ec: scala.concurrent.ExecutionContext) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ final class ClasForm(
|
||||||
def invite(c: Clas) =
|
def invite(c: Clas) =
|
||||||
Form(
|
Form(
|
||||||
mapping(
|
mapping(
|
||||||
"username" -> lila.user.DataForm.historicalUsernameField
|
"username" -> lila.user.UserForm.historicalUsernameField
|
||||||
.verifying("Unknown username", { blockingFetchUser(_).isDefined })
|
.verifying("Unknown username", { blockingFetchUser(_).isDefined })
|
||||||
.verifying("This is a teacher", u => !c.teachers.toList.contains(u.toLowerCase)),
|
.verifying("This is a teacher", u => !c.teachers.toList.contains(u.toLowerCase)),
|
||||||
"realName" -> clean(nonEmptyText)
|
"realName" -> clean(nonEmptyText)
|
||||||
|
|
|
@ -13,7 +13,7 @@ final class Env(
|
||||||
puzzleRoundRepo: lila.puzzle.RoundRepo,
|
puzzleRoundRepo: lila.puzzle.RoundRepo,
|
||||||
msgApi: lila.msg.MsgApi,
|
msgApi: lila.msg.MsgApi,
|
||||||
lightUserAsync: lila.common.LightUser.Getter,
|
lightUserAsync: lila.common.LightUser.Getter,
|
||||||
securityForms: lila.security.DataForm,
|
securityForms: lila.security.SecurityForm,
|
||||||
authenticator: lila.user.Authenticator,
|
authenticator: lila.user.Authenticator,
|
||||||
cacheApi: lila.memo.CacheApi,
|
cacheApi: lila.memo.CacheApi,
|
||||||
baseUrl: BaseUrl
|
baseUrl: BaseUrl
|
||||||
|
|
|
@ -3,7 +3,7 @@ package lila.coordinate
|
||||||
import play.api.data._
|
import play.api.data._
|
||||||
import play.api.data.Forms._
|
import play.api.data.Forms._
|
||||||
|
|
||||||
object DataForm {
|
object CoordinateForm {
|
||||||
|
|
||||||
val color = Form(
|
val color = Form(
|
||||||
single(
|
single(
|
|
@ -14,5 +14,5 @@ final class Env(
|
||||||
|
|
||||||
lazy val api = wire[CoordinateApi]
|
lazy val api = wire[CoordinateApi]
|
||||||
|
|
||||||
lazy val forms = DataForm
|
lazy val forms = CoordinateForm
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ object EventForm {
|
||||||
"startsAt" -> utcDate,
|
"startsAt" -> utcDate,
|
||||||
"finishesAt" -> utcDate,
|
"finishesAt" -> utcDate,
|
||||||
"hostedBy" -> optional {
|
"hostedBy" -> optional {
|
||||||
lila.user.DataForm.historicalUsernameField
|
lila.user.UserForm.historicalUsernameField
|
||||||
.transform[User.ID](_.toLowerCase, identity)
|
.transform[User.ID](_.toLowerCase, identity)
|
||||||
}
|
}
|
||||||
)(Data.apply)(Data.unapply)
|
)(Data.apply)(Data.unapply)
|
||||||
|
|
|
@ -61,7 +61,7 @@ final class Env(
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy val mentionNotifier: MentionNotifier = wire[MentionNotifier]
|
lazy val mentionNotifier: MentionNotifier = wire[MentionNotifier]
|
||||||
lazy val forms = wire[DataForm]
|
lazy val forms = wire[ForumForm]
|
||||||
lazy val recent = wire[Recent]
|
lazy val recent = wire[Recent]
|
||||||
|
|
||||||
lila.common.Bus.subscribeFun("team", "gdprErase") {
|
lila.common.Bus.subscribeFun("team", "gdprErase") {
|
||||||
|
|
|
@ -5,13 +5,13 @@ import play.api.data._
|
||||||
import play.api.data.Forms._
|
import play.api.data.Forms._
|
||||||
import lila.user.User
|
import lila.user.User
|
||||||
|
|
||||||
final private[forum] class DataForm(
|
final private[forum] class ForumForm(
|
||||||
promotion: lila.security.PromotionApi,
|
promotion: lila.security.PromotionApi,
|
||||||
val captcher: lila.hub.actors.Captcher
|
val captcher: lila.hub.actors.Captcher
|
||||||
)(implicit ec: scala.concurrent.ExecutionContext)
|
)(implicit ec: scala.concurrent.ExecutionContext)
|
||||||
extends lila.hub.CaptchedForm {
|
extends lila.hub.CaptchedForm {
|
||||||
|
|
||||||
import DataForm._
|
import ForumForm._
|
||||||
|
|
||||||
def postMapping(user: User) =
|
def postMapping(user: User) =
|
||||||
mapping(
|
mapping(
|
||||||
|
@ -49,7 +49,7 @@ final private[forum] class DataForm(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
object DataForm {
|
object ForumForm {
|
||||||
|
|
||||||
case class PostData(
|
case class PostData(
|
||||||
text: String,
|
text: String,
|
|
@ -31,7 +31,7 @@ final class PostApi(
|
||||||
def makePost(
|
def makePost(
|
||||||
categ: Categ,
|
categ: Categ,
|
||||||
topic: Topic,
|
topic: Topic,
|
||||||
data: DataForm.PostData,
|
data: ForumForm.PostData,
|
||||||
me: User
|
me: User
|
||||||
): Fu[Post] =
|
): Fu[Post] =
|
||||||
lastNumberOf(topic) flatMap { number =>
|
lastNumberOf(topic) flatMap { number =>
|
||||||
|
|
|
@ -48,7 +48,7 @@ final private[forum] class TopicApi(
|
||||||
|
|
||||||
def makeTopic(
|
def makeTopic(
|
||||||
categ: Categ,
|
categ: Categ,
|
||||||
data: DataForm.TopicData,
|
data: ForumForm.TopicData,
|
||||||
me: User
|
me: User
|
||||||
): Fu[Topic] =
|
): Fu[Topic] =
|
||||||
env.topicRepo.nextSlug(categ, data.name) zip detectLanguage(data.post.text) flatMap {
|
env.topicRepo.nextSlug(categ, data.name) zip detectLanguage(data.post.text) flatMap {
|
||||||
|
|
|
@ -34,7 +34,7 @@ final class Env(
|
||||||
|
|
||||||
lazy val paginator = wire[PaginatorBuilder[lila.game.Game, Query]]
|
lazy val paginator = wire[PaginatorBuilder[lila.game.Game, Query]]
|
||||||
|
|
||||||
lazy val forms = wire[DataForm]
|
lazy val forms = wire[GameSearchForm]
|
||||||
|
|
||||||
lazy val userGameSearch = wire[UserGameSearch]
|
lazy val userGameSearch = wire[UserGameSearch]
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import play.api.data.Forms._
|
||||||
import lila.common.Form._
|
import lila.common.Form._
|
||||||
import lila.search.Range
|
import lila.search.Range
|
||||||
|
|
||||||
final private[gameSearch] class DataForm {
|
final private[gameSearch] class GameSearchForm {
|
||||||
|
|
||||||
val search = Form(
|
val search = Form(
|
||||||
mapping(
|
mapping(
|
||||||
|
@ -39,8 +39,8 @@ final private[gameSearch] class DataForm {
|
||||||
"incMin" -> optional(numberIn(Query.clockIncs)),
|
"incMin" -> optional(numberIn(Query.clockIncs)),
|
||||||
"incMax" -> optional(numberIn(Query.clockIncs))
|
"incMax" -> optional(numberIn(Query.clockIncs))
|
||||||
)(SearchClock.apply)(SearchClock.unapply),
|
)(SearchClock.apply)(SearchClock.unapply),
|
||||||
"dateMin" -> DataForm.dateField,
|
"dateMin" -> GameSearchForm.dateField,
|
||||||
"dateMax" -> DataForm.dateField,
|
"dateMax" -> GameSearchForm.dateField,
|
||||||
"status" -> optional(numberIn(Query.statuses)),
|
"status" -> optional(numberIn(Query.statuses)),
|
||||||
"analysed" -> optional(number),
|
"analysed" -> optional(number),
|
||||||
"sort" -> optional(
|
"sort" -> optional(
|
||||||
|
@ -53,7 +53,7 @@ final private[gameSearch] class DataForm {
|
||||||
) fill SearchData()
|
) fill SearchData()
|
||||||
}
|
}
|
||||||
|
|
||||||
private[gameSearch] object DataForm {
|
private[gameSearch] object GameSearchForm {
|
||||||
val dateField = optional(ISODateOrTimestamp.isoDateOrTimestamp)
|
val dateField = optional(ISODateOrTimestamp.isoDateOrTimestamp)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import lila.game.Game
|
||||||
import play.api.mvc.Request
|
import play.api.mvc.Request
|
||||||
|
|
||||||
final class UserGameSearch(
|
final class UserGameSearch(
|
||||||
forms: DataForm,
|
forms: GameSearchForm,
|
||||||
paginator: lila.search.PaginatorBuilder[Game, Query]
|
paginator: lila.search.PaginatorBuilder[Game, Query]
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import com.softwaremill.macwire._
|
||||||
@Module
|
@Module
|
||||||
final class Env(gameRepo: lila.game.GameRepo)(implicit ec: scala.concurrent.ExecutionContext) {
|
final class Env(gameRepo: lila.game.GameRepo)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
lazy val forms = wire[DataForm]
|
lazy val forms = wire[ImporterForm]
|
||||||
|
|
||||||
lazy val importer = wire[Importer]
|
lazy val importer = wire[Importer]
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import scala.util.chaining._
|
||||||
|
|
||||||
import lila.game._
|
import lila.game._
|
||||||
|
|
||||||
final class DataForm {
|
final class ImporterForm {
|
||||||
|
|
||||||
lazy val importForm = Form(
|
lazy val importForm = Form(
|
||||||
mapping(
|
mapping(
|
|
@ -65,7 +65,7 @@ final class MsgCompat(
|
||||||
def create(me: User)(implicit req: play.api.mvc.Request[_]): Either[Form[_], Fu[User.ID]] =
|
def create(me: User)(implicit req: play.api.mvc.Request[_]): Either[Form[_], Fu[User.ID]] =
|
||||||
Form(
|
Form(
|
||||||
mapping(
|
mapping(
|
||||||
"username" -> lila.user.DataForm.historicalUsernameField
|
"username" -> lila.user.UserForm.historicalUsernameField
|
||||||
.verifying("Unknown username", { blockingFetchUser(_).isDefined })
|
.verifying("Unknown username", { blockingFetchUser(_).isDefined })
|
||||||
.verifying(
|
.verifying(
|
||||||
"Sorry, this player doesn't accept new messages",
|
"Sorry, this player doesn't accept new messages",
|
||||||
|
|
|
@ -4,7 +4,7 @@ import cats.implicits._
|
||||||
import play.api.data._
|
import play.api.data._
|
||||||
import play.api.data.Forms._
|
import play.api.data.Forms._
|
||||||
|
|
||||||
object DataForm {
|
object PlanForm {
|
||||||
|
|
||||||
private val txnTypes = Set("express_checkout", "web_accept", "recurring_payment", "subscr_payment")
|
private val txnTypes = Set("express_checkout", "web_accept", "recurring_payment", "subscr_payment")
|
||||||
// ignored types = subscr_cancel, ...
|
// ignored types = subscr_cancel, ...
|
|
@ -3,7 +3,7 @@ package lila.pref
|
||||||
import play.api.data._
|
import play.api.data._
|
||||||
import play.api.data.Forms._
|
import play.api.data.Forms._
|
||||||
|
|
||||||
object DataForm {
|
object PrefForm {
|
||||||
|
|
||||||
private def containedIn(choices: Seq[(Int, String)]): Int => Boolean =
|
private def containedIn(choices: Seq[(Int, String)]): Int => Boolean =
|
||||||
choice => choices.exists(_._1 == choice)
|
choice => choices.exists(_._1 == choice)
|
|
@ -84,7 +84,7 @@ final class Env(
|
||||||
currentPuzzleId = api.head.currentPuzzleId
|
currentPuzzleId = api.head.currentPuzzleId
|
||||||
)
|
)
|
||||||
|
|
||||||
lazy val forms = DataForm
|
lazy val forms = PuzzleForm
|
||||||
|
|
||||||
lazy val daily = new Daily(
|
lazy val daily = new Daily(
|
||||||
puzzleColl,
|
puzzleColl,
|
||||||
|
|
|
@ -3,7 +3,7 @@ package lila.puzzle
|
||||||
import play.api.data._
|
import play.api.data._
|
||||||
import play.api.data.Forms._
|
import play.api.data.Forms._
|
||||||
|
|
||||||
object DataForm {
|
object PuzzleForm {
|
||||||
|
|
||||||
val round = Form(
|
val round = Form(
|
||||||
single(
|
single(
|
|
@ -60,7 +60,7 @@ final class Env(
|
||||||
slack = slackScoreThresholdSetting.get _
|
slack = slackScoreThresholdSetting.get _
|
||||||
)
|
)
|
||||||
|
|
||||||
lazy val forms = wire[DataForm]
|
lazy val forms = wire[ReportForm]
|
||||||
|
|
||||||
private lazy val autoAnalysis = wire[AutoAnalysis]
|
private lazy val autoAnalysis = wire[AutoAnalysis]
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import scala.concurrent.duration._
|
||||||
import lila.common.LightUser
|
import lila.common.LightUser
|
||||||
import lila.user.User
|
import lila.user.User
|
||||||
|
|
||||||
final private[report] class DataForm(
|
final private[report] class ReportForm(
|
||||||
lightUserAsync: LightUser.Getter,
|
lightUserAsync: LightUser.Getter,
|
||||||
val captcher: lila.hub.actors.Captcher,
|
val captcher: lila.hub.actors.Captcher,
|
||||||
domain: lila.common.config.NetDomain
|
domain: lila.common.config.NetDomain
|
||||||
|
@ -23,7 +23,7 @@ final private[report] class DataForm(
|
||||||
|
|
||||||
val create = Form(
|
val create = Form(
|
||||||
mapping(
|
mapping(
|
||||||
"username" -> lila.user.DataForm.historicalUsernameField.verifying(
|
"username" -> lila.user.UserForm.historicalUsernameField.verifying(
|
||||||
"Unknown username", {
|
"Unknown username", {
|
||||||
blockingFetchUser(_).isDefined
|
blockingFetchUser(_).isDefined
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ final private[report] class DataForm(
|
||||||
|
|
||||||
val flag = Form(
|
val flag = Form(
|
||||||
mapping(
|
mapping(
|
||||||
"username" -> lila.user.DataForm.historicalUsernameField,
|
"username" -> lila.user.UserForm.historicalUsernameField,
|
||||||
"resource" -> nonEmptyText,
|
"resource" -> nonEmptyText,
|
||||||
"text" -> text(minLength = 3, maxLength = 140)
|
"text" -> text(minLength = 3, maxLength = 140)
|
||||||
)(ReportFlag.apply)(ReportFlag.unapply)
|
)(ReportFlag.apply)(ReportFlag.unapply)
|
|
@ -52,7 +52,7 @@ final class Env(
|
||||||
if (config.recaptcha.enabled) wire[RecaptchaGoogle]
|
if (config.recaptcha.enabled) wire[RecaptchaGoogle]
|
||||||
else RecaptchaSkip
|
else RecaptchaSkip
|
||||||
|
|
||||||
lazy val forms = wire[DataForm]
|
lazy val forms = wire[SecurityForm]
|
||||||
|
|
||||||
lazy val geoIP: GeoIP = wire[GeoIP]
|
lazy val geoIP: GeoIP = wire[GeoIP]
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import lila.common.{ EmailAddress, LameName, Form => LilaForm }
|
||||||
import lila.user.{ TotpSecret, User, UserRepo }
|
import lila.user.{ TotpSecret, User, UserRepo }
|
||||||
import User.{ ClearPassword, TotpToken }
|
import User.{ ClearPassword, TotpToken }
|
||||||
|
|
||||||
final class DataForm(
|
final class SecurityForm(
|
||||||
userRepo: UserRepo,
|
userRepo: UserRepo,
|
||||||
authenticator: lila.user.Authenticator,
|
authenticator: lila.user.Authenticator,
|
||||||
emailValidator: EmailAddressValidator,
|
emailValidator: EmailAddressValidator,
|
||||||
|
@ -17,7 +17,7 @@ final class DataForm(
|
||||||
recaptchaPublicConfig: RecaptchaPublicConfig
|
recaptchaPublicConfig: RecaptchaPublicConfig
|
||||||
)(implicit ec: scala.concurrent.ExecutionContext) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
import DataForm._
|
import SecurityForm._
|
||||||
|
|
||||||
private val recaptchaField = "g-recaptcha-response" -> optional(nonEmptyText)
|
private val recaptchaField = "g-recaptcha-response" -> optional(nonEmptyText)
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ final class DataForm(
|
||||||
text.verifying("incorrectPassword", p => candidate.check(ClearPassword(p)))
|
text.verifying("incorrectPassword", p => candidate.check(ClearPassword(p)))
|
||||||
}
|
}
|
||||||
|
|
||||||
object DataForm {
|
object SecurityForm {
|
||||||
|
|
||||||
case class AgreementData(
|
case class AgreementData(
|
||||||
assistance: Boolean,
|
assistance: Boolean,
|
|
@ -15,7 +15,7 @@ final class Signup(
|
||||||
store: Store,
|
store: Store,
|
||||||
api: SecurityApi,
|
api: SecurityApi,
|
||||||
ipTrust: IpTrust,
|
ipTrust: IpTrust,
|
||||||
forms: DataForm,
|
forms: SecurityForm,
|
||||||
emailAddressValidator: EmailAddressValidator,
|
emailAddressValidator: EmailAddressValidator,
|
||||||
emailConfirm: EmailConfirm,
|
emailConfirm: EmailConfirm,
|
||||||
recaptcha: Recaptcha,
|
recaptcha: Recaptcha,
|
||||||
|
|
|
@ -104,14 +104,14 @@ final class StudyApi(
|
||||||
|
|
||||||
def importGame(data: StudyMaker.ImportGame, user: User): Fu[Option[Study.WithChapter]] =
|
def importGame(data: StudyMaker.ImportGame, user: User): Fu[Option[Study.WithChapter]] =
|
||||||
(data.form.as match {
|
(data.form.as match {
|
||||||
case DataForm.importGame.AsNewStudy =>
|
case StudyForm.importGame.AsNewStudy =>
|
||||||
studyMaker(data, user) flatMap { res =>
|
studyMaker(data, user) flatMap { res =>
|
||||||
studyRepo.insert(res.study) >>
|
studyRepo.insert(res.study) >>
|
||||||
chapterRepo.insert(res.chapter) >>-
|
chapterRepo.insert(res.chapter) >>-
|
||||||
indexStudy(res.study) >>-
|
indexStudy(res.study) >>-
|
||||||
scheduleTimeline(res.study.id) inject res.some
|
scheduleTimeline(res.study.id) inject res.some
|
||||||
}
|
}
|
||||||
case DataForm.importGame.AsChapterOf(studyId) =>
|
case StudyForm.importGame.AsChapterOf(studyId) =>
|
||||||
byId(studyId) flatMap {
|
byId(studyId) flatMap {
|
||||||
case Some(study) if study.canContribute(user.id) =>
|
case Some(study) if study.canContribute(user.id) =>
|
||||||
addChapter(
|
addChapter(
|
||||||
|
|
|
@ -5,7 +5,7 @@ import play.api.data.Forms._
|
||||||
|
|
||||||
import lila.common.Form.clean
|
import lila.common.Form.clean
|
||||||
|
|
||||||
object DataForm {
|
object StudyForm {
|
||||||
|
|
||||||
object importGame {
|
object importGame {
|
||||||
|
|
|
@ -79,7 +79,7 @@ final private class StudyMaker(
|
||||||
object StudyMaker {
|
object StudyMaker {
|
||||||
|
|
||||||
case class ImportGame(
|
case class ImportGame(
|
||||||
form: DataForm.importGame.Data = DataForm.importGame.Data(),
|
form: StudyForm.importGame.Data = StudyForm.importGame.Data(),
|
||||||
id: Option[Study.Id] = None,
|
id: Option[Study.Id] = None,
|
||||||
name: Option[Study.Name] = None,
|
name: Option[Study.Name] = None,
|
||||||
settings: Option[Settings] = None,
|
settings: Option[Settings] = None,
|
||||||
|
|
|
@ -31,7 +31,7 @@ final class Env(
|
||||||
lazy val memberRepo = new MemberRepo(db(CollName("team_member")))
|
lazy val memberRepo = new MemberRepo(db(CollName("team_member")))
|
||||||
lazy val requestRepo = new RequestRepo(db(CollName("team_request")))
|
lazy val requestRepo = new RequestRepo(db(CollName("team_request")))
|
||||||
|
|
||||||
lazy val forms = wire[DataForm]
|
lazy val forms = wire[TeamForm]
|
||||||
|
|
||||||
lazy val memberStream = wire[TeamMemberStream]
|
lazy val memberStream = wire[TeamMemberStream]
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import scala.concurrent.duration._
|
||||||
import lila.db.dsl._
|
import lila.db.dsl._
|
||||||
import lila.common.Form.{ clean, numberIn }
|
import lila.common.Form.{ clean, numberIn }
|
||||||
|
|
||||||
final private[team] class DataForm(
|
final private[team] class TeamForm(
|
||||||
teamRepo: TeamRepo,
|
teamRepo: TeamRepo,
|
||||||
lightUserApi: lila.user.LightUserApi,
|
lightUserApi: lila.user.LightUserApi,
|
||||||
val captcher: lila.hub.actors.Captcher
|
val captcher: lila.hub.actors.Captcher
|
||||||
|
@ -76,7 +76,7 @@ final private[team] class DataForm(
|
||||||
|
|
||||||
val selectMember = Form(
|
val selectMember = Form(
|
||||||
single(
|
single(
|
||||||
"userId" -> lila.user.DataForm.historicalUsernameField
|
"userId" -> lila.user.UserForm.historicalUsernameField
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -49,7 +49,7 @@ final class Env(
|
||||||
|
|
||||||
private def scheduler = system.scheduler
|
private def scheduler = system.scheduler
|
||||||
|
|
||||||
lazy val forms = wire[DataForm]
|
lazy val forms = wire[TournamentForm]
|
||||||
|
|
||||||
lazy val tournamentRepo = new TournamentRepo(db(config.tournamentColl), config.playerColl)
|
lazy val tournamentRepo = new TournamentRepo(db(config.tournamentColl), config.playerColl)
|
||||||
lazy val pairingRepo = new PairingRepo(db(config.pairingColl))
|
lazy val pairingRepo = new PairingRepo(db(config.pairingColl))
|
||||||
|
|
|
@ -68,13 +68,13 @@ final class TournamentApi(
|
||||||
name = setup.name,
|
name = setup.name,
|
||||||
clock = setup.clockConfig,
|
clock = setup.clockConfig,
|
||||||
minutes = setup.minutes,
|
minutes = setup.minutes,
|
||||||
waitMinutes = setup.waitMinutes | DataForm.waitMinuteDefault,
|
waitMinutes = setup.waitMinutes | TournamentForm.waitMinuteDefault,
|
||||||
startDate = setup.startDate,
|
startDate = setup.startDate,
|
||||||
mode = setup.realMode,
|
mode = setup.realMode,
|
||||||
password = setup.password,
|
password = setup.password,
|
||||||
variant = setup.realVariant,
|
variant = setup.realVariant,
|
||||||
position =
|
position =
|
||||||
DataForm.startingPosition(setup.position | chess.StartingPosition.initial.fen, setup.realVariant),
|
TournamentForm.startingPosition(setup.position | chess.StartingPosition.initial.fen, setup.realVariant),
|
||||||
berserkable = setup.berserkable | true,
|
berserkable = setup.berserkable | true,
|
||||||
streakable = setup.streakable | true,
|
streakable = setup.streakable | true,
|
||||||
teamBattle = setup.teamBattleByTeam map TeamBattle.init,
|
teamBattle = setup.teamBattleByTeam map TeamBattle.init,
|
||||||
|
@ -114,7 +114,7 @@ final class TournamentApi(
|
||||||
password = data.password,
|
password = data.password,
|
||||||
position =
|
position =
|
||||||
if (old.isCreated || !old.position.initial)
|
if (old.isCreated || !old.position.initial)
|
||||||
DataForm.startingPosition(position | chess.StartingPosition.initial.fen, realVariant)
|
TournamentForm.startingPosition(position | chess.StartingPosition.initial.fen, realVariant)
|
||||||
else old.position,
|
else old.position,
|
||||||
noBerserk = !(~berserkable),
|
noBerserk = !(~berserkable),
|
||||||
noStreak = !(~streakable),
|
noStreak = !(~streakable),
|
||||||
|
|
|
@ -13,9 +13,9 @@ import lila.hub.LeaderTeam
|
||||||
import lila.hub.LightTeam._
|
import lila.hub.LightTeam._
|
||||||
import lila.user.User
|
import lila.user.User
|
||||||
|
|
||||||
final class DataForm {
|
final class TournamentForm {
|
||||||
|
|
||||||
import DataForm._
|
import TournamentForm._
|
||||||
|
|
||||||
def create(user: User, leaderTeams: List[LeaderTeam], teamBattleId: Option[TeamID] = None) =
|
def create(user: User, leaderTeams: List[LeaderTeam], teamBattleId: Option[TeamID] = None) =
|
||||||
form(user, leaderTeams) fill TournamentSetup(
|
form(user, leaderTeams) fill TournamentSetup(
|
||||||
|
@ -104,7 +104,7 @@ final class DataForm {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
object DataForm {
|
object TournamentForm {
|
||||||
|
|
||||||
import chess.variant._
|
import chess.variant._
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ private[tournament] case class TournamentSetup(
|
||||||
|
|
||||||
def realMode = Mode(rated.orElse(mode.map(Mode.Rated.id ==)) | true)
|
def realMode = Mode(rated.orElse(mode.map(Mode.Rated.id ==)) | true)
|
||||||
|
|
||||||
def realVariant = variant.flatMap(DataForm.guessVariant) | chess.variant.Standard
|
def realVariant = variant.flatMap(TournamentForm.guessVariant) | chess.variant.Standard
|
||||||
|
|
||||||
def clockConfig = chess.Clock.Config((clockTime * 60).toInt, clockIncrement)
|
def clockConfig = chess.Clock.Config((clockTime * 60).toInt, clockIncrement)
|
||||||
|
|
|
@ -105,7 +105,7 @@ final class CrudApi(tournamentRepo: TournamentRepo) {
|
||||||
iconFont = none,
|
iconFont = none,
|
||||||
iconImg = image.some.filter(_.nonEmpty)
|
iconImg = image.some.filter(_.nonEmpty)
|
||||||
).some,
|
).some,
|
||||||
position = DataForm.startingPosition(data.position, realVariant),
|
position = TournamentForm.startingPosition(data.position, realVariant),
|
||||||
noBerserk = !data.berserkable,
|
noBerserk = !data.berserkable,
|
||||||
noStreak = !data.streakable,
|
noStreak = !data.streakable,
|
||||||
teamBattle = data.teamBattle option (tour.teamBattle | TeamBattle(Set.empty, 10)),
|
teamBattle = data.teamBattle option (tour.teamBattle | TeamBattle(Set.empty, 10)),
|
||||||
|
|
|
@ -11,7 +11,7 @@ import lila.common.Form._
|
||||||
|
|
||||||
object CrudForm {
|
object CrudForm {
|
||||||
|
|
||||||
import DataForm._
|
import TournamentForm._
|
||||||
import lila.common.Form.UTCDate._
|
import lila.common.Form.UTCDate._
|
||||||
|
|
||||||
val maxHomepageHours = 72
|
val maxHomepageHours = 72
|
||||||
|
@ -24,7 +24,7 @@ object CrudForm {
|
||||||
"clockIncrement" -> numberIn(clockIncrementChoices),
|
"clockIncrement" -> numberIn(clockIncrementChoices),
|
||||||
"minutes" -> number(min = 20, max = 1440),
|
"minutes" -> number(min = 20, max = 1440),
|
||||||
"variant" -> number.verifying(Variant exists _),
|
"variant" -> number.verifying(Variant exists _),
|
||||||
"position" -> text.verifying(DataForm.positions contains _),
|
"position" -> text.verifying(TournamentForm.positions contains _),
|
||||||
"date" -> utcDate,
|
"date" -> utcDate,
|
||||||
"image" -> stringIn(imageChoices),
|
"image" -> stringIn(imageChoices),
|
||||||
"headline" -> text(minLength = 5, maxLength = 30),
|
"headline" -> text(minLength = 5, maxLength = 30),
|
||||||
|
|
|
@ -70,7 +70,7 @@ final class Env(
|
||||||
|
|
||||||
lazy val authenticator = wire[Authenticator]
|
lazy val authenticator = wire[Authenticator]
|
||||||
|
|
||||||
lazy val forms = wire[DataForm]
|
lazy val forms = wire[UserForm]
|
||||||
|
|
||||||
lila.common.Bus.subscribeFuns(
|
lila.common.Bus.subscribeFuns(
|
||||||
"adjustCheater" -> {
|
"adjustCheater" -> {
|
||||||
|
|
|
@ -7,7 +7,7 @@ import play.api.data.Forms._
|
||||||
import User.ClearPassword
|
import User.ClearPassword
|
||||||
import lila.common.Form.clean
|
import lila.common.Form.clean
|
||||||
|
|
||||||
final class DataForm(authenticator: Authenticator) {
|
final class UserForm(authenticator: Authenticator) {
|
||||||
|
|
||||||
val note = Form(
|
val note = Form(
|
||||||
mapping(
|
mapping(
|
||||||
|
@ -69,7 +69,7 @@ final class DataForm(authenticator: Authenticator) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object DataForm {
|
object UserForm {
|
||||||
|
|
||||||
val title = Form(single("title" -> optional(nonEmptyText)))
|
val title = Form(single("title" -> optional(nonEmptyText)))
|
||||||
|
|
Loading…
Reference in New Issue