Merge pull request #2354 from freefal/tournamentCreate
Add tournament creation api to lila
This commit is contained in:
commit
e287433c53
|
@ -173,12 +173,21 @@ object Tournament extends LilaController {
|
|||
def create = AuthBody { implicit ctx =>
|
||||
implicit me =>
|
||||
NoLame {
|
||||
import play.api.i18n.Messages.Implicits._
|
||||
import play.api.Play.current
|
||||
implicit val req = ctx.body
|
||||
env.forms.create.bindFromRequest.fold(
|
||||
err => BadRequest(html.tournament.form(err, env.forms)).fuccess,
|
||||
setup => env.api.createTournament(setup, me) map { tour =>
|
||||
Redirect(routes.Tournament.show(tour.id))
|
||||
})
|
||||
negotiate (
|
||||
html = env.forms.create.bindFromRequest.fold(
|
||||
err => BadRequest(html.tournament.form(err, env.forms)).fuccess,
|
||||
setup => env.api.createTournament(setup, me) map { tour =>
|
||||
Redirect(routes.Tournament.show(tour.id))
|
||||
}),
|
||||
api = _ => env.forms.create.bindFromRequest.fold(
|
||||
err => BadRequest(errorsAsJson(err)).fuccess,
|
||||
setup => env.api.createTournament(setup, me) map { tour =>
|
||||
Ok(Json.obj("id" -> tour.id))
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue