2013-05-06 19:57:42 -06:00
|
|
|
package controllers
|
|
|
|
|
|
|
|
import lila.app._
|
|
|
|
import views._
|
|
|
|
|
|
|
|
object Importer extends LilaController with BaseGame {
|
|
|
|
|
2013-05-09 09:11:06 -06:00
|
|
|
private def env = Env.importer
|
2013-05-06 19:57:42 -06:00
|
|
|
|
2013-05-09 09:11:06 -06:00
|
|
|
def importGame = Open { implicit ctx ⇒
|
|
|
|
makeListMenu map { listMenu ⇒
|
|
|
|
Ok(html.game.importGame(listMenu, env.forms.importForm))
|
|
|
|
}
|
|
|
|
}
|
2013-05-06 19:57:42 -06:00
|
|
|
|
2013-05-09 09:11:06 -06:00
|
|
|
def sendGame = OpenBody { implicit ctx ⇒
|
|
|
|
implicit def req = ctx.body
|
|
|
|
env.forms.importForm.bindFromRequest.fold(
|
|
|
|
failure ⇒ makeListMenu map { listMenu ⇒
|
|
|
|
Ok(html.game.importGame(listMenu, failure))
|
|
|
|
},
|
2013-10-16 13:58:48 -06:00
|
|
|
data ⇒ env.importer(data, ctx.userId, ctx.req.remoteAddress) map { game ⇒
|
2014-02-01 11:45:02 -07:00
|
|
|
Redirect(routes.Round.watcher(game.id, "white"))
|
2013-05-09 09:11:06 -06:00
|
|
|
} recover {
|
|
|
|
case e ⇒ {
|
|
|
|
logwarn(e.getMessage)
|
|
|
|
Redirect(routes.Importer.importGame)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
2013-05-06 19:57:42 -06:00
|
|
|
}
|