mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-08 22:45:51 +01:00
Merge pull request #1424 from team-lab/account-description
Account description
This commit is contained in:
6
src/main/resources/update/gitbucket-core_4.9.xml
Normal file
6
src/main/resources/update/gitbucket-core_4.9.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<changeSet>
|
||||||
|
<addColumn tableName="ACCOUNT">
|
||||||
|
<column name="DESCRIPTION" type="text" nullable="true" />
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
@@ -24,5 +24,8 @@ object GitBucketCoreModule extends Module("gitbucket-core",
|
|||||||
new SqlMigration("update/gitbucket-core_4.7.sql")
|
new SqlMigration("update/gitbucket-core_4.7.sql")
|
||||||
),
|
),
|
||||||
new Version("4.7.1"),
|
new Version("4.7.1"),
|
||||||
new Version("4.8")
|
new Version("4.8"),
|
||||||
|
new Version("4.9",
|
||||||
|
new LiquibaseMigration("update/gitbucket-core_4.9.xml")
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
with AccessTokenService with WebHookService with RepositoryCreationService =>
|
with AccessTokenService with WebHookService with RepositoryCreationService =>
|
||||||
|
|
||||||
case class AccountNewForm(userName: String, password: String, fullName: String, mailAddress: String,
|
case class AccountNewForm(userName: String, password: String, fullName: String, mailAddress: String,
|
||||||
url: Option[String], fileId: Option[String])
|
description: Option[String], url: Option[String], fileId: Option[String])
|
||||||
|
|
||||||
case class AccountEditForm(password: Option[String], fullName: String, mailAddress: String,
|
case class AccountEditForm(password: Option[String], fullName: String, mailAddress: String,
|
||||||
url: Option[String], fileId: Option[String], clearImage: Boolean)
|
description: Option[String], url: Option[String], fileId: Option[String], clearImage: Boolean)
|
||||||
|
|
||||||
case class SshKeyForm(title: String, publicKey: String)
|
case class SshKeyForm(title: String, publicKey: String)
|
||||||
|
|
||||||
@@ -43,6 +43,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
"password" -> trim(label("Password" , text(required, maxlength(20)))),
|
"password" -> trim(label("Password" , text(required, maxlength(20)))),
|
||||||
"fullName" -> trim(label("Full Name" , text(required, maxlength(100)))),
|
"fullName" -> trim(label("Full Name" , text(required, maxlength(100)))),
|
||||||
"mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100), uniqueMailAddress()))),
|
"mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100), uniqueMailAddress()))),
|
||||||
|
"description" -> trim(label("bio" , optional(text()))),
|
||||||
"url" -> trim(label("URL" , optional(text(maxlength(200))))),
|
"url" -> trim(label("URL" , optional(text(maxlength(200))))),
|
||||||
"fileId" -> trim(label("File ID" , optional(text())))
|
"fileId" -> trim(label("File ID" , optional(text())))
|
||||||
)(AccountNewForm.apply)
|
)(AccountNewForm.apply)
|
||||||
@@ -51,6 +52,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
"password" -> trim(label("Password" , optional(text(maxlength(20))))),
|
"password" -> trim(label("Password" , optional(text(maxlength(20))))),
|
||||||
"fullName" -> trim(label("Full Name" , text(required, maxlength(100)))),
|
"fullName" -> trim(label("Full Name" , text(required, maxlength(100)))),
|
||||||
"mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100), uniqueMailAddress("userName")))),
|
"mailAddress" -> trim(label("Mail Address" , text(required, maxlength(100), uniqueMailAddress("userName")))),
|
||||||
|
"description" -> trim(label("bio" , optional(text()))),
|
||||||
"url" -> trim(label("URL" , optional(text(maxlength(200))))),
|
"url" -> trim(label("URL" , optional(text(maxlength(200))))),
|
||||||
"fileId" -> trim(label("File ID" , optional(text()))),
|
"fileId" -> trim(label("File ID" , optional(text()))),
|
||||||
"clearImage" -> trim(label("Clear image" , boolean()))
|
"clearImage" -> trim(label("Clear image" , boolean()))
|
||||||
@@ -65,11 +67,12 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
"note" -> trim(label("Token", text(required, maxlength(100))))
|
"note" -> trim(label("Token", text(required, maxlength(100))))
|
||||||
)(PersonalTokenForm.apply)
|
)(PersonalTokenForm.apply)
|
||||||
|
|
||||||
case class NewGroupForm(groupName: String, url: Option[String], fileId: Option[String], members: String)
|
case class NewGroupForm(groupName: String, description: Option[String], url: Option[String], fileId: Option[String], members: String)
|
||||||
case class EditGroupForm(groupName: String, url: Option[String], fileId: Option[String], members: String, clearImage: Boolean)
|
case class EditGroupForm(groupName: String, description: Option[String], url: Option[String], fileId: Option[String], members: String, clearImage: Boolean)
|
||||||
|
|
||||||
val newGroupForm = mapping(
|
val newGroupForm = mapping(
|
||||||
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
|
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
|
||||||
|
"description" -> trim(label("Group description", optional(text()))),
|
||||||
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
||||||
"fileId" -> trim(label("File ID" ,optional(text()))),
|
"fileId" -> trim(label("File ID" ,optional(text()))),
|
||||||
"members" -> trim(label("Members" ,text(required, members)))
|
"members" -> trim(label("Members" ,text(required, members)))
|
||||||
@@ -77,6 +80,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
val editGroupForm = mapping(
|
val editGroupForm = mapping(
|
||||||
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier))),
|
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier))),
|
||||||
|
"description" -> trim(label("Group description", optional(text()))),
|
||||||
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
||||||
"fileId" -> trim(label("File ID" ,optional(text()))),
|
"fileId" -> trim(label("File ID" ,optional(text()))),
|
||||||
"members" -> trim(label("Members" ,text(required, members))),
|
"members" -> trim(label("Members" ,text(required, members))),
|
||||||
@@ -167,6 +171,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
password = form.password.map(sha1).getOrElse(account.password),
|
password = form.password.map(sha1).getOrElse(account.password),
|
||||||
fullName = form.fullName,
|
fullName = form.fullName,
|
||||||
mailAddress = form.mailAddress,
|
mailAddress = form.mailAddress,
|
||||||
|
description = form.description,
|
||||||
url = form.url))
|
url = form.url))
|
||||||
|
|
||||||
updateImage(userName, form.fileId, form.clearImage)
|
updateImage(userName, form.fileId, form.clearImage)
|
||||||
@@ -266,7 +271,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
post("/register", newForm){ form =>
|
post("/register", newForm){ form =>
|
||||||
if(context.settings.allowAccountRegistration){
|
if(context.settings.allowAccountRegistration){
|
||||||
createAccount(form.userName, sha1(form.password), form.fullName, form.mailAddress, false, form.url)
|
createAccount(form.userName, sha1(form.password), form.fullName, form.mailAddress, false, form.description, form.url)
|
||||||
updateImage(form.userName, form.fileId, false)
|
updateImage(form.userName, form.fileId, false)
|
||||||
redirect("/signin")
|
redirect("/signin")
|
||||||
} else NotFound()
|
} else NotFound()
|
||||||
@@ -277,7 +282,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
post("/groups/new", newGroupForm)(usersOnly { form =>
|
post("/groups/new", newGroupForm)(usersOnly { form =>
|
||||||
createGroup(form.groupName, form.url)
|
createGroup(form.groupName, form.description, form.url)
|
||||||
updateGroupMembers(form.groupName, form.members.split(",").map {
|
updateGroupMembers(form.groupName, form.members.split(",").map {
|
||||||
_.split(":") match {
|
_.split(":") match {
|
||||||
case Array(userName, isManager) => (userName, isManager.toBoolean)
|
case Array(userName, isManager) => (userName, isManager.toBoolean)
|
||||||
@@ -315,7 +320,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
}
|
}
|
||||||
}.toList){ case (groupName, members) =>
|
}.toList){ case (groupName, members) =>
|
||||||
getAccountByUserName(groupName, true).map { account =>
|
getAccountByUserName(groupName, true).map { account =>
|
||||||
updateGroup(groupName, form.url, false)
|
updateGroup(groupName, form.description, form.url, false)
|
||||||
|
|
||||||
// Update GROUP_MEMBER
|
// Update GROUP_MEMBER
|
||||||
updateGroupMembers(form.groupName, members)
|
updateGroupMembers(form.groupName, members)
|
||||||
|
|||||||
@@ -91,16 +91,16 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
case class NewUserForm(userName: String, password: String, fullName: String,
|
case class NewUserForm(userName: String, password: String, fullName: String,
|
||||||
mailAddress: String, isAdmin: Boolean,
|
mailAddress: String, isAdmin: Boolean,
|
||||||
url: Option[String], fileId: Option[String])
|
description: Option[String], url: Option[String], fileId: Option[String])
|
||||||
|
|
||||||
case class EditUserForm(userName: String, password: Option[String], fullName: String,
|
case class EditUserForm(userName: String, password: Option[String], fullName: String,
|
||||||
mailAddress: String, isAdmin: Boolean, url: Option[String],
|
mailAddress: String, isAdmin: Boolean, description: Option[String], url: Option[String],
|
||||||
fileId: Option[String], clearImage: Boolean, isRemoved: Boolean)
|
fileId: Option[String], clearImage: Boolean, isRemoved: Boolean)
|
||||||
|
|
||||||
case class NewGroupForm(groupName: String, url: Option[String], fileId: Option[String],
|
case class NewGroupForm(groupName: String, description: Option[String], url: Option[String], fileId: Option[String],
|
||||||
members: String)
|
members: String)
|
||||||
|
|
||||||
case class EditGroupForm(groupName: String, url: Option[String], fileId: Option[String],
|
case class EditGroupForm(groupName: String, description: Option[String], url: Option[String], fileId: Option[String],
|
||||||
members: String, clearImage: Boolean, isRemoved: Boolean)
|
members: String, clearImage: Boolean, isRemoved: Boolean)
|
||||||
|
|
||||||
|
|
||||||
@@ -110,6 +110,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
"fullName" -> trim(label("Full Name" ,text(required, maxlength(100)))),
|
"fullName" -> trim(label("Full Name" ,text(required, maxlength(100)))),
|
||||||
"mailAddress" -> trim(label("Mail Address" ,text(required, maxlength(100), uniqueMailAddress()))),
|
"mailAddress" -> trim(label("Mail Address" ,text(required, maxlength(100), uniqueMailAddress()))),
|
||||||
"isAdmin" -> trim(label("User Type" ,boolean())),
|
"isAdmin" -> trim(label("User Type" ,boolean())),
|
||||||
|
"description" -> trim(label("bio" ,optional(text()))),
|
||||||
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
||||||
"fileId" -> trim(label("File ID" ,optional(text())))
|
"fileId" -> trim(label("File ID" ,optional(text())))
|
||||||
)(NewUserForm.apply)
|
)(NewUserForm.apply)
|
||||||
@@ -120,6 +121,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
"fullName" -> trim(label("Full Name" ,text(required, maxlength(100)))),
|
"fullName" -> trim(label("Full Name" ,text(required, maxlength(100)))),
|
||||||
"mailAddress" -> trim(label("Mail Address" ,text(required, maxlength(100), uniqueMailAddress("userName")))),
|
"mailAddress" -> trim(label("Mail Address" ,text(required, maxlength(100), uniqueMailAddress("userName")))),
|
||||||
"isAdmin" -> trim(label("User Type" ,boolean())),
|
"isAdmin" -> trim(label("User Type" ,boolean())),
|
||||||
|
"description" -> trim(label("bio" ,optional(text()))),
|
||||||
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
||||||
"fileId" -> trim(label("File ID" ,optional(text()))),
|
"fileId" -> trim(label("File ID" ,optional(text()))),
|
||||||
"clearImage" -> trim(label("Clear image" ,boolean())),
|
"clearImage" -> trim(label("Clear image" ,boolean())),
|
||||||
@@ -128,6 +130,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
val newGroupForm = mapping(
|
val newGroupForm = mapping(
|
||||||
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
|
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier, uniqueUserName, reservedNames))),
|
||||||
|
"description" -> trim(label("Group description", optional(text()))),
|
||||||
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
||||||
"fileId" -> trim(label("File ID" ,optional(text()))),
|
"fileId" -> trim(label("File ID" ,optional(text()))),
|
||||||
"members" -> trim(label("Members" ,text(required, members)))
|
"members" -> trim(label("Members" ,text(required, members)))
|
||||||
@@ -135,6 +138,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
|
|
||||||
val editGroupForm = mapping(
|
val editGroupForm = mapping(
|
||||||
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier))),
|
"groupName" -> trim(label("Group name" ,text(required, maxlength(100), identifier))),
|
||||||
|
"description" -> trim(label("Group description", optional(text()))),
|
||||||
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
"url" -> trim(label("URL" ,optional(text(maxlength(200))))),
|
||||||
"fileId" -> trim(label("File ID" ,optional(text()))),
|
"fileId" -> trim(label("File ID" ,optional(text()))),
|
||||||
"members" -> trim(label("Members" ,text(required, members))),
|
"members" -> trim(label("Members" ,text(required, members))),
|
||||||
@@ -196,7 +200,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
post("/admin/users/_newuser", newUserForm)(adminOnly { form =>
|
post("/admin/users/_newuser", newUserForm)(adminOnly { form =>
|
||||||
createAccount(form.userName, sha1(form.password), form.fullName, form.mailAddress, form.isAdmin, form.url)
|
createAccount(form.userName, sha1(form.password), form.fullName, form.mailAddress, form.isAdmin, form.description, form.url)
|
||||||
updateImage(form.userName, form.fileId, false)
|
updateImage(form.userName, form.fileId, false)
|
||||||
redirect("/admin/users")
|
redirect("/admin/users")
|
||||||
})
|
})
|
||||||
@@ -230,6 +234,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
fullName = form.fullName,
|
fullName = form.fullName,
|
||||||
mailAddress = form.mailAddress,
|
mailAddress = form.mailAddress,
|
||||||
isAdmin = form.isAdmin,
|
isAdmin = form.isAdmin,
|
||||||
|
description = form.description,
|
||||||
url = form.url,
|
url = form.url,
|
||||||
isRemoved = form.isRemoved))
|
isRemoved = form.isRemoved))
|
||||||
|
|
||||||
@@ -244,7 +249,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
post("/admin/users/_newgroup", newGroupForm)(adminOnly { form =>
|
post("/admin/users/_newgroup", newGroupForm)(adminOnly { form =>
|
||||||
createGroup(form.groupName, form.url)
|
createGroup(form.groupName, form.description, form.url)
|
||||||
updateGroupMembers(form.groupName, form.members.split(",").map {
|
updateGroupMembers(form.groupName, form.members.split(",").map {
|
||||||
_.split(":") match {
|
_.split(":") match {
|
||||||
case Array(userName, isManager) => (userName, isManager.toBoolean)
|
case Array(userName, isManager) => (userName, isManager.toBoolean)
|
||||||
@@ -267,7 +272,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
|||||||
}
|
}
|
||||||
}.toList){ case (groupName, members) =>
|
}.toList){ case (groupName, members) =>
|
||||||
getAccountByUserName(groupName, true).map { account =>
|
getAccountByUserName(groupName, true).map { account =>
|
||||||
updateGroup(groupName, form.url, form.isRemoved)
|
updateGroup(groupName, form.url, form.description, form.isRemoved)
|
||||||
|
|
||||||
if(form.isRemoved){
|
if(form.isRemoved){
|
||||||
// Remove from GROUP_MEMBER
|
// Remove from GROUP_MEMBER
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ trait AccountComponent { self: Profile =>
|
|||||||
val image = column[String]("IMAGE")
|
val image = column[String]("IMAGE")
|
||||||
val groupAccount = column[Boolean]("GROUP_ACCOUNT")
|
val groupAccount = column[Boolean]("GROUP_ACCOUNT")
|
||||||
val removed = column[Boolean]("REMOVED")
|
val removed = column[Boolean]("REMOVED")
|
||||||
def * = (userName, fullName, mailAddress, password, isAdmin, url.?, registeredDate, updatedDate, lastLoginDate.?, image.?, groupAccount, removed) <> (Account.tupled, Account.unapply)
|
val description = column[String]("DESCRIPTION")
|
||||||
|
def * = (userName, fullName, mailAddress, password, isAdmin, url.?, registeredDate, updatedDate, lastLoginDate.?, image.?, groupAccount, removed, description.?) <> (Account.tupled, Account.unapply)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,5 +36,6 @@ case class Account(
|
|||||||
lastLoginDate: Option[java.util.Date],
|
lastLoginDate: Option[java.util.Date],
|
||||||
image: Option[String],
|
image: Option[String],
|
||||||
isGroupAccount: Boolean,
|
isGroupAccount: Boolean,
|
||||||
isRemoved: Boolean
|
isRemoved: Boolean,
|
||||||
|
description: Option[String]
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ trait AccountService {
|
|||||||
defaultAuthentication(userName, password)
|
defaultAuthentication(userName, password)
|
||||||
}
|
}
|
||||||
case None => {
|
case None => {
|
||||||
createAccount(ldapUserInfo.userName, "", ldapUserInfo.fullName, ldapUserInfo.mailAddress, false, None)
|
createAccount(ldapUserInfo.userName, "", ldapUserInfo.fullName, ldapUserInfo.mailAddress, false, None, None)
|
||||||
getAccountByUserName(ldapUserInfo.userName)
|
getAccountByUserName(ldapUserInfo.userName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,7 +103,7 @@ trait AccountService {
|
|||||||
} else false
|
} else false
|
||||||
}
|
}
|
||||||
|
|
||||||
def createAccount(userName: String, password: String, fullName: String, mailAddress: String, isAdmin: Boolean, url: Option[String])
|
def createAccount(userName: String, password: String, fullName: String, mailAddress: String, isAdmin: Boolean, description: Option[String], url: Option[String])
|
||||||
(implicit s: Session): Unit =
|
(implicit s: Session): Unit =
|
||||||
Accounts insert Account(
|
Accounts insert Account(
|
||||||
userName = userName,
|
userName = userName,
|
||||||
@@ -117,12 +117,13 @@ trait AccountService {
|
|||||||
lastLoginDate = None,
|
lastLoginDate = None,
|
||||||
image = None,
|
image = None,
|
||||||
isGroupAccount = false,
|
isGroupAccount = false,
|
||||||
isRemoved = false)
|
isRemoved = false,
|
||||||
|
description = description)
|
||||||
|
|
||||||
def updateAccount(account: Account)(implicit s: Session): Unit =
|
def updateAccount(account: Account)(implicit s: Session): Unit =
|
||||||
Accounts
|
Accounts
|
||||||
.filter { a => a.userName === account.userName.bind }
|
.filter { a => a.userName === account.userName.bind }
|
||||||
.map { a => (a.password, a.fullName, a.mailAddress, a.isAdmin, a.url.?, a.registeredDate, a.updatedDate, a.lastLoginDate.?, a.removed) }
|
.map { a => (a.password, a.fullName, a.mailAddress, a.isAdmin, a.url.?, a.registeredDate, a.updatedDate, a.lastLoginDate.?, a.removed, a.description.?) }
|
||||||
.update (
|
.update (
|
||||||
account.password,
|
account.password,
|
||||||
account.fullName,
|
account.fullName,
|
||||||
@@ -132,7 +133,8 @@ trait AccountService {
|
|||||||
account.registeredDate,
|
account.registeredDate,
|
||||||
currentDate,
|
currentDate,
|
||||||
account.lastLoginDate,
|
account.lastLoginDate,
|
||||||
account.isRemoved)
|
account.isRemoved,
|
||||||
|
account.description)
|
||||||
|
|
||||||
def updateAvatarImage(userName: String, image: Option[String])(implicit s: Session): Unit =
|
def updateAvatarImage(userName: String, image: Option[String])(implicit s: Session): Unit =
|
||||||
Accounts.filter(_.userName === userName.bind).map(_.image.?).update(image)
|
Accounts.filter(_.userName === userName.bind).map(_.image.?).update(image)
|
||||||
@@ -140,7 +142,7 @@ trait AccountService {
|
|||||||
def updateLastLoginDate(userName: String)(implicit s: Session): Unit =
|
def updateLastLoginDate(userName: String)(implicit s: Session): Unit =
|
||||||
Accounts.filter(_.userName === userName.bind).map(_.lastLoginDate).update(currentDate)
|
Accounts.filter(_.userName === userName.bind).map(_.lastLoginDate).update(currentDate)
|
||||||
|
|
||||||
def createGroup(groupName: String, url: Option[String])(implicit s: Session): Unit =
|
def createGroup(groupName: String, description: Option[String], url: Option[String])(implicit s: Session): Unit =
|
||||||
Accounts insert Account(
|
Accounts insert Account(
|
||||||
userName = groupName,
|
userName = groupName,
|
||||||
password = "",
|
password = "",
|
||||||
@@ -153,10 +155,13 @@ trait AccountService {
|
|||||||
lastLoginDate = None,
|
lastLoginDate = None,
|
||||||
image = None,
|
image = None,
|
||||||
isGroupAccount = true,
|
isGroupAccount = true,
|
||||||
isRemoved = false)
|
isRemoved = false,
|
||||||
|
description = description)
|
||||||
|
|
||||||
def updateGroup(groupName: String, url: Option[String], removed: Boolean)(implicit s: Session): Unit =
|
def updateGroup(groupName: String, description: Option[String], url: Option[String], removed: Boolean)(implicit s: Session): Unit =
|
||||||
Accounts.filter(_.userName === groupName.bind).map(t => t.url.? -> t.removed).update(url, removed)
|
Accounts.filter(_.userName === groupName.bind)
|
||||||
|
.map(t => (t.url.?, t.description.?, t.removed))
|
||||||
|
.update(url, description, removed)
|
||||||
|
|
||||||
def updateGroupMembers(groupName: String, members: List[(String, Boolean)])(implicit s: Session): Unit = {
|
def updateGroupMembers(groupName: String, members: List[(String, Boolean)])(implicit s: Session): Unit = {
|
||||||
GroupMembers.filter(_.groupName === groupName.bind).delete
|
GroupMembers.filter(_.groupName === groupName.bind).delete
|
||||||
|
|||||||
@@ -37,6 +37,11 @@
|
|||||||
<input type="text" name="url" id="url" class="form-control" value="@account.url"/>
|
<input type="text" name="url" id="url" class="form-control" value="@account.url"/>
|
||||||
<span id="error-url" class="error"></span>
|
<span id="error-url" class="error"></span>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<fieldset class="form-group">
|
||||||
|
<label for="description" class="strong">Bio (optional):</label>
|
||||||
|
<textarea name="description" id="description" class="form-control">@account.description</textarea>
|
||||||
|
<span id="error-description" class="error"></span>
|
||||||
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<fieldset class="form-group">
|
<fieldset class="form-group">
|
||||||
|
|||||||
@@ -21,6 +21,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<input type="text" name="url" id="url" class="form-control" value="@account.map(_.url)"/>
|
<input type="text" name="url" id="url" class="form-control" value="@account.map(_.url)"/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<fieldset class="form-group">
|
||||||
|
<label for="groupDescription" class="strong">Description (Optional)</label>
|
||||||
|
<div>
|
||||||
|
<textarea name="description" id="description" class="form-control">@account.map(_.description)</textarea>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
<fieldset class="form-group">
|
<fieldset class="form-group">
|
||||||
<label for="avatar" class="strong">Image (Optional)</label>
|
<label for="avatar" class="strong">Image (Optional)</label>
|
||||||
@gitbucket.core.helper.html.uploadavatar(account)
|
@gitbucket.core.helper.html.uploadavatar(account)
|
||||||
|
|||||||
@@ -12,6 +12,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="padding-left: 10px; padding-right: 10px;">
|
<div style="padding-left: 10px; padding-right: 10px;">
|
||||||
|
@account.description.map{ description =>
|
||||||
|
<p style="color: white;">@description</p>
|
||||||
|
}
|
||||||
@if(account.url.isDefined){
|
@if(account.url.isDefined){
|
||||||
<p style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
|
<p style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
|
||||||
<i class="octicon octicon-home"></i> <a href="@account.url">@account.url</a>
|
<i class="octicon octicon-home"></i> <a href="@account.url">@account.url</a>
|
||||||
|
|||||||
@@ -33,6 +33,11 @@
|
|||||||
<input type="text" name="url" id="url" class="form-control" value=""/>
|
<input type="text" name="url" id="url" class="form-control" value=""/>
|
||||||
<span id="error-url" class="error"></span>
|
<span id="error-url" class="error"></span>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<label for="description" class="strong">Bio (optional):</label>
|
||||||
|
<textarea name="description" id="description" class="form-control"></textarea>
|
||||||
|
<span id="error-description" class="error"></span>
|
||||||
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
|||||||
@@ -66,6 +66,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<input type="text" name="url" id="url" class="form-control" value="@account.map(_.url)"/>
|
<input type="text" name="url" id="url" class="form-control" value="@account.map(_.url)"/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<fieldset class="form-group">
|
||||||
|
<label class="strong">Bio (Optional):</label>
|
||||||
|
<div>
|
||||||
|
<span id="error-description" class="error"></span>
|
||||||
|
</div>
|
||||||
|
<textarea name="description" id="description" class="form-control">@account.map(_.description)</textarea>
|
||||||
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<fieldset class="form-group">
|
<fieldset class="form-group">
|
||||||
|
|||||||
@@ -24,6 +24,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<input type="text" name="url" id="url" class="form-control" value="@account.map(_.url)"/>
|
<input type="text" name="url" id="url" class="form-control" value="@account.map(_.url)"/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<fieldset class="form-group">
|
||||||
|
<label class="strong">Description (Optional)</label>
|
||||||
|
<textarea name="description" id="description" class="form-control">@account.map(_.description)</textarea>
|
||||||
|
</fieldset>
|
||||||
<fieldset class="form-group">
|
<fieldset class="form-group">
|
||||||
<label for="avatar" class="strong">Image (Optional)</label>
|
<label for="avatar" class="strong">Image (Optional)</label>
|
||||||
@gitbucket.core.helper.html.uploadavatar(account)
|
@gitbucket.core.helper.html.uploadavatar(account)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class AccountServiceSpec extends FunSuite with ServiceSpecBase {
|
|||||||
|
|
||||||
test("getAllUsers") { withTestDB { implicit session =>
|
test("getAllUsers") { withTestDB { implicit session =>
|
||||||
assert(AccountService.getAllUsers() match {
|
assert(AccountService.getAllUsers() match {
|
||||||
case List(Account("root", "root", RootMailAddress, _, true, _, _, _, None, None, false, false)) => true
|
case List(Account("root", "root", RootMailAddress, _, true, _, _, _, None, None, false, false, None)) => true
|
||||||
case _ => false
|
case _ => false
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
@@ -47,12 +47,20 @@ class AccountServiceSpec extends FunSuite with ServiceSpecBase {
|
|||||||
val newAddress = "new mail address"
|
val newAddress = "new mail address"
|
||||||
AccountService.updateAccount(user().copy(mailAddress = newAddress))
|
AccountService.updateAccount(user().copy(mailAddress = newAddress))
|
||||||
assert(user().mailAddress == newAddress)
|
assert(user().mailAddress == newAddress)
|
||||||
|
|
||||||
|
val newUrl = Some("http://new.url.example/path")
|
||||||
|
AccountService.updateAccount(user().copy(url = newUrl))
|
||||||
|
assert(user().url == newUrl)
|
||||||
|
|
||||||
|
val newDescription = Some("http://new.url.example/path")
|
||||||
|
AccountService.updateAccount(user().copy(description = newDescription))
|
||||||
|
assert(user().description == newDescription)
|
||||||
}}
|
}}
|
||||||
|
|
||||||
test("group") { withTestDB { implicit session =>
|
test("group") { withTestDB { implicit session =>
|
||||||
val group1 = "group1"
|
val group1 = "group1"
|
||||||
val user1 = "root"
|
val user1 = "root"
|
||||||
AccountService.createGroup(group1, None)
|
AccountService.createGroup(group1, None, None)
|
||||||
|
|
||||||
assert(AccountService.getGroupMembers(group1) == Nil)
|
assert(AccountService.getGroupMembers(group1) == Nil)
|
||||||
assert(AccountService.getGroupsByUserName(user1) == Nil)
|
assert(AccountService.getGroupsByUserName(user1) == Nil)
|
||||||
@@ -67,5 +75,20 @@ class AccountServiceSpec extends FunSuite with ServiceSpecBase {
|
|||||||
assert(AccountService.getGroupMembers(group1) == Nil)
|
assert(AccountService.getGroupMembers(group1) == Nil)
|
||||||
assert(AccountService.getGroupsByUserName(user1) == Nil)
|
assert(AccountService.getGroupsByUserName(user1) == Nil)
|
||||||
}}
|
}}
|
||||||
}
|
|
||||||
|
|
||||||
|
test("createGroup save description") { withTestDB { implicit session =>
|
||||||
|
AccountService.createGroup("some-group", Some("some clever description"), None)
|
||||||
|
val maybeGroup = AccountService.getAccountByUserName("some-group")
|
||||||
|
|
||||||
|
assert(maybeGroup.flatMap(_.description) == Some("some clever description"))
|
||||||
|
}}
|
||||||
|
|
||||||
|
test("updateGroup save description") { withTestDB { implicit session =>
|
||||||
|
AccountService.createGroup("a-group", None, None)
|
||||||
|
|
||||||
|
AccountService.updateGroup("a-group", Some("new description"), None, false)
|
||||||
|
|
||||||
|
val group = AccountService.getAccountByUserName("a-group")
|
||||||
|
assert(group.flatMap(_.description) == Some("new description"))
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ class ProtectedBranchServiceSpec extends FunSpec with ServiceSpecBase with Prote
|
|||||||
it("administrator is manager") {
|
it("administrator is manager") {
|
||||||
withTestDB { implicit session =>
|
withTestDB { implicit session =>
|
||||||
val x = ProtectedBranchInfo("grp1", "repo1", true, Nil, false)
|
val x = ProtectedBranchInfo("grp1", "repo1", true, Nil, false)
|
||||||
x.createGroup("grp1", None)
|
x.createGroup("grp1", None, None)
|
||||||
generateNewAccount("user1")
|
generateNewAccount("user1")
|
||||||
generateNewAccount("user2")
|
generateNewAccount("user2")
|
||||||
generateNewAccount("user3")
|
generateNewAccount("user3")
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ trait ServiceSpecBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def generateNewAccount(name:String)(implicit s:Session):Account = {
|
def generateNewAccount(name:String)(implicit s:Session):Account = {
|
||||||
AccountService.createAccount(name, name, name, s"${name}@example.com", false, None)
|
AccountService.createAccount(name, name, name, s"${name}@example.com", false, None, None)
|
||||||
user(name)
|
user(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,8 @@ class AvatarImageProviderSpec extends FunSpec with MockitoSugar {
|
|||||||
lastLoginDate = None,
|
lastLoginDate = None,
|
||||||
image = image,
|
image = image,
|
||||||
isGroupAccount = false,
|
isGroupAccount = false,
|
||||||
isRemoved = false)
|
isRemoved = false,
|
||||||
|
description = None)
|
||||||
|
|
||||||
private def createSystemSettings(useGravatar: Boolean) =
|
private def createSystemSettings(useGravatar: Boolean) =
|
||||||
SystemSettings(
|
SystemSettings(
|
||||||
|
|||||||
Reference in New Issue
Block a user