summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/issue.go2
-rw-r--r--models/models.go4
-rw-r--r--models/org.go2
-rw-r--r--models/repo.go1
-rw-r--r--models/user.go19
5 files changed, 16 insertions, 12 deletions
diff --git a/models/issue.go b/models/issue.go
index 3cd71d8aa4..2b80e57608 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -564,7 +564,7 @@ func GetLabels(repoId int64) ([]*Label, error) {
// UpdateLabel updates label information.
func UpdateLabel(l *Label) error {
- _, err := x.Id(l.Id).Update(l)
+ _, err := x.Id(l.Id).AllCols().Update(l)
return err
}
diff --git a/models/models.go b/models/models.go
index 1cb7229645..b0c3b8978f 100644
--- a/models/models.go
+++ b/models/models.go
@@ -16,7 +16,7 @@ import (
"github.com/go-xorm/xorm"
_ "github.com/lib/pq"
- "github.com/gogits/gogs/models/migrations"
+ // "github.com/gogits/gogs/models/migrations"
"github.com/gogits/gogs/modules/setting"
)
@@ -140,7 +140,7 @@ func SetEngine() (err error) {
if err != nil {
return fmt.Errorf("models.init(fail to create xorm.log): %v", err)
}
- x.Logger = xorm.NewSimpleLogger(f)
+ x.SetLogger(xorm.NewSimpleLogger(f))
x.ShowSQL = true
x.ShowInfo = true
diff --git a/models/org.go b/models/org.go
index 42b14bf072..36cf5f7d1a 100644
--- a/models/org.go
+++ b/models/org.go
@@ -103,7 +103,7 @@ func CreateOrganization(org, owner *User) (*User, error) {
return nil, ErrUserNameIllegal
}
- isExist, err := IsUserExist(org.Name)
+ isExist, err := IsUserExist(0, org.Name)
if err != nil {
return nil, err
} else if isExist {
diff --git a/models/repo.go b/models/repo.go
index fd00823a23..90cfdba854 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -154,7 +154,6 @@ type Repository struct {
IsPrivate bool
IsBare bool
- IsGoget bool
IsMirror bool
*Mirror `xorm:"-"`
diff --git a/models/user.go b/models/user.go
index 37e77dd3ba..387ab6555b 100644
--- a/models/user.go
+++ b/models/user.go
@@ -249,11 +249,13 @@ func (u *User) GetFullNameFallback() string {
// IsUserExist checks if given user name exist,
// the user name should be noncased unique.
-func IsUserExist(name string) (bool, error) {
+// If uid is presented, then check will rule out that one,
+// it is used when update a user name in settings page.
+func IsUserExist(uid int64, name string) (bool, error) {
if len(name) == 0 {
return false, nil
}
- return x.Get(&User{LowerName: strings.ToLower(name)})
+ return x.Where("id!=?", uid).Get(&User{LowerName: strings.ToLower(name)})
}
// IsEmailUsed returns true if the e-mail has been used.
@@ -278,7 +280,7 @@ func CreateUser(u *User) error {
return ErrUserNameIllegal
}
- isExist, err := IsUserExist(u.Name)
+ isExist, err := IsUserExist(0, u.Name)
if err != nil {
return err
} else if isExist {
@@ -401,7 +403,7 @@ func ChangeUserName(u *User, newUserName string) (err error) {
// UpdateUser updates user's information.
func UpdateUser(u *User) error {
- has, err := x.Where("id!=?", u.Id).And("type=?", INDIVIDUAL).And("email=?", u.Email).Get(new(User))
+ has, err := x.Where("id!=?", u.Id).And("type=?", u.Type).And("email=?", u.Email).Get(new(User))
if err != nil {
return err
} else if has {
@@ -578,7 +580,7 @@ func GetUserIdsByNames(names []string) []int64 {
return ids
}
-// Get all email addresses
+// GetEmailAddresses returns all e-mail addresses belongs to given user.
func GetEmailAddresses(uid int64) ([]*EmailAddress, error) {
emails := make([]*EmailAddress, 0, 5)
err := x.Where("uid=?", uid).Find(&emails)
@@ -592,7 +594,6 @@ func GetEmailAddresses(uid int64) ([]*EmailAddress, error) {
}
isPrimaryFound := false
-
for _, email := range emails {
if email.Email == u.Email {
isPrimaryFound = true
@@ -605,7 +606,11 @@ func GetEmailAddresses(uid int64) ([]*EmailAddress, error) {
// We alway want the primary email address displayed, even if it's not in
// the emailaddress table (yet)
if !isPrimaryFound {
- emails = append(emails, &EmailAddress{Email: u.Email, IsActivated: true, IsPrimary: true})
+ emails = append(emails, &EmailAddress{
+ Email: u.Email,
+ IsActivated: true,
+ IsPrimary: true,
+ })
}
return emails, nil
}