summaryrefslogtreecommitdiffstats
path: root/models/org.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-09-06 08:54:08 -0400
committerUnknwon <u@gogs.io>2015-09-06 08:54:08 -0400
commitaa67de910af6246a6dc9ad96c56f789e282e8403 (patch)
treec845cd7afe587d341a091507d2f08310a816e509 /models/org.go
parent24658fcbdd507bd66cd76b6ca96e1ef5e1c15af5 (diff)
downloadgitea-aa67de910af6246a6dc9ad96c56f789e282e8403.tar.gz
gitea-aa67de910af6246a6dc9ad96c56f789e282e8403.zip
fix #1558
Diffstat (limited to 'models/org.go')
-rw-r--r--models/org.go23
1 files changed, 11 insertions, 12 deletions
diff --git a/models/org.go b/models/org.go
index dfd720fade..ac458c78d5 100644
--- a/models/org.go
+++ b/models/org.go
@@ -212,7 +212,6 @@ func GetOrganizations(num, offset int) ([]*User, error) {
return orgs, err
}
-// TODO: need some kind of mechanism to record failure.
// DeleteOrganization completely and permanently deletes everything of organization.
func DeleteOrganization(org *User) (err error) {
if err := DeleteUser(org); err != nil {
@@ -220,23 +219,23 @@ func DeleteOrganization(org *User) (err error) {
}
sess := x.NewSession()
- defer sess.Close()
+ defer sessionRelease(sess)
if err = sess.Begin(); err != nil {
return err
}
- if _, err = sess.Delete(&Team{OrgID: org.Id}); err != nil {
- sess.Rollback()
- return err
+ if err = deleteBeans(sess,
+ &Team{OrgID: org.Id},
+ &OrgUser{OrgID: org.Id},
+ &TeamUser{OrgID: org.Id},
+ ); err != nil {
+ return fmt.Errorf("deleteBeans: %v", err)
}
- if _, err = sess.Delete(&OrgUser{OrgID: org.Id}); err != nil {
- sess.Rollback()
- return err
- }
- if _, err = sess.Delete(&TeamUser{OrgID: org.Id}); err != nil {
- sess.Rollback()
- return err
+
+ if err = deleteUser(sess, org); err != nil {
+ return fmt.Errorf("deleteUser: %v", err)
}
+
return sess.Commit()
}