Explorar o código

Add admin routes documentation

Gitote %!s(int64=7) %!d(string=hai) anos
pai
achega
a0154745da

+ 36 - 5
routes/admin/admin.go

@@ -19,12 +19,23 @@ import (
 )
 
 const (
+	// DASHBOARD page template
 	DASHBOARD = "admin/dashboard"
+
+	// ANALYTICS page template
 	ANALYTICS = "admin/analytics"
-	API       = "admin/api"
-	CONFIG    = "admin/config"
-	MONITOR   = "admin/monitor"
-	STATUS    = "admin/status"
+
+	// API page template
+	API = "admin/api"
+
+	// CONFIG page template
+	CONFIG = "admin/config"
+
+	// MONITOR page template
+	MONITOR = "admin/monitor"
+
+	// STATUS page template
+	STATUS = "admin/status"
 )
 
 var (
@@ -110,19 +121,33 @@ func updateSystemStatus() {
 	sysStatus.NumGC = m.NumGC
 }
 
-// Operation types.
+// AdminOperation types.
 type AdminOperation int
 
 const (
+	// CLEAN_INACTIVATE_USER operation value
 	CLEAN_INACTIVATE_USER AdminOperation = iota + 1
+
+	// CLEAN_REPO_ARCHIVES operation value
 	CLEAN_REPO_ARCHIVES
+
+	// CLEAN_MISSING_REPOS operation value
 	CLEAN_MISSING_REPOS
+
+	// GIT_GC_REPOS operation value
 	GIT_GC_REPOS
+
+	// SYNC_SSH_AUTHORIZED_KEY operation value
 	SYNC_SSH_AUTHORIZED_KEY
+
+	// SYNC_REPOSITORY_HOOKS operation value
 	SYNC_REPOSITORY_HOOKS
+
+	// REINIT_MISSING_REPOSITORY operation value
 	REINIT_MISSING_REPOSITORY
 )
 
+// Dashboard shows dashboard page
 func Dashboard(c *context.Context) {
 	c.Data["Title"] = "Dashboard"
 	c.Data["PageIsAdmin"] = true
@@ -172,6 +197,7 @@ func Dashboard(c *context.Context) {
 	c.HTML(200, DASHBOARD)
 }
 
+// SendTestMail send mail to verify the email
 func SendTestMail(c *context.Context) {
 	email := c.Query("email")
 	// Send a test email to the user's email address and redirect back to Config
@@ -184,6 +210,7 @@ func SendTestMail(c *context.Context) {
 	c.Redirect(setting.AppSubURL + "/admin/config")
 }
 
+// Config shows configuration page
 func Config(c *context.Context) {
 	c.Data["Title"] = "Configuration"
 	c.Data["PageIsAdmin"] = true
@@ -245,6 +272,7 @@ func Config(c *context.Context) {
 	c.HTML(200, CONFIG)
 }
 
+// Monitor shows monitor page
 func Monitor(c *context.Context) {
 	c.Data["Title"] = "Monitoring"
 	c.Data["PageIsAdmin"] = true
@@ -254,18 +282,21 @@ func Monitor(c *context.Context) {
 	c.HTML(200, MONITOR)
 }
 
+// Status shows status page
 func Status(c *context.Context) {
 	c.Data["Title"] = "Status"
 	c.Data["PageIsAdminStatus"] = true
 	c.HTML(200, STATUS)
 }
 
+// Analytics shows analytics page
 func Analytics(c *context.Context) {
 	c.Data["Title"] = "Analytics"
 	c.Data["PageIsAdminAnalytics"] = true
 	c.HTML(200, ANALYTICS)
 }
 
+// AdminAPI shows api configuration
 func AdminAPI(c *context.Context) {
 	c.Data["Title"] = "API"
 	c.Data["PageIsAdminAPI"] = true

+ 13 - 2
routes/admin/auths.go

@@ -14,11 +14,17 @@ import (
 )
 
 const (
-	AUTHS     = "admin/auth/list"
-	AUTH_NEW  = "admin/auth/new"
+	// AUTHS list page template
+	AUTHS = "admin/auth/list"
+
+	// AUTH_NEW page template
+	AUTH_NEW = "admin/auth/new"
+
+	// AUTH_EDIT page template
 	AUTH_EDIT = "admin/auth/edit"
 )
 
+// Authentications shows authentication page
 func Authentications(c *context.Context) {
 	c.Title("admin.authentication")
 	c.PageIs("Admin")
@@ -54,6 +60,7 @@ var (
 	}
 )
 
+// NewAuthSource shows create auth page
 func NewAuthSource(c *context.Context) {
 	c.Title("admin.auths.new")
 	c.PageIs("Admin")
@@ -109,6 +116,7 @@ func parseSMTPConfig(f form.Authentication) *models.SMTPConfig {
 	}
 }
 
+// NewAuthSourcePost creates a new auth source
 func NewAuthSourcePost(c *context.Context, f form.Authentication) {
 	c.Title("admin.auths.new")
 	c.PageIs("Admin")
@@ -166,6 +174,7 @@ func NewAuthSourcePost(c *context.Context, f form.Authentication) {
 	c.Redirect(setting.AppSubURL + "/admin/auths")
 }
 
+// EditAuthSource shows edit auth source page
 func EditAuthSource(c *context.Context) {
 	c.Title("admin.auths.edit")
 	c.PageIs("Admin")
@@ -185,6 +194,7 @@ func EditAuthSource(c *context.Context) {
 	c.Success(AUTH_EDIT)
 }
 
+// EditAuthSourcePost edits an auth source
 func EditAuthSourcePost(c *context.Context, f form.Authentication) {
 	c.Title("admin.auths.edit")
 	c.PageIs("Admin")
@@ -235,6 +245,7 @@ func EditAuthSourcePost(c *context.Context, f form.Authentication) {
 	c.Redirect(setting.AppSubURL + "/admin/auths/" + com.ToStr(f.ID))
 }
 
+// DeleteAuthSource deletes an auth source
 func DeleteAuthSource(c *context.Context) {
 	source, err := models.GetLoginSourceByID(c.ParamsInt64(":authid"))
 	if err != nil {

+ 2 - 0
routes/admin/inbox.go

@@ -5,9 +5,11 @@ import (
 )
 
 const (
+	// INBOX page template
 	INBOX = "admin/inbox"
 )
 
+// Inbox shows admin inbox page
 func Inbox(c *context.Context) {
 	c.Data["Title"] = "Inbox"
 	c.Data["PageIsAdminInbox"] = true

+ 4 - 0
routes/admin/notice.go

@@ -11,9 +11,11 @@ import (
 )
 
 const (
+	// NOTICES page template
 	NOTICES = "admin/notice"
 )
 
+// Notices shows admin notices page
 func Notices(c *context.Context) {
 	c.Data["Title"] = "System Notices"
 	c.Data["PageIsAdmin"] = true
@@ -37,6 +39,7 @@ func Notices(c *context.Context) {
 	c.HTML(200, NOTICES)
 }
 
+// DeleteNotices deletes notices
 func DeleteNotices(c *context.Context) {
 	strs := c.QueryStrings("ids[]")
 	ids := make([]int64, 0, len(strs))
@@ -56,6 +59,7 @@ func DeleteNotices(c *context.Context) {
 	}
 }
 
+// EmptyNotices emty notices list
 func EmptyNotices(c *context.Context) {
 	if err := models.DeleteNotices(0, 0); err != nil {
 		c.Handle(500, "DeleteNotices", err)

+ 2 - 0
routes/admin/orgs.go

@@ -8,9 +8,11 @@ import (
 )
 
 const (
+	// ORGS list page template
 	ORGS = "admin/org/list"
 )
 
+// Organizations shows organizations page
 func Organizations(c *context.Context) {
 	c.Data["Title"] = "Organizations"
 	c.Data["PageIsAdmin"] = true

+ 3 - 0
routes/admin/repos.go

@@ -10,9 +10,11 @@ import (
 )
 
 const (
+	// REPOS list page template
 	REPOS = "admin/repo/list"
 )
 
+// Repos shows repositories page
 func Repos(c *context.Context) {
 	c.Data["Title"] = "Repositories"
 	c.Data["PageIsAdmin"] = true
@@ -63,6 +65,7 @@ func Repos(c *context.Context) {
 	c.HTML(200, REPOS)
 }
 
+// DeleteRepo deletes a repository
 func DeleteRepo(c *context.Context) {
 	repo, err := models.GetRepositoryByID(c.QueryInt64("id"))
 	if err != nil {

+ 13 - 2
routes/admin/users.go

@@ -14,11 +14,17 @@ import (
 )
 
 const (
-	USERS     = "admin/user/list"
-	USER_NEW  = "admin/user/new"
+	// USERS list page template
+	USERS = "admin/user/list"
+
+	// USER_NEW page template
+	USER_NEW = "admin/user/new"
+
+	// USER_EDIT page template
 	USER_EDIT = "admin/user/edit"
 )
 
+// Users shows users page
 func Users(c *context.Context) {
 	c.Data["Title"] = "Users"
 	c.Data["PageIsAdmin"] = true
@@ -34,6 +40,7 @@ func Users(c *context.Context) {
 	})
 }
 
+// NewUser shows new user page
 func NewUser(c *context.Context) {
 	c.Data["Title"] = "Create New Account"
 	c.Data["PageIsAdmin"] = true
@@ -52,6 +59,7 @@ func NewUser(c *context.Context) {
 	c.HTML(200, USER_NEW)
 }
 
+// NewUserPost creates a new user
 func NewUserPost(c *context.Context, f form.AdminCrateUser) {
 	c.Data["Title"] = "Create New Account"
 	c.Data["PageIsAdmin"] = true
@@ -148,6 +156,7 @@ func prepareUserInfo(c *context.Context) *models.User {
 	return u
 }
 
+// EditUser shows edit user page
 func EditUser(c *context.Context) {
 	c.Data["Title"] = "Edit Account"
 	c.Data["PageIsAdmin"] = true
@@ -162,6 +171,7 @@ func EditUser(c *context.Context) {
 	c.HTML(200, USER_EDIT)
 }
 
+// EditUserPost edits an user
 func EditUserPost(c *context.Context, f form.AdminEditUser) {
 	c.Data["Title"] = "Edit Account"
 	c.Data["PageIsAdmin"] = true
@@ -247,6 +257,7 @@ func EditUserPost(c *context.Context, f form.AdminEditUser) {
 	c.Redirect(setting.AppSubURL + "/admin/users/" + c.Params(":userid"))
 }
 
+// DeleteUser deletes an user
 func DeleteUser(c *context.Context) {
 	u, err := models.GetUserByID(c.ParamsInt64(":userid"))
 	if err != nil {