diff options
Diffstat (limited to 'routers/web/repo/setting.go')
-rw-r--r-- | routers/web/repo/setting.go | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/routers/web/repo/setting.go b/routers/web/repo/setting.go index e71a5bf482..b104ede005 100644 --- a/routers/web/repo/setting.go +++ b/routers/web/repo/setting.go @@ -16,6 +16,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/db" + unit_model "code.gitea.io/gitea/models/unit" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" @@ -337,7 +338,7 @@ func SettingsPost(ctx *context.Context) { case "advanced": var repoChanged bool var units []models.RepoUnit - var deleteUnitTypes []models.UnitType + var deleteUnitTypes []unit_model.Type // This section doesn't require repo_name/RepoName to be set in the form, don't show it // as an error on the UI for this action @@ -348,7 +349,7 @@ func SettingsPost(ctx *context.Context) { repoChanged = true } - if form.EnableWiki && form.EnableExternalWiki && !models.UnitTypeExternalWiki.UnitGlobalDisabled() { + if form.EnableWiki && form.EnableExternalWiki && !unit_model.TypeExternalWiki.UnitGlobalDisabled() { if !validation.IsValidExternalURL(form.ExternalWikiURL) { ctx.Flash.Error(ctx.Tr("repo.settings.external_wiki_url_error")) ctx.Redirect(repo.Link() + "/settings") @@ -357,29 +358,29 @@ func SettingsPost(ctx *context.Context) { units = append(units, models.RepoUnit{ RepoID: repo.ID, - Type: models.UnitTypeExternalWiki, + Type: unit_model.TypeExternalWiki, Config: &models.ExternalWikiConfig{ ExternalWikiURL: form.ExternalWikiURL, }, }) - deleteUnitTypes = append(deleteUnitTypes, models.UnitTypeWiki) - } else if form.EnableWiki && !form.EnableExternalWiki && !models.UnitTypeWiki.UnitGlobalDisabled() { + deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeWiki) + } else if form.EnableWiki && !form.EnableExternalWiki && !unit_model.TypeWiki.UnitGlobalDisabled() { units = append(units, models.RepoUnit{ RepoID: repo.ID, - Type: models.UnitTypeWiki, + Type: unit_model.TypeWiki, Config: new(models.UnitConfig), }) - deleteUnitTypes = append(deleteUnitTypes, models.UnitTypeExternalWiki) + deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeExternalWiki) } else { - if !models.UnitTypeExternalWiki.UnitGlobalDisabled() { - deleteUnitTypes = append(deleteUnitTypes, models.UnitTypeExternalWiki) + if !unit_model.TypeExternalWiki.UnitGlobalDisabled() { + deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeExternalWiki) } - if !models.UnitTypeWiki.UnitGlobalDisabled() { - deleteUnitTypes = append(deleteUnitTypes, models.UnitTypeWiki) + if !unit_model.TypeWiki.UnitGlobalDisabled() { + deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeWiki) } } - if form.EnableIssues && form.EnableExternalTracker && !models.UnitTypeExternalTracker.UnitGlobalDisabled() { + if form.EnableIssues && form.EnableExternalTracker && !unit_model.TypeExternalTracker.UnitGlobalDisabled() { if !validation.IsValidExternalURL(form.ExternalTrackerURL) { ctx.Flash.Error(ctx.Tr("repo.settings.external_tracker_url_error")) ctx.Redirect(repo.Link() + "/settings") @@ -392,47 +393,47 @@ func SettingsPost(ctx *context.Context) { } units = append(units, models.RepoUnit{ RepoID: repo.ID, - Type: models.UnitTypeExternalTracker, + Type: unit_model.TypeExternalTracker, Config: &models.ExternalTrackerConfig{ ExternalTrackerURL: form.ExternalTrackerURL, ExternalTrackerFormat: form.TrackerURLFormat, ExternalTrackerStyle: form.TrackerIssueStyle, }, }) - deleteUnitTypes = append(deleteUnitTypes, models.UnitTypeIssues) - } else if form.EnableIssues && !form.EnableExternalTracker && !models.UnitTypeIssues.UnitGlobalDisabled() { + deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeIssues) + } else if form.EnableIssues && !form.EnableExternalTracker && !unit_model.TypeIssues.UnitGlobalDisabled() { units = append(units, models.RepoUnit{ RepoID: repo.ID, - Type: models.UnitTypeIssues, + Type: unit_model.TypeIssues, Config: &models.IssuesConfig{ EnableTimetracker: form.EnableTimetracker, AllowOnlyContributorsToTrackTime: form.AllowOnlyContributorsToTrackTime, EnableDependencies: form.EnableIssueDependencies, }, }) - deleteUnitTypes = append(deleteUnitTypes, models.UnitTypeExternalTracker) + deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeExternalTracker) } else { - if !models.UnitTypeExternalTracker.UnitGlobalDisabled() { - deleteUnitTypes = append(deleteUnitTypes, models.UnitTypeExternalTracker) + if !unit_model.TypeExternalTracker.UnitGlobalDisabled() { + deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeExternalTracker) } - if !models.UnitTypeIssues.UnitGlobalDisabled() { - deleteUnitTypes = append(deleteUnitTypes, models.UnitTypeIssues) + if !unit_model.TypeIssues.UnitGlobalDisabled() { + deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeIssues) } } - if form.EnableProjects && !models.UnitTypeProjects.UnitGlobalDisabled() { + if form.EnableProjects && !unit_model.TypeProjects.UnitGlobalDisabled() { units = append(units, models.RepoUnit{ RepoID: repo.ID, - Type: models.UnitTypeProjects, + Type: unit_model.TypeProjects, }) - } else if !models.UnitTypeProjects.UnitGlobalDisabled() { - deleteUnitTypes = append(deleteUnitTypes, models.UnitTypeProjects) + } else if !unit_model.TypeProjects.UnitGlobalDisabled() { + deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeProjects) } - if form.EnablePulls && !models.UnitTypePullRequests.UnitGlobalDisabled() { + if form.EnablePulls && !unit_model.TypePullRequests.UnitGlobalDisabled() { units = append(units, models.RepoUnit{ RepoID: repo.ID, - Type: models.UnitTypePullRequests, + Type: unit_model.TypePullRequests, Config: &models.PullRequestsConfig{ IgnoreWhitespaceConflicts: form.PullsIgnoreWhitespace, AllowMerge: form.PullsAllowMerge, @@ -445,8 +446,8 @@ func SettingsPost(ctx *context.Context) { DefaultMergeStyle: models.MergeStyle(form.PullsDefaultMergeStyle), }, }) - } else if !models.UnitTypePullRequests.UnitGlobalDisabled() { - deleteUnitTypes = append(deleteUnitTypes, models.UnitTypePullRequests) + } else if !unit_model.TypePullRequests.UnitGlobalDisabled() { + deleteUnitTypes = append(deleteUnitTypes, unit_model.TypePullRequests) } if err := models.UpdateRepositoryUnits(repo, units, deleteUnitTypes); err != nil { @@ -786,7 +787,7 @@ func Collaboration(ctx *context.Context) { ctx.Data["OrgID"] = ctx.Repo.Repository.OwnerID ctx.Data["OrgName"] = ctx.Repo.Repository.OwnerName ctx.Data["Org"] = ctx.Repo.Repository.Owner - ctx.Data["Units"] = models.Units + ctx.Data["Units"] = unit_model.Units ctx.HTML(http.StatusOK, tplCollaboration) } |