|
|
@@ -13,17 +13,24 @@ import (
|
|
|
)
|
|
|
|
|
|
const (
|
|
|
- SETTINGS_OPTIONS = "org/settings/options"
|
|
|
- SETTINGS_DELETE = "org/settings/delete"
|
|
|
+ // SETTINGS_OPTIONS url
|
|
|
+ SETTINGS_OPTIONS = "org/settings/options"
|
|
|
+
|
|
|
+ // SETTINGS_DELETE url
|
|
|
+ SETTINGS_DELETE = "org/settings/delete"
|
|
|
+
|
|
|
+ // SETTINGS_WEBHOOKS url
|
|
|
SETTINGS_WEBHOOKS = "org/settings/webhooks"
|
|
|
)
|
|
|
|
|
|
+// Settings shows the organization settings page
|
|
|
func Settings(c *context.Context) {
|
|
|
c.Data["Title"] = c.Tr("org.settings")
|
|
|
c.Data["PageIsSettingsOptions"] = true
|
|
|
c.HTML(200, SETTINGS_OPTIONS)
|
|
|
}
|
|
|
|
|
|
+// SettingsPost updates organization settings with the body fields
|
|
|
func SettingsPost(c *context.Context, f form.UpdateOrgSetting) {
|
|
|
c.Data["Title"] = c.Tr("org.settings")
|
|
|
c.Data["PageIsSettingsOptions"] = true
|
|
|
@@ -74,6 +81,8 @@ func SettingsPost(c *context.Context, f form.UpdateOrgSetting) {
|
|
|
org.Website = f.Website
|
|
|
org.Location = f.Location
|
|
|
org.IsVerified = f.IsVerified
|
|
|
+
|
|
|
+ // Update organization
|
|
|
if err := models.UpdateUser(org); err != nil {
|
|
|
c.Handle(500, "UpdateUser", err)
|
|
|
return
|
|
|
@@ -83,17 +92,22 @@ func SettingsPost(c *context.Context, f form.UpdateOrgSetting) {
|
|
|
c.Redirect(c.Org.OrgLink + "/settings")
|
|
|
}
|
|
|
|
|
|
+// SettingsAvatar updates organization avatar
|
|
|
func SettingsAvatar(c *context.Context, f form.Avatar) {
|
|
|
f.Source = form.AVATAR_LOCAL
|
|
|
+
|
|
|
+ // Update avatar
|
|
|
if err := user.UpdateAvatarSetting(c, f, c.Org.Organization); err != nil {
|
|
|
c.Flash.Error(err.Error())
|
|
|
} else {
|
|
|
c.Flash.Success(c.Tr("org.settings.update_avatar_success"))
|
|
|
}
|
|
|
|
|
|
+ // Redirect to "/settings"
|
|
|
c.Redirect(c.Org.OrgLink + "/settings")
|
|
|
}
|
|
|
|
|
|
+// SettingsDeleteAvatar deletes organization avatar
|
|
|
func SettingsDeleteAvatar(c *context.Context) {
|
|
|
if err := c.Org.Organization.DeleteAvatar(); err != nil {
|
|
|
c.Flash.Error(err.Error())
|
|
|
@@ -102,12 +116,14 @@ func SettingsDeleteAvatar(c *context.Context) {
|
|
|
c.Redirect(c.Org.OrgLink + "/settings")
|
|
|
}
|
|
|
|
|
|
+// SettingsDelete deletes an organization
|
|
|
func SettingsDelete(c *context.Context) {
|
|
|
c.Title("org.settings")
|
|
|
c.PageIs("SettingsDelete")
|
|
|
|
|
|
org := c.Org.Organization
|
|
|
if c.Req.Method == "POST" {
|
|
|
+ // Check if user is logged in
|
|
|
if _, err := models.UserLogin(c.User.Name, c.Query("password"), c.User.LoginSource); err != nil {
|
|
|
if errors.IsUserNotExist(err) {
|
|
|
c.RenderWithErr(c.Tr("form.enterred_invalid_password"), SETTINGS_DELETE, nil)
|
|
|
@@ -117,6 +133,7 @@ func SettingsDelete(c *context.Context) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // Delete organization
|
|
|
if err := models.DeleteOrganization(org); err != nil {
|
|
|
if models.IsErrUserOwnRepos(err) {
|
|
|
c.Flash.Error(c.Tr("form.org_still_own_repo"))
|
|
|
@@ -134,6 +151,7 @@ func SettingsDelete(c *context.Context) {
|
|
|
c.Success(SETTINGS_DELETE)
|
|
|
}
|
|
|
|
|
|
+// Webhooks shows organization webhooks settings
|
|
|
func Webhooks(c *context.Context) {
|
|
|
c.Data["Title"] = c.Tr("org.settings")
|
|
|
c.Data["PageIsSettingsHooks"] = true
|
|
|
@@ -151,7 +169,10 @@ func Webhooks(c *context.Context) {
|
|
|
c.HTML(200, SETTINGS_WEBHOOKS)
|
|
|
}
|
|
|
|
|
|
+// DeleteWbhook deletes an organization webhook
|
|
|
func DeleteWebhook(c *context.Context) {
|
|
|
+
|
|
|
+ // Delete the webhook
|
|
|
if err := models.DeleteWebhookOfOrgByID(c.Org.Organization.ID, c.QueryInt64("id")); err != nil {
|
|
|
c.Flash.Error("DeleteWebhookByOrgID: " + err.Error())
|
|
|
} else {
|