diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2016-11-18 11:03:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-18 11:03:03 +0800 |
commit | cf045b029cc11dc48c3a626441b7017710088823 (patch) | |
tree | f234f8ad8b8a548bda4c9d372ca5b9af95b0b40b /routers/org | |
parent | 91953ae9b421300eef79d58891dec7f2026e5d53 (diff) | |
download | gitea-cf045b029cc11dc48c3a626441b7017710088823.tar.gz gitea-cf045b029cc11dc48c3a626441b7017710088823.zip |
golint fixed for parts of routers root, dev, user and org dirs (#167)
* golint fixed for parts of routers root, dev and org dirs
* add user/auth.go golint fixed
* rename unnecessary exported to unexported and user dir golint fixed
Diffstat (limited to 'routers/org')
-rw-r--r-- | routers/org/members.go | 13 | ||||
-rw-r--r-- | routers/org/org.go | 15 | ||||
-rw-r--r-- | routers/org/setting.go | 30 | ||||
-rw-r--r-- | routers/org/teams.go | 40 |
4 files changed, 65 insertions, 33 deletions
diff --git a/routers/org/members.go b/routers/org/members.go index 3afc6e32e5..e7f1960665 100644 --- a/routers/org/members.go +++ b/routers/org/members.go @@ -15,10 +15,13 @@ import ( ) const ( - MEMBERS base.TplName = "org/member/members" - MEMBER_INVITE base.TplName = "org/member/invite" + // tplMembers template for organization members page + tplMembers base.TplName = "org/member/members" + // tplMemberInvite template for orgnization invite page + tplMemberInvite base.TplName = "org/member/invite" ) +// Members render orgnization users page func Members(ctx *context.Context) { org := ctx.Org.Organization ctx.Data["Title"] = org.FullName @@ -30,9 +33,10 @@ func Members(ctx *context.Context) { } ctx.Data["Members"] = org.Members - ctx.HTML(200, MEMBERS) + ctx.HTML(200, tplMembers) } +// MembersAction response for operation to a member of orgnization func MembersAction(ctx *context.Context) { uid := com.StrTo(ctx.Query("uid")).MustInt64() if uid == 0 { @@ -91,6 +95,7 @@ func MembersAction(ctx *context.Context) { } } +// Invitation render organization invitation page func Invitation(ctx *context.Context) { org := ctx.Org.Organization ctx.Data["Title"] = org.FullName @@ -119,5 +124,5 @@ func Invitation(ctx *context.Context) { return } - ctx.HTML(200, MEMBER_INVITE) + ctx.HTML(200, tplMemberInvite) } diff --git a/routers/org/org.go b/routers/org/org.go index 57d41d0e28..1475c6e542 100644 --- a/routers/org/org.go +++ b/routers/org/org.go @@ -14,19 +14,22 @@ import ( ) const ( - CREATE base.TplName = "org/create" + // tplCreateOrg template path for create organization + tplCreateOrg base.TplName = "org/create" ) +// Create render the page for create organization func Create(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("new_org") - ctx.HTML(200, CREATE) + ctx.HTML(200, tplCreateOrg) } +// CreatePost response for create organization func CreatePost(ctx *context.Context, form auth.CreateOrgForm) { ctx.Data["Title"] = ctx.Tr("new_org") if ctx.HasError() { - ctx.HTML(200, CREATE) + ctx.HTML(200, tplCreateOrg) return } @@ -40,11 +43,11 @@ func CreatePost(ctx *context.Context, form auth.CreateOrgForm) { ctx.Data["Err_OrgName"] = true switch { case models.IsErrUserAlreadyExist(err): - ctx.RenderWithErr(ctx.Tr("form.org_name_been_taken"), CREATE, &form) + ctx.RenderWithErr(ctx.Tr("form.org_name_been_taken"), tplCreateOrg, &form) case models.IsErrNameReserved(err): - ctx.RenderWithErr(ctx.Tr("org.form.name_reserved", err.(models.ErrNameReserved).Name), CREATE, &form) + ctx.RenderWithErr(ctx.Tr("org.form.name_reserved", err.(models.ErrNameReserved).Name), tplCreateOrg, &form) case models.IsErrNamePatternNotAllowed(err): - ctx.RenderWithErr(ctx.Tr("org.form.name_pattern_not_allowed", err.(models.ErrNamePatternNotAllowed).Pattern), CREATE, &form) + ctx.RenderWithErr(ctx.Tr("org.form.name_pattern_not_allowed", err.(models.ErrNamePatternNotAllowed).Pattern), tplCreateOrg, &form) default: ctx.Handle(500, "CreateOrganization", err) } diff --git a/routers/org/setting.go b/routers/org/setting.go index ac12efa4af..4a7a891d47 100644 --- a/routers/org/setting.go +++ b/routers/org/setting.go @@ -17,23 +17,28 @@ import ( ) const ( - SETTINGS_OPTIONS base.TplName = "org/settings/options" - SETTINGS_DELETE base.TplName = "org/settings/delete" - SETTINGS_HOOKS base.TplName = "org/settings/hooks" + // tplSettingsOptions template path for render settings + tplSettingsOptions base.TplName = "org/settings/options" + // tplSettingsDelete template path for render delete repository + tplSettingsDelete base.TplName = "org/settings/delete" + // tplSettingsHooks template path for render hook settings + tplSettingsHooks base.TplName = "org/settings/hooks" ) +// Settings render the main settings page func Settings(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("org.settings") ctx.Data["PageIsSettingsOptions"] = true - ctx.HTML(200, SETTINGS_OPTIONS) + ctx.HTML(200, tplSettingsOptions) } +// SettingsPost response for settings change submited func SettingsPost(ctx *context.Context, form auth.UpdateOrgSettingForm) { ctx.Data["Title"] = ctx.Tr("org.settings") ctx.Data["PageIsSettingsOptions"] = true if ctx.HasError() { - ctx.HTML(200, SETTINGS_OPTIONS) + ctx.HTML(200, tplSettingsOptions) return } @@ -47,12 +52,12 @@ func SettingsPost(ctx *context.Context, form auth.UpdateOrgSettingForm) { return } else if isExist { ctx.Data["OrgName"] = true - ctx.RenderWithErr(ctx.Tr("form.username_been_taken"), SETTINGS_OPTIONS, &form) + ctx.RenderWithErr(ctx.Tr("form.username_been_taken"), tplSettingsOptions, &form) return } else if err = models.ChangeUserName(org, form.Name); err != nil { if err == models.ErrUserNameIllegal { ctx.Data["OrgName"] = true - ctx.RenderWithErr(ctx.Tr("form.illegal_username"), SETTINGS_OPTIONS, &form) + ctx.RenderWithErr(ctx.Tr("form.illegal_username"), tplSettingsOptions, &form) } else { ctx.Handle(500, "ChangeUserName", err) } @@ -83,6 +88,7 @@ func SettingsPost(ctx *context.Context, form auth.UpdateOrgSettingForm) { ctx.Redirect(ctx.Org.OrgLink + "/settings") } +// SettingsAvatar response for change avatar on settings page func SettingsAvatar(ctx *context.Context, form auth.AvatarForm) { form.Source = auth.AvatarLocal if err := user.UpdateAvatarSetting(ctx, form, ctx.Org.Organization); err != nil { @@ -94,6 +100,7 @@ func SettingsAvatar(ctx *context.Context, form auth.AvatarForm) { ctx.Redirect(ctx.Org.OrgLink + "/settings") } +// SettingsDeleteAvatar response for delete avatar on setings page func SettingsDeleteAvatar(ctx *context.Context) { if err := ctx.Org.Organization.DeleteAvatar(); err != nil { ctx.Flash.Error(err.Error()) @@ -102,6 +109,7 @@ func SettingsDeleteAvatar(ctx *context.Context) { ctx.Redirect(ctx.Org.OrgLink + "/settings") } +// SettingsDelete response for delete repository func SettingsDelete(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("org.settings") ctx.Data["PageIsSettingsDelete"] = true @@ -110,7 +118,7 @@ func SettingsDelete(ctx *context.Context) { if ctx.Req.Method == "POST" { if _, err := models.UserSignIn(ctx.User.Name, ctx.Query("password")); err != nil { if models.IsErrUserNotExist(err) { - ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_password"), SETTINGS_DELETE, nil) + ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_password"), tplSettingsDelete, nil) } else { ctx.Handle(500, "UserSignIn", err) } @@ -131,9 +139,10 @@ func SettingsDelete(ctx *context.Context) { return } - ctx.HTML(200, SETTINGS_DELETE) + ctx.HTML(200, tplSettingsDelete) } +// Webhooks render webhook list page func Webhooks(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("org.settings") ctx.Data["PageIsSettingsHooks"] = true @@ -147,9 +156,10 @@ func Webhooks(ctx *context.Context) { } ctx.Data["Webhooks"] = ws - ctx.HTML(200, SETTINGS_HOOKS) + ctx.HTML(200, tplSettingsHooks) } +// DeleteWebhook response for delete webhook func DeleteWebhook(ctx *context.Context) { if err := models.DeleteWebhookByOrgID(ctx.Org.Organization.ID, ctx.QueryInt64("id")); err != nil { ctx.Flash.Error("DeleteWebhookByOrgID: " + err.Error()) diff --git a/routers/org/teams.go b/routers/org/teams.go index 8c301277d8..aed5c5bd76 100644 --- a/routers/org/teams.go +++ b/routers/org/teams.go @@ -17,12 +17,17 @@ import ( ) const ( - TEAMS base.TplName = "org/team/teams" - TEAM_NEW base.TplName = "org/team/new" - TEAM_MEMBERS base.TplName = "org/team/members" - TEAM_REPOSITORIES base.TplName = "org/team/repositories" + // tplTeams template path for teams list page + tplTeams base.TplName = "org/team/teams" + // tplTeamNew template path for create new team page + tplTeamNew base.TplName = "org/team/new" + // tplTeamMembers template path for showing team members page + tplTeamMembers base.TplName = "org/team/members" + // tplTeamRepositories template path for showing team repositories page + tplTeamRepositories base.TplName = "org/team/repositories" ) +// Teams render teams list page func Teams(ctx *context.Context) { org := ctx.Org.Organization ctx.Data["Title"] = org.FullName @@ -36,9 +41,10 @@ func Teams(ctx *context.Context) { } ctx.Data["Teams"] = org.Teams - ctx.HTML(200, TEAMS) + ctx.HTML(200, tplTeams) } +// TeamsAction response for join, leave, remove, add operations to team func TeamsAction(ctx *context.Context) { uid := com.StrTo(ctx.Query("uid")).MustInt64() if uid == 0 { @@ -107,6 +113,7 @@ func TeamsAction(ctx *context.Context) { } } +// TeamsRepoAction operate team's repository func TeamsRepoAction(ctx *context.Context) { if !ctx.Org.IsOwner { ctx.Error(404) @@ -141,14 +148,16 @@ func TeamsRepoAction(ctx *context.Context) { ctx.Redirect(ctx.Org.OrgLink + "/teams/" + ctx.Org.Team.LowerName + "/repositories") } +// NewTeam render create new team page func NewTeam(ctx *context.Context) { ctx.Data["Title"] = ctx.Org.Organization.FullName ctx.Data["PageIsOrgTeams"] = true ctx.Data["PageIsOrgTeamsNew"] = true ctx.Data["Team"] = &models.Team{} - ctx.HTML(200, TEAM_NEW) + ctx.HTML(200, tplTeamNew) } +// NewTeamPost response for create new team func NewTeamPost(ctx *context.Context, form auth.CreateTeamForm) { ctx.Data["Title"] = ctx.Org.Organization.FullName ctx.Data["PageIsOrgTeams"] = true @@ -163,7 +172,7 @@ func NewTeamPost(ctx *context.Context, form auth.CreateTeamForm) { ctx.Data["Team"] = t if ctx.HasError() { - ctx.HTML(200, TEAM_NEW) + ctx.HTML(200, tplTeamNew) return } @@ -171,7 +180,7 @@ func NewTeamPost(ctx *context.Context, form auth.CreateTeamForm) { ctx.Data["Err_TeamName"] = true switch { case models.IsErrTeamAlreadyExist(err): - ctx.RenderWithErr(ctx.Tr("form.team_name_been_taken"), TEAM_NEW, &form) + ctx.RenderWithErr(ctx.Tr("form.team_name_been_taken"), tplTeamNew, &form) default: ctx.Handle(500, "NewTeam", err) } @@ -181,6 +190,7 @@ func NewTeamPost(ctx *context.Context, form auth.CreateTeamForm) { ctx.Redirect(ctx.Org.OrgLink + "/teams/" + t.LowerName) } +// TeamMembers render team members page func TeamMembers(ctx *context.Context) { ctx.Data["Title"] = ctx.Org.Team.Name ctx.Data["PageIsOrgTeams"] = true @@ -188,9 +198,10 @@ func TeamMembers(ctx *context.Context) { ctx.Handle(500, "GetMembers", err) return } - ctx.HTML(200, TEAM_MEMBERS) + ctx.HTML(200, tplTeamMembers) } +// TeamRepositories show the repositories of team func TeamRepositories(ctx *context.Context) { ctx.Data["Title"] = ctx.Org.Team.Name ctx.Data["PageIsOrgTeams"] = true @@ -198,17 +209,19 @@ func TeamRepositories(ctx *context.Context) { ctx.Handle(500, "GetRepositories", err) return } - ctx.HTML(200, TEAM_REPOSITORIES) + ctx.HTML(200, tplTeamRepositories) } +// EditTeam render team edit page func EditTeam(ctx *context.Context) { ctx.Data["Title"] = ctx.Org.Organization.FullName ctx.Data["PageIsOrgTeams"] = true ctx.Data["team_name"] = ctx.Org.Team.Name ctx.Data["desc"] = ctx.Org.Team.Description - ctx.HTML(200, TEAM_NEW) + ctx.HTML(200, tplTeamNew) } +// EditTeamPost response for modify team information func EditTeamPost(ctx *context.Context, form auth.CreateTeamForm) { t := ctx.Org.Team ctx.Data["Title"] = ctx.Org.Organization.FullName @@ -216,7 +229,7 @@ func EditTeamPost(ctx *context.Context, form auth.CreateTeamForm) { ctx.Data["Team"] = t if ctx.HasError() { - ctx.HTML(200, TEAM_NEW) + ctx.HTML(200, tplTeamNew) return } @@ -247,7 +260,7 @@ func EditTeamPost(ctx *context.Context, form auth.CreateTeamForm) { ctx.Data["Err_TeamName"] = true switch { case models.IsErrTeamAlreadyExist(err): - ctx.RenderWithErr(ctx.Tr("form.team_name_been_taken"), TEAM_NEW, &form) + ctx.RenderWithErr(ctx.Tr("form.team_name_been_taken"), tplTeamNew, &form) default: ctx.Handle(500, "UpdateTeam", err) } @@ -256,6 +269,7 @@ func EditTeamPost(ctx *context.Context, form auth.CreateTeamForm) { ctx.Redirect(ctx.Org.OrgLink + "/teams/" + t.LowerName) } +// DeleteTeam response for the delete team request func DeleteTeam(ctx *context.Context) { if err := models.DeleteTeam(ctx.Org.Team); err != nil { ctx.Flash.Error("DeleteTeam: " + err.Error()) |