show PGN import error - closes #5320
This commit is contained in:
parent
a66ab63c19
commit
b73a4d5011
|
@ -27,6 +27,15 @@ object importGame {
|
|||
p(cls := "explanation")(trans.importGameExplanation()),
|
||||
postForm(cls := "form3 import", action := routes.Importer.sendGame())(
|
||||
form3.group(form("pgn"), trans.pasteThePgnStringHere())(form3.textarea(_)()),
|
||||
form("pgn").value flatMap { pgn =>
|
||||
lila.importer.ImportData(pgn, none).preprocess(none).fold(
|
||||
err => frag(
|
||||
pre(cls := "error")(err.toList mkString "\n"),
|
||||
br, br
|
||||
).some,
|
||||
_ => none
|
||||
)
|
||||
},
|
||||
form3.group(form("pgnFile"), raw("Or upload a PGN file"), klass = "upload") { f =>
|
||||
form3.file.pgn(f.name)
|
||||
},
|
||||
|
|
|
@ -12,12 +12,11 @@ import lila.game._
|
|||
private[importer] final class DataForm {
|
||||
|
||||
lazy val importForm = Form(mapping(
|
||||
"pgn" -> nonEmptyText.verifying("invalidPgn", checkPgn _),
|
||||
"pgn" -> nonEmptyText.verifying("invalidPgn", p => checkPgn(p).isSuccess),
|
||||
"analyse" -> optional(nonEmptyText)
|
||||
)(ImportData.apply)(ImportData.unapply))
|
||||
|
||||
private def checkPgn(pgn: String): Boolean =
|
||||
ImportData(pgn, none).preprocess(none).isSuccess
|
||||
def checkPgn(pgn: String): Valid[Preprocessed] = ImportData(pgn, none).preprocess(none)
|
||||
}
|
||||
|
||||
private[importer] case class TagResult(status: Status, winner: Option[Color])
|
||||
|
|
Loading…
Reference in a new issue