mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-05 04:56:02 +01:00
Merge pull request #1851 from kounoike/pr-includegroups-option
Add "include group accounts" checkbox in User management
This commit is contained in:
@@ -331,12 +331,13 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
||||
|
||||
get("/admin/users")(adminOnly {
|
||||
val includeRemoved = params.get("includeRemoved").map(_.toBoolean).getOrElse(false)
|
||||
val users = getAllUsers(includeRemoved)
|
||||
val includeGroups = params.get("includeGroups").map(_.toBoolean).getOrElse(false)
|
||||
val users = getAllUsers(includeRemoved, includeGroups)
|
||||
val members = users.collect { case account if(account.isGroupAccount) =>
|
||||
account.userName -> getGroupMembers(account.userName).map(_.userName)
|
||||
}.toMap
|
||||
|
||||
html.userlist(users, members, includeRemoved)
|
||||
html.userlist(users, members, includeRemoved, includeGroups)
|
||||
})
|
||||
|
||||
get("/admin/users/_newuser")(adminOnly {
|
||||
|
||||
@@ -96,11 +96,13 @@ trait AccountService {
|
||||
def getAccountByMailAddress(mailAddress: String, includeRemoved: Boolean = false)(implicit s: Session): Option[Account] =
|
||||
Accounts filter(t => (t.mailAddress.toLowerCase === mailAddress.toLowerCase.bind) && (t.removed === false.bind, !includeRemoved)) firstOption
|
||||
|
||||
def getAllUsers(includeRemoved: Boolean = true)(implicit s: Session): List[Account] =
|
||||
if(includeRemoved){
|
||||
Accounts sortBy(_.userName) list
|
||||
} else {
|
||||
Accounts filter (_.removed === false.bind) sortBy(_.userName) list
|
||||
def getAllUsers(includeRemoved: Boolean = true, includeGroups: Boolean = true)(implicit s: Session): List[Account] =
|
||||
{
|
||||
Accounts filter { t =>
|
||||
(1.bind === 1.bind) &&
|
||||
(t.groupAccount === false.bind, !includeGroups) &&
|
||||
(t.removed === false.bind, !includeRemoved)
|
||||
} sortBy(_.userName) list
|
||||
}
|
||||
|
||||
def isLastAdministrator(account: Account)(implicit s: Session): Boolean = {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@(users: List[gitbucket.core.model.Account], members: Map[String, List[String]], includeRemoved: Boolean)(implicit context: gitbucket.core.controller.Context)
|
||||
@(users: List[gitbucket.core.model.Account], members: Map[String, List[String]], includeRemoved: Boolean, includeGroups: Boolean)(implicit context: gitbucket.core.controller.Context)
|
||||
@import gitbucket.core.view.helpers
|
||||
@gitbucket.core.html.main("Manage Users"){
|
||||
@gitbucket.core.admin.html.menu("users"){
|
||||
@@ -10,6 +10,10 @@
|
||||
<input type="checkbox" id="includeRemoved" name="includeRemoved" @if(includeRemoved){checked}/>
|
||||
Include removed users
|
||||
</label>
|
||||
<label for="includeGroups">
|
||||
<input type="checkbox" id="includeGroups" name="includeGroups" @if(includeGroups){checked}/>
|
||||
Include group accounts
|
||||
</label>
|
||||
<table class="table table-bordered table-hover">
|
||||
@users.map { account =>
|
||||
<tr>
|
||||
@@ -63,8 +67,9 @@
|
||||
}
|
||||
<script>
|
||||
$(function(){
|
||||
$('#includeRemoved').click(function(){
|
||||
location.href = '@context.path/admin/users?includeRemoved=' + this.checked;
|
||||
$('#includeRemoved,#includeGroups').click(function(){
|
||||
location.href = '@context.path/admin/users?includeRemoved=' + $('#includeRemoved').prop('checked')
|
||||
+ '&includeGroups=' + $('#includeGroups').prop('checked');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user