summaryrefslogtreecommitdiffstats
path: root/services/org
diff options
context:
space:
mode:
Diffstat (limited to 'services/org')
-rw-r--r--services/org/org.go17
1 files changed, 12 insertions, 5 deletions
diff --git a/services/org/org.go b/services/org/org.go
index e45fb305de..a62e5b6fc8 100644
--- a/services/org/org.go
+++ b/services/org/org.go
@@ -4,20 +4,22 @@
package org
import (
+ "context"
"fmt"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
- "code.gitea.io/gitea/models/organization"
+ org_model "code.gitea.io/gitea/models/organization"
packages_model "code.gitea.io/gitea/models/packages"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/storage"
"code.gitea.io/gitea/modules/util"
+ user_service "code.gitea.io/gitea/services/user"
)
// DeleteOrganization completely and permanently deletes everything of organization.
-func DeleteOrganization(org *organization.Organization) error {
+func DeleteOrganization(org *org_model.Organization) error {
ctx, commiter, err := db.TxContext(db.DefaultContext)
if err != nil {
return err
@@ -39,7 +41,7 @@ func DeleteOrganization(org *organization.Organization) error {
return models.ErrUserOwnPackages{UID: org.ID}
}
- if err := organization.DeleteOrganization(ctx, org); err != nil {
+ if err := org_model.DeleteOrganization(ctx, org); err != nil {
return fmt.Errorf("DeleteOrganization: %w", err)
}
@@ -53,15 +55,20 @@ func DeleteOrganization(org *organization.Organization) error {
path := user_model.UserPath(org.Name)
if err := util.RemoveAll(path); err != nil {
- return fmt.Errorf("Failed to RemoveAll %s: %w", path, err)
+ return fmt.Errorf("failed to RemoveAll %s: %w", path, err)
}
if len(org.Avatar) > 0 {
avatarPath := org.CustomAvatarRelativePath()
if err := storage.Avatars.Delete(avatarPath); err != nil {
- return fmt.Errorf("Failed to remove %s: %w", avatarPath, err)
+ return fmt.Errorf("failed to remove %s: %w", avatarPath, err)
}
}
return nil
}
+
+// RenameOrganization renames an organization.
+func RenameOrganization(ctx context.Context, org *org_model.Organization, newName string) error {
+ return user_service.RenameUser(ctx, org.AsUser(), newName)
+}