2014-05-03 17:45:14 -06:00
|
|
|
package controllers
|
|
|
|
|
|
|
|
import lila.app._
|
|
|
|
|
|
|
|
object Coordinate extends LilaController {
|
|
|
|
|
|
|
|
private def env = Env.coordinate
|
|
|
|
|
|
|
|
def home = Open { implicit ctx =>
|
2014-05-04 05:53:48 -06:00
|
|
|
ctx.userId ?? { userId => env.api getScore userId map (_.some) } map { score =>
|
|
|
|
views.html.coordinate.home(score)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-14 08:34:07 -07:00
|
|
|
def score = AuthBody { implicit ctx => me =>
|
|
|
|
implicit val body = ctx.body
|
|
|
|
env.forms.score.bindFromRequest.fold(
|
|
|
|
err => fuccess(BadRequest),
|
|
|
|
data => env.api.addScore(me.id, data.isWhite, data.score)
|
|
|
|
) >> {
|
|
|
|
env.api getScore me.id map { s =>
|
|
|
|
Ok(views.html.coordinate.scoreCharts(s))
|
2014-05-04 05:53:48 -06:00
|
|
|
}
|
2017-02-14 08:34:07 -07:00
|
|
|
}
|
2014-05-04 05:53:48 -06:00
|
|
|
}
|
|
|
|
|
2017-02-14 08:34:07 -07:00
|
|
|
def color = AuthBody { implicit ctx => me =>
|
|
|
|
implicit val req = ctx.body
|
|
|
|
env.forms.color.bindFromRequest.fold(
|
|
|
|
err => fuccess(BadRequest),
|
|
|
|
value => Env.pref.api.setPref(
|
|
|
|
me,
|
|
|
|
(p: lila.pref.Pref) => p.copy(coordColor = value),
|
|
|
|
notifyChange = false
|
|
|
|
) inject Ok(())
|
|
|
|
)
|
2014-05-03 17:45:14 -06:00
|
|
|
}
|
|
|
|
}
|