aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorUnknwon <joe2010xtmf@163.com>2014-09-25 19:33:39 -0400
committerUnknwon <joe2010xtmf@163.com>2014-09-25 19:33:39 -0400
commit71e4689d118b3628a6ef7b93117c54265c4d83a5 (patch)
tree90b7b998ba4f5813f7286f3c5a02bece68f6dc62 /models
parentf69761563b7a4fe9ace2a1643391cbcf9b92b372 (diff)
downloadgitea-71e4689d118b3628a6ef7b93117c54265c4d83a5.tar.gz
gitea-71e4689d118b3628a6ef7b93117c54265c4d83a5.zip
Page: User profile
Diffstat (limited to 'models')
-rw-r--r--models/repo.go8
-rw-r--r--models/user.go3
2 files changed, 8 insertions, 3 deletions
diff --git a/models/repo.go b/models/repo.go
index 093e3b7f57..8e7ab96ba6 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -1197,16 +1197,20 @@ func StarRepo(uid, repoId int64, star bool) (err error) {
}
if _, err = x.Insert(&Star{Uid: uid, RepoId: repoId}); err != nil {
return err
+ } else if _, err = x.Exec("UPDATE `repository` SET num_stars = num_stars + 1 WHERE id = ?", repoId); err != nil {
+ return err
}
- _, err = x.Exec("UPDATE `repository` SET num_stars = num_stars + 1 WHERE id = ?", repoId)
+ _, err = x.Exec("UPDATE `user` SET num_stars = num_stars + 1 WHERE id = ?", uid)
} else {
if !IsStaring(uid, repoId) {
return nil
}
if _, err = x.Delete(&Star{0, uid, repoId}); err != nil {
return err
+ } else if _, err = x.Exec("UPDATE `repository` SET num_stars = num_stars - 1 WHERE id = ?", repoId); err != nil {
+ return err
}
- _, err = x.Exec("UPDATE `repository` SET num_stars = num_stars - 1 WHERE id = ?", repoId)
+ _, err = x.Exec("UPDATE `user` SET num_stars = num_stars - 1 WHERE id = ?", uid)
}
return err
}
diff --git a/models/user.go b/models/user.go
index 49f8387d79..f327ed1440 100644
--- a/models/user.go
+++ b/models/user.go
@@ -11,6 +11,7 @@ import (
"errors"
"fmt"
"os"
+ "path"
"path/filepath"
"strings"
"time"
@@ -90,7 +91,7 @@ func (u *User) DashboardLink() string {
// HomeLink returns the user home page link.
func (u *User) HomeLink() string {
- return setting.AppSubUrl + "/user/" + u.Name
+ return "/" + path.Join(setting.AppSubUrl, u.Name)
}
// AvatarLink returns user gravatar link.