From 7da39b4785dfcfe83f490c8d167e1d2efa1dabff Mon Sep 17 00:00:00 2001 From: takezoe Date: Sat, 29 Jun 2013 02:23:32 +0900 Subject: [PATCH] Add the password field to the account editing page. --- src/main/scala/app/AccountController.scala | 4 +++- src/main/twirl/account/useredit.scala.html | 24 +++++++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main/scala/app/AccountController.scala b/src/main/scala/app/AccountController.scala index 61594f799..90d65306b 100644 --- a/src/main/scala/app/AccountController.scala +++ b/src/main/scala/app/AccountController.scala @@ -12,7 +12,7 @@ trait AccountControllerBase extends ControllerBase { case class AccountNewForm(userName: String, password: String,mailAddress: String, url: Option[String]) - case class AccountEditForm(mailAddress: String, url: Option[String]) + case class AccountEditForm(password: Option[String], mailAddress: String, url: Option[String]) val newForm = mapping( "userName" -> trim(label("User name" , text(required, maxlength(100)))), @@ -22,6 +22,7 @@ trait AccountControllerBase extends ControllerBase { )(AccountNewForm.apply) val editForm = mapping( + "password" -> trim(label("Password" , optional(text(maxlength(20))))), "mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100)))), "url" -> trim(label("URL" , optional(text(maxlength(200))))) )(AccountEditForm.apply) @@ -45,6 +46,7 @@ trait AccountControllerBase extends ControllerBase { val userName = params("userName") getAccountByUserName(userName).map { account => updateAccount(account.copy( + password = form.password.getOrElse(account.password), mailAddress = form.mailAddress, url = form.url)) redirect("/%s".format(userName)) diff --git a/src/main/twirl/account/useredit.scala.html b/src/main/twirl/account/useredit.scala.html index 0a30dabe2..8c643485a 100644 --- a/src/main/twirl/account/useredit.scala.html +++ b/src/main/twirl/account/useredit.scala.html @@ -1,27 +1,31 @@ @(account: Option[model.Account])(implicit context: app.Context) @import context._ @import view.helpers._ -@html.main(account.map(_.userName).getOrElse("Create account")){ -
+@html.main((if(account.isDefined) "Your Profile" else "Create account")){ + @if(account.isEmpty){
- +
-
- - - -
}
- + + + +
+
+
- +