diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2014-03-11 14:17:05 +0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2014-03-11 14:17:05 +0800 |
commit | b5cc4078a9c3f11f37f4d01f77428a5dc226baa4 (patch) | |
tree | 81010e14074f24336fe7b8ba7bc69933a9cc4a33 /models | |
parent | fdc4151ff3f97df69788c69f8136b1c1be49b29f (diff) | |
download | gitea-b5cc4078a9c3f11f37f4d01f77428a5dc226baa4.tar.gz gitea-b5cc4078a9c3f11f37f4d01f77428a5dc226baa4.zip |
add repo list of dashboard
Diffstat (limited to 'models')
-rw-r--r-- | models/repo.go | 4 | ||||
-rw-r--r-- | models/user.go | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/models/repo.go b/models/repo.go index ed828a347b..d4f304557c 100644 --- a/models/repo.go +++ b/models/repo.go @@ -223,6 +223,10 @@ func GetRepositories(user *User) ([]Repository, error) { return repos, err } +func GetRepositoryCount(user *User) (int64, error) { + return orm.Count(&Repository{OwnerId: user.Id}) +} + func StarReposiory(user *User, repoName string) error { return nil } diff --git a/models/user.go b/models/user.go index d904304f51..95cebb1812 100644 --- a/models/user.go +++ b/models/user.go @@ -142,13 +142,15 @@ func UpdateUser(user *User) (err error) { // DeleteUser completely deletes everything of the user. func DeleteUser(user *User) error { - repos, err := GetRepositories(user) + cnt, err := GetRepositoryCount(user) if err != nil { return errors.New("modesl.GetRepositories: " + err.Error()) - } else if len(repos) > 0 { + } else if cnt > 0 { return ErrUserOwnRepos } + // TODO: check issues, other repos' commits + _, err = orm.Delete(user) // TODO: delete and update follower information. return err |