diff --git a/src/main/scala/app/UsersController.scala b/src/main/scala/app/UsersController.scala index 22332ea..5980599 100644 --- a/src/main/scala/app/UsersController.scala +++ b/src/main/scala/app/UsersController.scala @@ -8,7 +8,7 @@ trait UsersControllerBase extends ControllerBase { self: AccountService => - case class NewUserForm(userName: String, password: String, mailAddress: String, userType: Int, url: Option[String]) + case class UserForm(userName: String, password: String, mailAddress: String, userType: Int, url: Option[String]) val newForm = mapping( "userName" -> trim(label("Username" , text(required, maxlength(100), unique))), @@ -16,10 +16,16 @@ "mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100)))), "userType" -> trim(label("User Type" , number())), "url" -> trim(label("URL" , optional(text(maxlength(200))))) - )(NewUserForm.apply) - - + )(UserForm.apply) + val editForm = mapping( + "userName" -> trim(label("Username" , text())), + "password" -> trim(label("Password" , text(required, maxlength(100)))), + "mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100)))), + "userType" -> trim(label("User Type" , number())), + "url" -> trim(label("URL" , optional(text(maxlength(200))))) + )(UserForm.apply) + get("/admin/users"){ admin.html.userlist(getAllUsers()) } @@ -43,13 +49,16 @@ redirect("/admin/users") } -// get("/admin/users/:name/_edit"){ -// -// } -// -// post("/admin/users/:name/_edit"){ -// -// } + get("/admin/users/:userName/_edit"){ + val userName = params("userName") + admin.html.useredit(getAccountByUserName(userName)) + } + + post("/admin/users/:name/_edit", editForm){ form => + // TODO Update Account + + redirect("/admin/users") + } def unique: Constraint = new Constraint(){ def validate(name: String, value: String): Option[String] = diff --git a/src/main/twirl/admin/useredit.scala.html b/src/main/twirl/admin/useredit.scala.html index 52dd242..f9e76ef 100644 --- a/src/main/twirl/admin/useredit.scala.html +++ b/src/main/twirl/admin/useredit.scala.html @@ -1,38 +1,39 @@ @(account: Option[model.Account])(implicit context: app.Context) @import context._ -@html.main("New User"){ -
} \ No newline at end of file