summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorThibault Meyer <0xbaadf00d@users.noreply.github.com>2016-11-06 09:59:21 +0100
committerSandro Santilli <strk@kbt.io>2016-11-06 09:59:21 +0100
commitfe8bfa54dea3c4d513e64c86bd4ec555d2ca27be (patch)
treebd9583e7c15480996c7088f062856a69c918aba7 /models
parentd318f612a9101625cba575a44428ced9d2aafa84 (diff)
downloadgitea-fe8bfa54dea3c4d513e64c86bd4ec555d2ca27be.tar.gz
gitea-fe8bfa54dea3c4d513e64c86bd4ec555d2ca27be.zip
Ordering team by name ascending except for 'Owners' (#48)
Diffstat (limited to 'models')
-rw-r--r--models/org.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/models/org.go b/models/org.go
index 1fd6039b6d..ec54081857 100644
--- a/models/org.go
+++ b/models/org.go
@@ -50,7 +50,7 @@ func (org *User) GetOwnerTeam() (*Team, error) {
}
func (org *User) getTeams(e Engine) error {
- return e.Where("org_id=?", org.ID).Find(&org.Teams)
+ return e.Where("org_id=?", org.ID).OrderBy("CASE WHEN name LIKE '" + OWNER_TEAM + "' THEN '' ELSE name END").Find(&org.Teams)
}
// GetTeams returns all teams that belong to organization.
@@ -495,7 +495,7 @@ func (org *User) GetUserRepositories(userID int64, page, pageSize int) ([]*Repos
repos := make([]*Repository, 0, pageSize)
// FIXME: use XORM chain operations instead of raw SQL.
if err = x.Sql(fmt.Sprintf(`SELECT repository.* FROM repository
- INNER JOIN team_repo
+ INNER JOIN team_repo
ON team_repo.repo_id = repository.id
WHERE (repository.owner_id = ? AND repository.is_private = ?) OR team_repo.team_id IN (%s)
GROUP BY repository.id
@@ -507,7 +507,7 @@ func (org *User) GetUserRepositories(userID int64, page, pageSize int) ([]*Repos
}
results, err := x.Query(fmt.Sprintf(`SELECT repository.id FROM repository
- INNER JOIN team_repo
+ INNER JOIN team_repo
ON team_repo.repo_id = repository.id
WHERE (repository.owner_id = ? AND repository.is_private = ?) OR team_repo.team_id IN (%s)
GROUP BY repository.id
@@ -534,7 +534,7 @@ func (org *User) GetUserMirrorRepositories(userID int64) ([]*Repository, error)
repos := make([]*Repository, 0, 10)
if err = x.Sql(fmt.Sprintf(`SELECT repository.* FROM repository
- INNER JOIN team_repo
+ INNER JOIN team_repo
ON team_repo.repo_id = repository.id AND repository.is_mirror = ?
WHERE (repository.owner_id = ? AND repository.is_private = ?) OR team_repo.team_id IN (%s)
GROUP BY repository.id