Add full name to account and use it to create commits (#125)
The Git practice is to use the full name when creating commits, not a
user name. This commit fixes that by introducing a fullName field to
Account and using it when creating commits.

For migrating from earlier versions, the user name is used as an initial
value for the full name field.
1 parent 65e6de5 commit 13bff2963e59633611ea3a2d577be6bfd716d0a1
@Robin Stocker Robin Stocker authored on 6 Oct 2013
Showing 12 changed files
View
6
src/main/resources/update/1_7.sql 0 → 100644
ALTER TABLE ACCOUNT ADD COLUMN FULL_NAME VARCHAR(100);
 
UPDATE ACCOUNT SET FULL_NAME = USER_NAME WHERE FULL_NAME IS NULL;
 
ALTER TABLE ACCOUNT ALTER COLUMN FULL_NAME SET NOT NULL;
View
9
src/main/scala/app/AccountController.scala
trait AccountControllerBase extends AccountManagementControllerBase with FlashMapSupport {
self: SystemSettingsService with AccountService with RepositoryService with ActivityService
with OneselfAuthenticator =>
 
case class AccountNewForm(userName: String, password: String,mailAddress: String,
case class AccountNewForm(userName: String, password: String, fullName: String, mailAddress: String,
url: Option[String], fileId: Option[String])
 
case class AccountEditForm(password: Option[String], mailAddress: String,
case class AccountEditForm(password: Option[String], fullName: String, mailAddress: String,
url: Option[String], fileId: Option[String], clearImage: Boolean)
 
val newForm = mapping(
"userName" -> trim(label("User name" , text(required, maxlength(100), identifier, uniqueUserName))),
"password" -> trim(label("Password" , text(required, maxlength(20)))),
"fullName" -> trim(label("Full Name" , text(required, maxlength(100)))),
"mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100), uniqueMailAddress()))),
"url" -> trim(label("URL" , optional(text(maxlength(200))))),
"fileId" -> trim(label("File ID" , optional(text())))
)(AccountNewForm.apply)
 
val editForm = mapping(
"password" -> trim(label("Password" , optional(text(maxlength(20))))),
"fullName" -> trim(label("Full Name" , text(required, maxlength(100)))),
"mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100), uniqueMailAddress("userName")))),
"url" -> trim(label("URL" , optional(text(maxlength(200))))),
"fileId" -> trim(label("File ID" , optional(text()))),
"clearImage" -> trim(label("Clear image" , boolean()))
val userName = params("userName")
getAccountByUserName(userName).map { account =>
updateAccount(account.copy(
password = form.password.map(sha1).getOrElse(account.password),
fullName = form.fullName,
mailAddress = form.mailAddress,
url = form.url))
 
updateImage(userName, form.fileId, form.clearImage)
}
 
post("/register", newForm){ form =>
if(loadSystemSettings().allowAccountRegistration){
createAccount(form.userName, sha1(form.password), form.mailAddress, false, form.url)
createAccount(form.userName, sha1(form.password), form.fullName, form.mailAddress, false, form.url)
updateImage(form.userName, form.fileId, false)
redirect("/signin")
} else NotFound
}
View
2
■■■
src/main/scala/app/CreateRepositoryController.scala
 
val git = Git.open(tmpdir)
git.add.addFilepattern("README.md").call
git.commit
.setCommitter(new PersonIdent(loginUserName, loginAccount.mailAddress))
.setCommitter(new PersonIdent(loginAccount.fullName, loginAccount.mailAddress))
.setMessage("Initial commit").call
git.push.call
 
} finally {
View
2
■■■
src/main/scala/app/PullRequestsController.scala
s"Merge pull request #${issueId} from ${pullreq.requestUserName}/${pullreq.requestRepositoryName}\n"
+ form.message)
 
git.commit
.setCommitter(new PersonIdent(loginAccount.userName, loginAccount.mailAddress))
.setCommitter(new PersonIdent(loginAccount.fullName, loginAccount.mailAddress))
.call
 
// push
git.push.call
View
src/main/scala/app/UserManagementController.scala
View
src/main/scala/app/WikiController.scala
View
src/main/scala/model/Account.scala
View
src/main/scala/service/AccountService.scala
View
src/main/scala/service/WikiService.scala
View
src/main/scala/servlet/AutoUpdateListener.scala
View
src/main/twirl/account/edit.scala.html
View
src/main/twirl/admin/users/user.scala.html