Browse Source

Fixed GoStandards in pages routes

Yoginth 7 năm trước cách đây
mục cha
commit
e5f9ee999a
5 tập tin đã thay đổi với 89 bổ sung89 xóa
  1. 6 6
      routes/org/members.go
  2. 7 7
      routes/org/org.go
  3. 14 14
      routes/org/setting.go
  4. 18 18
      routes/org/teams.go
  5. 44 44
      routes/pages/pages.go

+ 6 - 6
routes/org/members.go

@@ -18,11 +18,11 @@ import (
 )
 
 const (
-	// MEMBERS page template
-	MEMBERS = "org/member/members"
+	// MembersTPL page template
+	MembersTPL = "org/member/members"
 
-	//MEMBER_INVITE page template
-	MEMBER_INVITE = "org/member/invite"
+	//MemberInviteTPL page template
+	MemberInviteTPL = "org/member/invite"
 )
 
 //Members shows organization members
@@ -37,7 +37,7 @@ func Members(c *context.Context) {
 	}
 	c.Data["Members"] = org.Members
 
-	c.HTML(200, MEMBERS)
+	c.HTML(200, MembersTPL)
 }
 
 // MembersAction handle the user actions
@@ -136,5 +136,5 @@ func Invitation(c *context.Context) {
 		return
 	}
 
-	c.HTML(200, MEMBER_INVITE)
+	c.HTML(200, MemberInviteTPL)
 }

+ 7 - 7
routes/org/org.go

@@ -16,14 +16,14 @@ import (
 )
 
 const (
-	// CREATE organization page template
-	CREATE = "org/create"
+	// CreateTPL organization page template
+	CreateTPL = "org/create"
 )
 
 // Create renders the page to create an organization
 func Create(c *context.Context) {
 	c.Data["Title"] = c.Tr("new_org")
-	c.HTML(200, CREATE)
+	c.HTML(200, CreateTPL)
 }
 
 // CreatePost creates an organization with the body fields
@@ -31,7 +31,7 @@ func CreatePost(c *context.Context, f form.CreateOrg) {
 	c.Data["Title"] = c.Tr("new_org")
 
 	if c.HasError() {
-		c.HTML(200, CREATE)
+		c.HTML(200, CreateTPL)
 		return
 	}
 
@@ -46,11 +46,11 @@ func CreatePost(c *context.Context, f form.CreateOrg) {
 		c.Data["Err_OrgName"] = true
 		switch {
 		case models.IsErrUserAlreadyExist(err):
-			c.RenderWithErr(c.Tr("form.org_name_been_taken"), CREATE, &f)
+			c.RenderWithErr(c.Tr("form.org_name_been_taken"), CreateTPL, &f)
 		case models.IsErrNameReserved(err):
-			c.RenderWithErr(c.Tr("org.form.name_reserved", err.(models.ErrNameReserved).Name), CREATE, &f)
+			c.RenderWithErr(c.Tr("org.form.name_reserved", err.(models.ErrNameReserved).Name), CreateTPL, &f)
 		case models.IsErrNamePatternNotAllowed(err):
-			c.RenderWithErr(c.Tr("org.form.name_pattern_not_allowed", err.(models.ErrNamePatternNotAllowed).Pattern), CREATE, &f)
+			c.RenderWithErr(c.Tr("org.form.name_pattern_not_allowed", err.(models.ErrNamePatternNotAllowed).Pattern), CreateTPL, &f)
 		default:
 			c.Handle(500, "CreateOrganization", err)
 		}

+ 14 - 14
routes/org/setting.go

@@ -19,21 +19,21 @@ import (
 )
 
 const (
-	// SETTINGS_OPTIONS page template
-	SETTINGS_OPTIONS = "org/settings/options"
+	// SettingsOptionsTPL page template
+	SettingsOptionsTPL = "org/settings/options"
 
-	// SETTINGS_DELETE page template
-	SETTINGS_DELETE = "org/settings/delete"
+	// SettingsDeleteTPL page template
+	SettingsDeleteTPL = "org/settings/delete"
 
-	// SETTINGS_WEBHOOKS page template
-	SETTINGS_WEBHOOKS = "org/settings/webhooks"
+	// SettingsWebhooksTPL page template
+	SettingsWebhooksTPL = "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)
+	c.HTML(200, SettingsOptionsTPL)
 }
 
 // SettingsPost updates organization settings with the body fields
@@ -42,7 +42,7 @@ func SettingsPost(c *context.Context, f form.UpdateOrgSetting) {
 	c.Data["PageIsSettingsOptions"] = true
 
 	if c.HasError() {
-		c.HTML(200, SETTINGS_OPTIONS)
+		c.HTML(200, SettingsOptionsTPL)
 		return
 	}
 
@@ -56,15 +56,15 @@ func SettingsPost(c *context.Context, f form.UpdateOrgSetting) {
 			return
 		} else if isExist {
 			c.Data["OrgName"] = true
-			c.RenderWithErr(c.Tr("form.username_been_taken"), SETTINGS_OPTIONS, &f)
+			c.RenderWithErr(c.Tr("form.username_been_taken"), SettingsOptionsTPL, &f)
 			return
 		} else if err = models.ChangeUserName(org, f.Name); err != nil {
 			c.Data["OrgName"] = true
 			switch {
 			case models.IsErrNameReserved(err):
-				c.RenderWithErr(c.Tr("user.form.name_reserved"), SETTINGS_OPTIONS, &f)
+				c.RenderWithErr(c.Tr("user.form.name_reserved"), SettingsOptionsTPL, &f)
 			case models.IsErrNamePatternNotAllowed(err):
-				c.RenderWithErr(c.Tr("user.form.name_pattern_not_allowed"), SETTINGS_OPTIONS, &f)
+				c.RenderWithErr(c.Tr("user.form.name_pattern_not_allowed"), SettingsOptionsTPL, &f)
 			default:
 				c.Handle(500, "ChangeUserName", err)
 			}
@@ -132,7 +132,7 @@ func SettingsDelete(c *context.Context) {
 		// 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)
+				c.RenderWithErr(c.Tr("form.enterred_invalid_password"), SettingsDeleteTPL, nil)
 			} else {
 				c.ServerError("UserLogin", err)
 			}
@@ -154,7 +154,7 @@ func SettingsDelete(c *context.Context) {
 		return
 	}
 
-	c.Success(SETTINGS_DELETE)
+	c.Success(SettingsDeleteTPL)
 }
 
 // Webhooks shows organization webhooks settings
@@ -172,7 +172,7 @@ func Webhooks(c *context.Context) {
 	}
 
 	c.Data["Webhooks"] = ws
-	c.HTML(200, SETTINGS_WEBHOOKS)
+	c.HTML(200, SettingsWebhooksTPL)
 }
 
 // DeleteWbhook deletes an organization webhook

+ 18 - 18
routes/org/teams.go

@@ -19,17 +19,17 @@ import (
 )
 
 const (
-	// TEAMS page template
-	TEAMS = "org/team/teams"
+	// TeamsTPL page template
+	TeamsTPL = "org/team/teams"
 
-	// TEAM_NEW page template
-	TEAM_NEW = "org/team/new"
+	// TeamNewTPL page template
+	TeamNewTPL = "org/team/new"
 
-	// TEAM_MEMBERS page template
-	TEAM_MEMBERS = "org/team/members"
+	// TeamMembersTPL page template
+	TeamMembersTPL = "org/team/members"
 
-	// TEAM_REPOSITORIES page template
-	TEAM_REPOSITORIES = "org/team/repositories"
+	// TeamRepositoriesTPL page template
+	TeamRepositoriesTPL = "org/team/repositories"
 )
 
 // Teams shows team page
@@ -46,7 +46,7 @@ func Teams(c *context.Context) {
 	}
 	c.Data["Teams"] = org.Teams
 
-	c.HTML(200, TEAMS)
+	c.HTML(200, TeamsTPL)
 }
 
 // TeamsAction handle the user action
@@ -167,7 +167,7 @@ func NewTeam(c *context.Context) {
 	c.Data["PageIsOrgTeams"] = true
 	c.Data["PageIsOrgTeamsNew"] = true
 	c.Data["Team"] = &models.Team{}
-	c.HTML(200, TEAM_NEW)
+	c.HTML(200, TeamNewTPL)
 }
 
 // NewTeamPost creates an organization with the body fields
@@ -185,7 +185,7 @@ func NewTeamPost(c *context.Context, f form.CreateTeam) {
 	c.Data["Team"] = t
 
 	if c.HasError() {
-		c.HTML(200, TEAM_NEW)
+		c.HTML(200, TeamNewTPL)
 		return
 	}
 
@@ -194,9 +194,9 @@ func NewTeamPost(c *context.Context, f form.CreateTeam) {
 		c.Data["Err_TeamName"] = true
 		switch {
 		case models.IsErrTeamAlreadyExist(err):
-			c.RenderWithErr(c.Tr("form.team_name_been_taken"), TEAM_NEW, &f)
+			c.RenderWithErr(c.Tr("form.team_name_been_taken"), TeamNewTPL, &f)
 		case models.IsErrNameReserved(err):
-			c.RenderWithErr(c.Tr("org.form.team_name_reserved", err.(models.ErrNameReserved).Name), TEAM_NEW, &f)
+			c.RenderWithErr(c.Tr("org.form.team_name_reserved", err.(models.ErrNameReserved).Name), TeamNewTPL, &f)
 		default:
 			c.Handle(500, "NewTeam", err)
 		}
@@ -214,7 +214,7 @@ func TeamMembers(c *context.Context) {
 		c.Handle(500, "GetMembers", err)
 		return
 	}
-	c.HTML(200, TEAM_MEMBERS)
+	c.HTML(200, TeamMembersTPL)
 }
 
 // TeamRepositories shows team repositoies page
@@ -225,7 +225,7 @@ func TeamRepositories(c *context.Context) {
 		c.Handle(500, "GetRepositories", err)
 		return
 	}
-	c.HTML(200, TEAM_REPOSITORIES)
+	c.HTML(200, TeamRepositoriesTPL)
 }
 
 // EditTeam shows edit team page
@@ -234,7 +234,7 @@ func EditTeam(c *context.Context) {
 	c.Data["PageIsOrgTeams"] = true
 	c.Data["team_name"] = c.Org.Team.Name
 	c.Data["desc"] = c.Org.Team.Description
-	c.HTML(200, TEAM_NEW)
+	c.HTML(200, TeamNewTPL)
 }
 
 // EditTeamPost edit team with the body fields
@@ -245,7 +245,7 @@ func EditTeamPost(c *context.Context, f form.CreateTeam) {
 	c.Data["Team"] = t
 
 	if c.HasError() {
-		c.HTML(200, TEAM_NEW)
+		c.HTML(200, TeamNewTPL)
 		return
 	}
 
@@ -277,7 +277,7 @@ func EditTeamPost(c *context.Context, f form.CreateTeam) {
 		c.Data["Err_TeamName"] = true
 		switch {
 		case models.IsErrTeamAlreadyExist(err):
-			c.RenderWithErr(c.Tr("form.team_name_been_taken"), TEAM_NEW, &f)
+			c.RenderWithErr(c.Tr("form.team_name_been_taken"), TeamNewTPL, &f)
 		default:
 			c.Handle(500, "UpdateTeam", err)
 		}

+ 44 - 44
routes/pages/pages.go

@@ -11,85 +11,85 @@ import (
 )
 
 const (
-	// ABOUT page template
-	ABOUT = "pages/about"
+	// AboutTPL page template
+	AboutTPL = "pages/about"
 
-	// FAQ page template
-	FAQ = "pages/faq"
+	// FaqTPL page template
+	FaqTPL = "pages/faq"
 
-	// PRIVACY page template
-	PRIVACY = "pages/privacy"
+	// PrivacyTPL page template
+	PrivacyTPL = "pages/privacy"
 
-	// TOS page template
-	TOS = "pages/tos"
+	// TosTPL page template
+	TosTPL = "pages/tos"
 
-	// BRAND page template
-	BRAND = "pages/brand"
+	// BrandTPL page template
+	BrandTPL = "pages/brand"
 
-	// CONTACT page template
-	CONTACT = "pages/contact"
+	// ContactTPL page template
+	ContactTPL = "pages/contact"
 
-	// CONTRIBUTE page template
-	CONTRIBUTE = "pages/contribute"
+	// ContributeTPL page template
+	ContributeTPL = "pages/contribute"
 
-	// SECURITY page template
-	SECURITY = "pages/security"
+	// SecurityTPL page template
+	SecurityTPL = "pages/security"
 
-	// VERIFIED page template
-	VERIFIED = "pages/verified"
+	// VerifiedTPL page template
+	VerifiedTPL = "pages/verified"
 
-	// MAKERS page template
-	MAKERS = "pages/makers"
+	// MakersTPL page template
+	MakersTPL = "pages/makers"
 
-	// HELP page template
-	HELP = "pages/help"
+	// HelpTPL page template
+	HelpTPL = "pages/help"
 
-	// FEATURES page template
-	FEATURES = "pages/features"
+	// FeaturesTPL page template
+	FeaturesTPL = "pages/features"
 
-	// FEATUREREQUEST page template
-	FEATUREREQUEST = "pages/request"
+	// FeatureRequestTPL page template
+	FeatureRequestTPL = "pages/request"
 
-	// SPONSORSHIP page template
-	SPONSORSHIP = "pages/sponsorship"
+	// SponsorshipTPL page template
+	SponsorshipTPL = "pages/sponsorship"
 
-	// SITEMAP page template
-	SITEMAP = "pages/sitemap"
+	// SitemapTPL page template
+	SitemapTPL = "pages/sitemap"
 )
 
 // About shows about page
 func About(c *context.Context) {
 	c.Data["Title"] = "About"
 
-	c.HTML(200, ABOUT)
+	c.HTML(200, AboutTPL)
 }
 
 // Faq shows faq page
 func Faq(c *context.Context) {
 	c.Data["Title"] = "FAQ"
 
-	c.HTML(200, FAQ)
+	c.HTML(200, FaqTPL)
 }
 
 // Privacy shows privacy page
 func Privacy(c *context.Context) {
 	c.Data["Title"] = "Privacy Policy"
 
-	c.HTML(200, PRIVACY)
+	c.HTML(200, PrivacyTPL)
 }
 
 // Tos shows tos page
 func Tos(c *context.Context) {
 	c.Data["Title"] = "Terms of Service"
 
-	c.HTML(200, TOS)
+	c.HTML(200, TosTPL)
 }
 
 // Brand shows brand page
 func Brand(c *context.Context) {
 	c.Data["Title"] = "Gitote Brand"
 
-	c.HTML(200, BRAND)
+	c.HTML(200, BrandTPL)
 }
 
 // Contribute shows contribute page
@@ -97,28 +97,28 @@ func Contribute(c *context.Context) {
 	c.Data["PageIsContribute"] = true
 	c.Data["Title"] = "Contribute"
 
-	c.HTML(200, CONTRIBUTE)
+	c.HTML(200, ContributeTPL)
 }
 
 // Security shows security page
 func Security(c *context.Context) {
 	c.Data["Title"] = "Security"
 
-	c.HTML(200, SECURITY)
+	c.HTML(200, SecurityTPL)
 }
 
 // Verified shows verified page
 func Verified(c *context.Context) {
 	c.Data["Title"] = "Verified"
 
-	c.HTML(200, VERIFIED)
+	c.HTML(200, VerifiedTPL)
 }
 
 // Makers shows maker page
 func Makers(c *context.Context) {
 	c.Data["Title"] = "Makers"
 
-	c.HTML(200, MAKERS)
+	c.HTML(200, MakersTPL)
 }
 
 // Help shows help page
@@ -126,14 +126,14 @@ func Help(c *context.Context) {
 	c.Data["Title"] = "Help"
 	c.Data["PageIsHelp"] = true
 
-	c.HTML(200, HELP)
+	c.HTML(200, HelpTPL)
 }
 
 // Contact shows contact page
 func Contact(c *context.Context) {
 	c.Data["Title"] = "Contact"
 
-	c.HTML(200, CONTACT)
+	c.HTML(200, ContactTPL)
 }
 
 // Features shows features page
@@ -141,19 +141,19 @@ func Features(c *context.Context) {
 	c.Data["Title"] = "Features"
 	c.Data["PageIsFeatures"] = true
 
-	c.HTML(200, FEATURES)
+	c.HTML(200, FeaturesTPL)
 }
 
 // FeatureRequest shows feature request page
 func FeatureRequest(c *context.Context) {
 	c.Data["Title"] = "Feature Request"
 
-	c.HTML(200, FEATUREREQUEST)
+	c.HTML(200, FeatureRequestTPL)
 }
 
 // Sponsorship shows sponsorship page
 func Sponsorship(c *context.Context) {
 	c.Data["Title"] = "Sponsorship"
 
-	c.HTML(200, SPONSORSHIP)
+	c.HTML(200, SponsorshipTPL)
 }