mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Move some files into models' sub packages (#20262)
* Move some files into models' sub packages * Move functions * merge main branch * Fix check * fix check * Fix some tests * Fix lint * Fix lint * Revert lint changes * Fix error comments * Fix lint Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
@@ -15,7 +15,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
activities_model "code.gitea.io/gitea/models/activities"
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
@@ -128,7 +128,7 @@ func Dashboard(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("admin.dashboard")
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
ctx.Data["PageIsAdminDashboard"] = true
|
||||
ctx.Data["Stats"] = models.GetStatistic()
|
||||
ctx.Data["Stats"] = activities_model.GetStatistic()
|
||||
ctx.Data["NeedUpdate"] = updatechecker.GetNeedUpdate()
|
||||
ctx.Data["RemoteVersion"] = updatechecker.GetRemoteVersion()
|
||||
// FIXME: update periodically
|
||||
@@ -144,7 +144,7 @@ func DashboardPost(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("admin.dashboard")
|
||||
ctx.Data["PageIsAdmin"] = true
|
||||
ctx.Data["PageIsAdminDashboard"] = true
|
||||
ctx.Data["Stats"] = models.GetStatistic()
|
||||
ctx.Data["Stats"] = activities_model.GetStatistic()
|
||||
updateSystemStatus()
|
||||
ctx.Data["SysStatus"] = sysStatus
|
||||
|
||||
|
@@ -9,13 +9,13 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
repo_module "code.gitea.io/gitea/modules/repository"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
"code.gitea.io/gitea/routers/web/explore"
|
||||
@@ -148,7 +148,7 @@ func AdoptOrDeleteRepository(ctx *context.Context) {
|
||||
if has || !isDir {
|
||||
// Fallthrough to failure mode
|
||||
} else if action == "adopt" {
|
||||
if _, err := repo_service.AdoptRepository(ctx.Doer, ctxUser, models.CreateRepoOptions{
|
||||
if _, err := repo_service.AdoptRepository(ctx.Doer, ctxUser, repo_module.CreateRepoOptions{
|
||||
Name: dirSplit[1],
|
||||
IsPrivate: true,
|
||||
}); err != nil {
|
||||
|
@@ -15,8 +15,8 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/auth"
|
||||
org_model "code.gitea.io/gitea/models/organization"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
@@ -296,7 +296,7 @@ func InfoOAuth(ctx *context.Context) {
|
||||
// returns a list of "org" and "org:team" strings,
|
||||
// that the given user is a part of.
|
||||
func getOAuthGroupsForUser(user *user_model.User) ([]string, error) {
|
||||
orgs, err := models.GetUserOrgsList(user)
|
||||
orgs, err := org_model.GetUserOrgsList(user)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("GetUserOrgList: %v", err)
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
activities_model "code.gitea.io/gitea/models/activities"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/markup"
|
||||
"code.gitea.io/gitea/modules/markup/markdown"
|
||||
@@ -23,33 +23,33 @@ import (
|
||||
"github.com/gorilla/feeds"
|
||||
)
|
||||
|
||||
func toBranchLink(act *models.Action) string {
|
||||
func toBranchLink(act *activities_model.Action) string {
|
||||
return act.GetRepoLink() + "/src/branch/" + util.PathEscapeSegments(act.GetBranch())
|
||||
}
|
||||
|
||||
func toTagLink(act *models.Action) string {
|
||||
func toTagLink(act *activities_model.Action) string {
|
||||
return act.GetRepoLink() + "/src/tag/" + util.PathEscapeSegments(act.GetTag())
|
||||
}
|
||||
|
||||
func toIssueLink(act *models.Action) string {
|
||||
func toIssueLink(act *activities_model.Action) string {
|
||||
return act.GetRepoLink() + "/issues/" + url.PathEscape(act.GetIssueInfos()[0])
|
||||
}
|
||||
|
||||
func toPullLink(act *models.Action) string {
|
||||
func toPullLink(act *activities_model.Action) string {
|
||||
return act.GetRepoLink() + "/pulls/" + url.PathEscape(act.GetIssueInfos()[0])
|
||||
}
|
||||
|
||||
func toSrcLink(act *models.Action) string {
|
||||
func toSrcLink(act *activities_model.Action) string {
|
||||
return act.GetRepoLink() + "/src/" + util.PathEscapeSegments(act.GetBranch())
|
||||
}
|
||||
|
||||
func toReleaseLink(act *models.Action) string {
|
||||
func toReleaseLink(act *activities_model.Action) string {
|
||||
return act.GetRepoLink() + "/releases/tag/" + util.PathEscapeSegments(act.GetBranch())
|
||||
}
|
||||
|
||||
// renderMarkdown creates a minimal markdown render context from an action.
|
||||
// If rendering fails, the original markdown text is returned
|
||||
func renderMarkdown(ctx *context.Context, act *models.Action, content string) string {
|
||||
func renderMarkdown(ctx *context.Context, act *activities_model.Action, content string) string {
|
||||
markdownCtx := &markup.RenderContext{
|
||||
Ctx: ctx,
|
||||
URLPrefix: act.GetRepoLink(),
|
||||
@@ -67,7 +67,7 @@ func renderMarkdown(ctx *context.Context, act *models.Action, content string) st
|
||||
}
|
||||
|
||||
// feedActionsToFeedItems convert gitea's Action feed to feeds Item
|
||||
func feedActionsToFeedItems(ctx *context.Context, actions models.ActionList) (items []*feeds.Item, err error) {
|
||||
func feedActionsToFeedItems(ctx *context.Context, actions activities_model.ActionList) (items []*feeds.Item, err error) {
|
||||
for _, act := range actions {
|
||||
act.LoadActUser()
|
||||
|
||||
@@ -78,110 +78,110 @@ func feedActionsToFeedItems(ctx *context.Context, actions models.ActionList) (it
|
||||
// title
|
||||
title = act.ActUser.DisplayName() + " "
|
||||
switch act.OpType {
|
||||
case models.ActionCreateRepo:
|
||||
case activities_model.ActionCreateRepo:
|
||||
title += ctx.TrHTMLEscapeArgs("action.create_repo", act.GetRepoLink(), act.ShortRepoPath())
|
||||
link.Href = act.GetRepoLink()
|
||||
case models.ActionRenameRepo:
|
||||
case activities_model.ActionRenameRepo:
|
||||
title += ctx.TrHTMLEscapeArgs("action.rename_repo", act.GetContent(), act.GetRepoLink(), act.ShortRepoPath())
|
||||
link.Href = act.GetRepoLink()
|
||||
case models.ActionCommitRepo:
|
||||
case activities_model.ActionCommitRepo:
|
||||
link.Href = toBranchLink(act)
|
||||
if len(act.Content) != 0 {
|
||||
title += ctx.TrHTMLEscapeArgs("action.commit_repo", act.GetRepoLink(), link.Href, act.GetBranch(), act.ShortRepoPath())
|
||||
} else {
|
||||
title += ctx.TrHTMLEscapeArgs("action.create_branch", act.GetRepoLink(), link.Href, act.GetBranch(), act.ShortRepoPath())
|
||||
}
|
||||
case models.ActionCreateIssue:
|
||||
case activities_model.ActionCreateIssue:
|
||||
link.Href = toIssueLink(act)
|
||||
title += ctx.TrHTMLEscapeArgs("action.create_issue", link.Href, act.GetIssueInfos()[0], act.ShortRepoPath())
|
||||
case models.ActionCreatePullRequest:
|
||||
case activities_model.ActionCreatePullRequest:
|
||||
link.Href = toPullLink(act)
|
||||
title += ctx.TrHTMLEscapeArgs("action.create_pull_request", link.Href, act.GetIssueInfos()[0], act.ShortRepoPath())
|
||||
case models.ActionTransferRepo:
|
||||
case activities_model.ActionTransferRepo:
|
||||
link.Href = act.GetRepoLink()
|
||||
title += ctx.TrHTMLEscapeArgs("action.transfer_repo", act.GetContent(), act.GetRepoLink(), act.ShortRepoPath())
|
||||
case models.ActionPushTag:
|
||||
case activities_model.ActionPushTag:
|
||||
link.Href = toTagLink(act)
|
||||
title += ctx.TrHTMLEscapeArgs("action.push_tag", act.GetRepoLink(), link.Href, act.GetTag(), act.ShortRepoPath())
|
||||
case models.ActionCommentIssue:
|
||||
case activities_model.ActionCommentIssue:
|
||||
issueLink := toIssueLink(act)
|
||||
if link.Href == "#" {
|
||||
link.Href = issueLink
|
||||
}
|
||||
title += ctx.TrHTMLEscapeArgs("action.comment_issue", issueLink, act.GetIssueInfos()[0], act.ShortRepoPath())
|
||||
case models.ActionMergePullRequest:
|
||||
case activities_model.ActionMergePullRequest:
|
||||
pullLink := toPullLink(act)
|
||||
if link.Href == "#" {
|
||||
link.Href = pullLink
|
||||
}
|
||||
title += ctx.TrHTMLEscapeArgs("action.merge_pull_request", pullLink, act.GetIssueInfos()[0], act.ShortRepoPath())
|
||||
case models.ActionCloseIssue:
|
||||
case activities_model.ActionCloseIssue:
|
||||
issueLink := toIssueLink(act)
|
||||
if link.Href == "#" {
|
||||
link.Href = issueLink
|
||||
}
|
||||
title += ctx.TrHTMLEscapeArgs("action.close_issue", issueLink, act.GetIssueInfos()[0], act.ShortRepoPath())
|
||||
case models.ActionReopenIssue:
|
||||
case activities_model.ActionReopenIssue:
|
||||
issueLink := toIssueLink(act)
|
||||
if link.Href == "#" {
|
||||
link.Href = issueLink
|
||||
}
|
||||
title += ctx.TrHTMLEscapeArgs("action.reopen_issue", issueLink, act.GetIssueInfos()[0], act.ShortRepoPath())
|
||||
case models.ActionClosePullRequest:
|
||||
case activities_model.ActionClosePullRequest:
|
||||
pullLink := toPullLink(act)
|
||||
if link.Href == "#" {
|
||||
link.Href = pullLink
|
||||
}
|
||||
title += ctx.TrHTMLEscapeArgs("action.close_pull_request", pullLink, act.GetIssueInfos()[0], act.ShortRepoPath())
|
||||
case models.ActionReopenPullRequest:
|
||||
case activities_model.ActionReopenPullRequest:
|
||||
pullLink := toPullLink(act)
|
||||
if link.Href == "#" {
|
||||
link.Href = pullLink
|
||||
}
|
||||
title += ctx.TrHTMLEscapeArgs("action.reopen_pull_request", pullLink, act.GetIssueInfos()[0], act.ShortRepoPath())
|
||||
case models.ActionDeleteTag:
|
||||
case activities_model.ActionDeleteTag:
|
||||
link.Href = act.GetRepoLink()
|
||||
title += ctx.TrHTMLEscapeArgs("action.delete_tag", act.GetRepoLink(), act.GetTag(), act.ShortRepoPath())
|
||||
case models.ActionDeleteBranch:
|
||||
case activities_model.ActionDeleteBranch:
|
||||
link.Href = act.GetRepoLink()
|
||||
title += ctx.TrHTMLEscapeArgs("action.delete_branch", act.GetRepoLink(), html.EscapeString(act.GetBranch()), act.ShortRepoPath())
|
||||
case models.ActionMirrorSyncPush:
|
||||
case activities_model.ActionMirrorSyncPush:
|
||||
srcLink := toSrcLink(act)
|
||||
if link.Href == "#" {
|
||||
link.Href = srcLink
|
||||
}
|
||||
title += ctx.TrHTMLEscapeArgs("action.mirror_sync_push", act.GetRepoLink(), srcLink, act.GetBranch(), act.ShortRepoPath())
|
||||
case models.ActionMirrorSyncCreate:
|
||||
case activities_model.ActionMirrorSyncCreate:
|
||||
srcLink := toSrcLink(act)
|
||||
if link.Href == "#" {
|
||||
link.Href = srcLink
|
||||
}
|
||||
title += ctx.TrHTMLEscapeArgs("action.mirror_sync_create", act.GetRepoLink(), srcLink, act.GetBranch(), act.ShortRepoPath())
|
||||
case models.ActionMirrorSyncDelete:
|
||||
case activities_model.ActionMirrorSyncDelete:
|
||||
link.Href = act.GetRepoLink()
|
||||
title += ctx.TrHTMLEscapeArgs("action.mirror_sync_delete", act.GetRepoLink(), act.GetBranch(), act.ShortRepoPath())
|
||||
case models.ActionApprovePullRequest:
|
||||
case activities_model.ActionApprovePullRequest:
|
||||
pullLink := toPullLink(act)
|
||||
title += ctx.TrHTMLEscapeArgs("action.approve_pull_request", pullLink, act.GetIssueInfos()[0], act.ShortRepoPath())
|
||||
case models.ActionRejectPullRequest:
|
||||
case activities_model.ActionRejectPullRequest:
|
||||
pullLink := toPullLink(act)
|
||||
title += ctx.TrHTMLEscapeArgs("action.reject_pull_request", pullLink, act.GetIssueInfos()[0], act.ShortRepoPath())
|
||||
case models.ActionCommentPull:
|
||||
case activities_model.ActionCommentPull:
|
||||
pullLink := toPullLink(act)
|
||||
title += ctx.TrHTMLEscapeArgs("action.comment_pull", pullLink, act.GetIssueInfos()[0], act.ShortRepoPath())
|
||||
case models.ActionPublishRelease:
|
||||
case activities_model.ActionPublishRelease:
|
||||
releaseLink := toReleaseLink(act)
|
||||
if link.Href == "#" {
|
||||
link.Href = releaseLink
|
||||
}
|
||||
title += ctx.TrHTMLEscapeArgs("action.publish_release", act.GetRepoLink(), releaseLink, act.ShortRepoPath(), act.Content)
|
||||
case models.ActionPullReviewDismissed:
|
||||
case activities_model.ActionPullReviewDismissed:
|
||||
pullLink := toPullLink(act)
|
||||
title += ctx.TrHTMLEscapeArgs("action.review_dismissed", pullLink, act.GetIssueInfos()[0], act.ShortRepoPath(), act.GetIssueInfos()[1])
|
||||
case models.ActionStarRepo:
|
||||
case activities_model.ActionStarRepo:
|
||||
link.Href = act.GetRepoLink()
|
||||
title += ctx.TrHTMLEscapeArgs("action.starred_repo", act.GetRepoLink(), act.GetRepoPath())
|
||||
case models.ActionWatchRepo:
|
||||
case activities_model.ActionWatchRepo:
|
||||
link.Href = act.GetRepoLink()
|
||||
title += ctx.TrHTMLEscapeArgs("action.watched_repo", act.GetRepoLink(), act.GetRepoPath())
|
||||
default:
|
||||
@@ -191,7 +191,7 @@ func feedActionsToFeedItems(ctx *context.Context, actions models.ActionList) (it
|
||||
// description & content
|
||||
{
|
||||
switch act.OpType {
|
||||
case models.ActionCommitRepo, models.ActionMirrorSyncPush:
|
||||
case activities_model.ActionCommitRepo, activities_model.ActionMirrorSyncPush:
|
||||
push := templates.ActionContent2Commits(act)
|
||||
repoLink := act.GetRepoLink()
|
||||
|
||||
@@ -212,20 +212,20 @@ func feedActionsToFeedItems(ctx *context.Context, actions models.ActionList) (it
|
||||
link = &feeds.Link{Href: fmt.Sprintf("%s/commit/%s", act.GetRepoLink(), push.Commits[0].Sha1)}
|
||||
}
|
||||
|
||||
case models.ActionCreateIssue, models.ActionCreatePullRequest:
|
||||
case activities_model.ActionCreateIssue, activities_model.ActionCreatePullRequest:
|
||||
desc = strings.Join(act.GetIssueInfos(), "#")
|
||||
content = renderMarkdown(ctx, act, act.GetIssueContent())
|
||||
case models.ActionCommentIssue, models.ActionApprovePullRequest, models.ActionRejectPullRequest, models.ActionCommentPull:
|
||||
case activities_model.ActionCommentIssue, activities_model.ActionApprovePullRequest, activities_model.ActionRejectPullRequest, activities_model.ActionCommentPull:
|
||||
desc = act.GetIssueTitle()
|
||||
comment := act.GetIssueInfos()[1]
|
||||
if len(comment) != 0 {
|
||||
desc += "\n\n" + renderMarkdown(ctx, act, comment)
|
||||
}
|
||||
case models.ActionMergePullRequest:
|
||||
case activities_model.ActionMergePullRequest:
|
||||
desc = act.GetIssueInfos()[1]
|
||||
case models.ActionCloseIssue, models.ActionReopenIssue, models.ActionClosePullRequest, models.ActionReopenPullRequest:
|
||||
case activities_model.ActionCloseIssue, activities_model.ActionReopenIssue, activities_model.ActionClosePullRequest, activities_model.ActionReopenPullRequest:
|
||||
desc = act.GetIssueTitle()
|
||||
case models.ActionPullReviewDismissed:
|
||||
case activities_model.ActionPullReviewDismissed:
|
||||
desc = ctx.Tr("action.review_dismissed_reason") + "\n\n" + act.GetIssueInfos()[2]
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
activities_model "code.gitea.io/gitea/models/activities"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
|
||||
"github.com/gorilla/feeds"
|
||||
@@ -26,7 +26,7 @@ func ShowUserFeedAtom(ctx *context.Context) {
|
||||
|
||||
// showUserFeed show user activity as RSS / Atom feed
|
||||
func showUserFeed(ctx *context.Context, formatType string) {
|
||||
actions, err := models.GetFeeds(ctx, models.GetFeedsOptions{
|
||||
actions, err := activities_model.GetFeeds(ctx, activities_model.GetFeedsOptions{
|
||||
RequestedUser: ctx.ContextUser,
|
||||
Actor: ctx.Doer,
|
||||
IncludePrivate: false,
|
||||
|
@@ -7,7 +7,7 @@ package feed
|
||||
import (
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
activities_model "code.gitea.io/gitea/models/activities"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
|
||||
// ShowRepoFeed shows user activity on the repo as RSS / Atom feed
|
||||
func ShowRepoFeed(ctx *context.Context, repo *repo_model.Repository, formatType string) {
|
||||
actions, err := models.GetFeeds(ctx, models.GetFeedsOptions{
|
||||
actions, err := activities_model.GetFeeds(ctx, activities_model.GetFeedsOptions{
|
||||
RequestedRepo: repo,
|
||||
Actor: ctx.Doer,
|
||||
IncludePrivate: true,
|
||||
|
@@ -26,6 +26,7 @@ import (
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
"code.gitea.io/gitea/routers/utils"
|
||||
"code.gitea.io/gitea/services/forms"
|
||||
org_service "code.gitea.io/gitea/services/org"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -194,7 +195,7 @@ func TeamsRepoAction(ctx *context.Context) {
|
||||
ctx.ServerError("GetRepositoryByName", err)
|
||||
return
|
||||
}
|
||||
err = models.AddRepository(ctx.Org.Team, repo)
|
||||
err = org_service.TeamAddRepository(ctx.Org.Team, repo)
|
||||
case "remove":
|
||||
err = models.RemoveRepository(ctx.Org.Team, ctx.FormInt64("repoid"))
|
||||
case "addall":
|
||||
|
@@ -8,7 +8,7 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
activities_model "code.gitea.io/gitea/models/activities"
|
||||
"code.gitea.io/gitea/models/unit"
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
@@ -52,7 +52,7 @@ func Activity(ctx *context.Context) {
|
||||
ctx.Data["PeriodText"] = ctx.Tr("repo.activity.period." + ctx.Data["Period"].(string))
|
||||
|
||||
var err error
|
||||
if ctx.Data["Activity"], err = models.GetActivityStats(ctx, ctx.Repo.Repository, timeFrom,
|
||||
if ctx.Data["Activity"], err = activities_model.GetActivityStats(ctx, ctx.Repo.Repository, timeFrom,
|
||||
ctx.Repo.CanRead(unit.TypeReleases),
|
||||
ctx.Repo.CanRead(unit.TypeIssues),
|
||||
ctx.Repo.CanRead(unit.TypePullRequests),
|
||||
@@ -61,7 +61,7 @@ func Activity(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.PageData["repoActivityTopAuthors"], err = models.GetActivityStatsTopAuthors(ctx, ctx.Repo.Repository, timeFrom, 10); err != nil {
|
||||
if ctx.PageData["repoActivityTopAuthors"], err = activities_model.GetActivityStatsTopAuthors(ctx, ctx.Repo.Repository, timeFrom, 10); err != nil {
|
||||
ctx.ServerError("GetActivityStatsTopAuthors", err)
|
||||
return
|
||||
}
|
||||
@@ -94,7 +94,7 @@ func ActivityAuthors(ctx *context.Context) {
|
||||
}
|
||||
|
||||
var err error
|
||||
authors, err := models.GetActivityStatsTopAuthors(ctx, ctx.Repo.Repository, timeFrom, 10)
|
||||
authors, err := activities_model.GetActivityStatsTopAuthors(ctx, ctx.Repo.Repository, timeFrom, 10)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetActivityStatsTopAuthors", err)
|
||||
return
|
||||
|
@@ -17,7 +17,6 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
git_model "code.gitea.io/gitea/models/git"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
access_model "code.gitea.io/gitea/models/perm/access"
|
||||
@@ -459,7 +458,7 @@ func ParseCompareInfo(ctx *context.Context) *CompareInfo {
|
||||
if rootRepo != nil &&
|
||||
rootRepo.ID != ci.HeadRepo.ID &&
|
||||
rootRepo.ID != baseRepo.ID {
|
||||
canRead := models.CheckRepoUnitUser(ctx, rootRepo, ctx.Doer, unit.TypeCode)
|
||||
canRead := access_model.CheckRepoUnitUser(ctx, rootRepo, ctx.Doer, unit.TypeCode)
|
||||
if canRead {
|
||||
ctx.Data["RootRepo"] = rootRepo
|
||||
if !fileOnly {
|
||||
@@ -484,7 +483,7 @@ func ParseCompareInfo(ctx *context.Context) *CompareInfo {
|
||||
ownForkRepo.ID != ci.HeadRepo.ID &&
|
||||
ownForkRepo.ID != baseRepo.ID &&
|
||||
(rootRepo == nil || ownForkRepo.ID != rootRepo.ID) {
|
||||
canRead := models.CheckRepoUnitUser(ctx, ownForkRepo, ctx.Doer, unit.TypeCode)
|
||||
canRead := access_model.CheckRepoUnitUser(ctx, ownForkRepo, ctx.Doer, unit.TypeCode)
|
||||
if canRead {
|
||||
ctx.Data["OwnForkRepo"] = ownForkRepo
|
||||
if !fileOnly {
|
||||
|
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
git_model "code.gitea.io/gitea/models/git"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unit"
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/charset"
|
||||
@@ -763,7 +764,7 @@ func UploadFileToServer(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
upload, err := models.NewUpload(name, buf, file)
|
||||
upload, err := repo_model.NewUpload(name, buf, file)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, fmt.Sprintf("NewUpload: %v", err))
|
||||
return
|
||||
@@ -783,7 +784,7 @@ func RemoveUploadFileFromServer(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := models.DeleteUploadByUUID(form.File); err != nil {
|
||||
if err := repo_model.DeleteUploadByUUID(form.File); err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, fmt.Sprintf("DeleteUploadByUUID: %v", err))
|
||||
return
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
activities_model "code.gitea.io/gitea/models/activities"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
git_model "code.gitea.io/gitea/models/git"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
@@ -1313,7 +1313,7 @@ func ViewIssue(ctx *context.Context) {
|
||||
|
||||
if ctx.IsSigned {
|
||||
// Update issue-user.
|
||||
if err = models.SetIssueReadBy(ctx, issue.ID, ctx.Doer.ID); err != nil {
|
||||
if err = activities_model.SetIssueReadBy(ctx, issue.ID, ctx.Doer.ID); err != nil {
|
||||
ctx.ServerError("ReadBy", err)
|
||||
return
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@ import (
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
activities_model "code.gitea.io/gitea/models/activities"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
git_model "code.gitea.io/gitea/models/git"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
@@ -295,7 +296,7 @@ func checkPullInfo(ctx *context.Context) *issues_model.Issue {
|
||||
|
||||
if ctx.IsSigned {
|
||||
// Update issue-user.
|
||||
if err = models.SetIssueReadBy(ctx, issue.ID, ctx.Doer.ID); err != nil {
|
||||
if err = activities_model.SetIssueReadBy(ctx, issue.ID, ctx.Doer.ID); err != nil {
|
||||
ctx.ServerError("ReadBy", err)
|
||||
return nil
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unit"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
@@ -33,7 +34,7 @@ const (
|
||||
)
|
||||
|
||||
// calReleaseNumCommitsBehind calculates given release has how many commits behind release target.
|
||||
func calReleaseNumCommitsBehind(repoCtx *context.Repository, release *models.Release, countCache map[string]int64) error {
|
||||
func calReleaseNumCommitsBehind(repoCtx *context.Repository, release *repo_model.Release, countCache map[string]int64) error {
|
||||
// Fast return if release target is same as default branch.
|
||||
if repoCtx.BranchName == release.Target {
|
||||
release.NumCommitsBehind = repoCtx.CommitsCount - release.NumCommits
|
||||
@@ -115,25 +116,25 @@ func releasesOrTags(ctx *context.Context, isTagList bool) {
|
||||
writeAccess := ctx.Repo.CanWrite(unit.TypeReleases)
|
||||
ctx.Data["CanCreateRelease"] = writeAccess && !ctx.Repo.Repository.IsArchived
|
||||
|
||||
opts := models.FindReleasesOptions{
|
||||
opts := repo_model.FindReleasesOptions{
|
||||
ListOptions: listOptions,
|
||||
IncludeDrafts: writeAccess && !isTagList,
|
||||
IncludeTags: isTagList,
|
||||
}
|
||||
|
||||
releases, err := models.GetReleasesByRepoID(ctx.Repo.Repository.ID, opts)
|
||||
releases, err := repo_model.GetReleasesByRepoID(ctx.Repo.Repository.ID, opts)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetReleasesByRepoID", err)
|
||||
return
|
||||
}
|
||||
|
||||
count, err := models.GetReleaseCountByRepoID(ctx.Repo.Repository.ID, opts)
|
||||
count, err := repo_model.GetReleaseCountByRepoID(ctx.Repo.Repository.ID, opts)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetReleaseCountByRepoID", err)
|
||||
return
|
||||
}
|
||||
|
||||
if err = models.GetReleaseAttachments(ctx, releases...); err != nil {
|
||||
if err = repo_model.GetReleaseAttachments(ctx, releases...); err != nil {
|
||||
ctx.ServerError("GetReleaseAttachments", err)
|
||||
return
|
||||
}
|
||||
@@ -199,9 +200,9 @@ func SingleRelease(ctx *context.Context) {
|
||||
writeAccess := ctx.Repo.CanWrite(unit.TypeReleases)
|
||||
ctx.Data["CanCreateRelease"] = writeAccess && !ctx.Repo.Repository.IsArchived
|
||||
|
||||
release, err := models.GetRelease(ctx.Repo.Repository.ID, ctx.Params("*"))
|
||||
release, err := repo_model.GetRelease(ctx.Repo.Repository.ID, ctx.Params("*"))
|
||||
if err != nil {
|
||||
if models.IsErrReleaseNotExist(err) {
|
||||
if repo_model.IsErrReleaseNotExist(err) {
|
||||
ctx.NotFound("GetRelease", err)
|
||||
return
|
||||
}
|
||||
@@ -209,7 +210,7 @@ func SingleRelease(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
err = models.GetReleaseAttachments(ctx, release)
|
||||
err = repo_model.GetReleaseAttachments(ctx, release)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetReleaseAttachments", err)
|
||||
return
|
||||
@@ -241,15 +242,15 @@ func SingleRelease(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Data["Releases"] = []*models.Release{release}
|
||||
ctx.Data["Releases"] = []*repo_model.Release{release}
|
||||
ctx.HTML(http.StatusOK, tplReleases)
|
||||
}
|
||||
|
||||
// LatestRelease redirects to the latest release
|
||||
func LatestRelease(ctx *context.Context) {
|
||||
release, err := models.GetLatestReleaseByRepoID(ctx.Repo.Repository.ID)
|
||||
release, err := repo_model.GetLatestReleaseByRepoID(ctx.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
if models.IsErrReleaseNotExist(err) {
|
||||
if repo_model.IsErrReleaseNotExist(err) {
|
||||
ctx.NotFound("LatestRelease", err)
|
||||
return
|
||||
}
|
||||
@@ -272,8 +273,8 @@ func NewRelease(ctx *context.Context) {
|
||||
ctx.Data["RequireTribute"] = true
|
||||
ctx.Data["tag_target"] = ctx.Repo.Repository.DefaultBranch
|
||||
if tagName := ctx.FormString("tag"); len(tagName) > 0 {
|
||||
rel, err := models.GetRelease(ctx.Repo.Repository.ID, tagName)
|
||||
if err != nil && !models.IsErrReleaseNotExist(err) {
|
||||
rel, err := repo_model.GetRelease(ctx.Repo.Repository.ID, tagName)
|
||||
if err != nil && !repo_model.IsErrReleaseNotExist(err) {
|
||||
ctx.ServerError("GetRelease", err)
|
||||
return
|
||||
}
|
||||
@@ -321,9 +322,9 @@ func NewReleasePost(ctx *context.Context) {
|
||||
attachmentUUIDs = form.Files
|
||||
}
|
||||
|
||||
rel, err := models.GetRelease(ctx.Repo.Repository.ID, form.TagName)
|
||||
rel, err := repo_model.GetRelease(ctx.Repo.Repository.ID, form.TagName)
|
||||
if err != nil {
|
||||
if !models.IsErrReleaseNotExist(err) {
|
||||
if !repo_model.IsErrReleaseNotExist(err) {
|
||||
ctx.ServerError("GetRelease", err)
|
||||
return
|
||||
}
|
||||
@@ -363,7 +364,7 @@ func NewReleasePost(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
rel = &models.Release{
|
||||
rel = &repo_model.Release{
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
Repo: ctx.Repo.Repository,
|
||||
PublisherID: ctx.Doer.ID,
|
||||
@@ -380,7 +381,7 @@ func NewReleasePost(ctx *context.Context) {
|
||||
if err = releaseservice.CreateRelease(ctx.Repo.GitRepo, rel, attachmentUUIDs, msg); err != nil {
|
||||
ctx.Data["Err_TagName"] = true
|
||||
switch {
|
||||
case models.IsErrReleaseAlreadyExist(err):
|
||||
case repo_model.IsErrReleaseAlreadyExist(err):
|
||||
ctx.RenderWithErr(ctx.Tr("repo.release.tag_name_already_exist"), tplReleaseNew, &form)
|
||||
case models.IsErrInvalidTagName(err):
|
||||
ctx.RenderWithErr(ctx.Tr("repo.release.tag_name_invalid"), tplReleaseNew, &form)
|
||||
@@ -427,9 +428,9 @@ func EditRelease(ctx *context.Context) {
|
||||
upload.AddUploadContext(ctx, "release")
|
||||
|
||||
tagName := ctx.Params("*")
|
||||
rel, err := models.GetRelease(ctx.Repo.Repository.ID, tagName)
|
||||
rel, err := repo_model.GetRelease(ctx.Repo.Repository.ID, tagName)
|
||||
if err != nil {
|
||||
if models.IsErrReleaseNotExist(err) {
|
||||
if repo_model.IsErrReleaseNotExist(err) {
|
||||
ctx.NotFound("GetRelease", err)
|
||||
} else {
|
||||
ctx.ServerError("GetRelease", err)
|
||||
@@ -463,9 +464,9 @@ func EditReleasePost(ctx *context.Context) {
|
||||
ctx.Data["RequireTribute"] = true
|
||||
|
||||
tagName := ctx.Params("*")
|
||||
rel, err := models.GetRelease(ctx.Repo.Repository.ID, tagName)
|
||||
rel, err := repo_model.GetRelease(ctx.Repo.Repository.ID, tagName)
|
||||
if err != nil {
|
||||
if models.IsErrReleaseNotExist(err) {
|
||||
if repo_model.IsErrReleaseNotExist(err) {
|
||||
ctx.NotFound("GetRelease", err)
|
||||
} else {
|
||||
ctx.ServerError("GetRelease", err)
|
||||
|
@@ -7,7 +7,7 @@ package repo
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
@@ -52,7 +52,7 @@ func TestNewReleasePost(t *testing.T) {
|
||||
test.LoadGitRepo(t, ctx)
|
||||
web.SetForm(ctx, &testCase.Form)
|
||||
NewReleasePost(ctx)
|
||||
unittest.AssertExistsAndLoadBean(t, &models.Release{
|
||||
unittest.AssertExistsAndLoadBean(t, &repo_model.Release{
|
||||
RepoID: 1,
|
||||
PublisherID: 2,
|
||||
TagName: testCase.Form.TagName,
|
||||
|
@@ -15,6 +15,7 @@ import (
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/models/organization"
|
||||
access_model "code.gitea.io/gitea/models/perm/access"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unit"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
@@ -152,7 +153,7 @@ func Create(ctx *context.Context) {
|
||||
templateID := ctx.FormInt64("template_id")
|
||||
if templateID > 0 {
|
||||
templateRepo, err := repo_model.GetRepositoryByID(templateID)
|
||||
if err == nil && models.CheckRepoUnitUser(ctx, templateRepo, ctxUser, unit.TypeCode) {
|
||||
if err == nil && access_model.CheckRepoUnitUser(ctx, templateRepo, ctxUser, unit.TypeCode) {
|
||||
ctx.Data["repo_template"] = templateID
|
||||
ctx.Data["repo_template_name"] = templateRepo.Name
|
||||
}
|
||||
@@ -257,7 +258,7 @@ func CreatePost(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
repo, err = repo_service.CreateRepository(ctx.Doer, ctxUser, models.CreateRepoOptions{
|
||||
repo, err = repo_service.CreateRepository(ctx.Doer, ctxUser, repo_module.CreateRepoOptions{
|
||||
Name: form.RepoName,
|
||||
Description: form.Description,
|
||||
Gitignores: form.Gitignores,
|
||||
@@ -358,7 +359,7 @@ func RedirectDownload(ctx *context.Context) {
|
||||
)
|
||||
tagNames := []string{vTag}
|
||||
curRepo := ctx.Repo.Repository
|
||||
releases, err := models.GetReleasesByRepoIDAndNames(ctx, curRepo.ID, tagNames)
|
||||
releases, err := repo_model.GetReleasesByRepoIDAndNames(ctx, curRepo.ID, tagNames)
|
||||
if err != nil {
|
||||
if repo_model.IsErrAttachmentNotExist(err) {
|
||||
ctx.Error(http.StatusNotFound)
|
||||
|
@@ -30,7 +30,7 @@ import (
|
||||
"code.gitea.io/gitea/modules/lfs"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
mirror_module "code.gitea.io/gitea/modules/mirror"
|
||||
"code.gitea.io/gitea/modules/repository"
|
||||
repo_module "code.gitea.io/gitea/modules/repository"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/typesniffer"
|
||||
@@ -43,6 +43,7 @@ import (
|
||||
"code.gitea.io/gitea/services/mailer"
|
||||
"code.gitea.io/gitea/services/migrations"
|
||||
mirror_service "code.gitea.io/gitea/services/mirror"
|
||||
org_service "code.gitea.io/gitea/services/org"
|
||||
repo_service "code.gitea.io/gitea/services/repository"
|
||||
wiki_service "code.gitea.io/gitea/services/wiki"
|
||||
)
|
||||
@@ -607,7 +608,7 @@ func SettingsPost(ctx *context.Context) {
|
||||
}
|
||||
repo.IsMirror = false
|
||||
|
||||
if _, err := repository.CleanUpMigrateInfo(ctx, repo); err != nil {
|
||||
if _, err := repo_module.CleanUpMigrateInfo(ctx, repo); err != nil {
|
||||
ctx.ServerError("CleanUpMigrateInfo", err)
|
||||
return
|
||||
} else if err = repo_model.DeleteMirrorByRepoID(ctx.Repo.Repository.ID); err != nil {
|
||||
@@ -916,7 +917,7 @@ func CollaborationPost(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if err = models.AddCollaborator(ctx.Repo.Repository, u); err != nil {
|
||||
if err = repo_module.AddCollaborator(ctx.Repo.Repository, u); err != nil {
|
||||
ctx.ServerError("AddCollaborator", err)
|
||||
return
|
||||
}
|
||||
@@ -989,8 +990,8 @@ func AddTeamPost(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if err = models.AddRepository(team, ctx.Repo.Repository); err != nil {
|
||||
ctx.ServerError("team.AddRepository", err)
|
||||
if err = org_service.TeamAddRepository(team, ctx.Repo.Repository); err != nil {
|
||||
ctx.ServerError("TeamAddRepository", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
activities_model "code.gitea.io/gitea/models/activities"
|
||||
admin_model "code.gitea.io/gitea/models/admin"
|
||||
asymkey_model "code.gitea.io/gitea/models/asymkey"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
git_model "code.gitea.io/gitea/models/git"
|
||||
@@ -666,9 +667,9 @@ func safeURL(address string) string {
|
||||
func checkHomeCodeViewable(ctx *context.Context) {
|
||||
if len(ctx.Repo.Units) > 0 {
|
||||
if ctx.Repo.Repository.IsBeingCreated() {
|
||||
task, err := models.GetMigratingTask(ctx.Repo.Repository.ID)
|
||||
task, err := admin_model.GetMigratingTask(ctx.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
if models.IsErrTaskDoesNotExist(err) {
|
||||
if admin_model.IsErrTaskDoesNotExist(err) {
|
||||
ctx.Data["Repo"] = ctx.Repo
|
||||
ctx.Data["CloneAddr"] = ""
|
||||
ctx.Data["Failed"] = true
|
||||
@@ -694,7 +695,7 @@ func checkHomeCodeViewable(ctx *context.Context) {
|
||||
|
||||
if ctx.IsSigned {
|
||||
// Set repo notification-status read if unread
|
||||
if err := models.SetRepoReadBy(ctx, ctx.Repo.Repository.ID, ctx.Doer.ID); err != nil {
|
||||
if err := activities_model.SetRepoReadBy(ctx, ctx.Repo.Repository.ID, ctx.Doer.ID); err != nil {
|
||||
ctx.ServerError("ReadBy", err)
|
||||
return
|
||||
}
|
||||
|
@@ -15,8 +15,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
git_model "code.gitea.io/gitea/models/git"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unit"
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/charset"
|
||||
@@ -164,7 +164,7 @@ func renderViewPage(ctx *context.Context) (*git.Repository, *git.TreeEntry) {
|
||||
}
|
||||
wikiName, err := wiki_service.FilenameToName(entry.Name())
|
||||
if err != nil {
|
||||
if models.IsErrWikiInvalidFileName(err) {
|
||||
if repo_model.IsErrWikiInvalidFileName(err) {
|
||||
continue
|
||||
}
|
||||
if wikiRepo != nil {
|
||||
@@ -588,7 +588,7 @@ func WikiPages(ctx *context.Context) {
|
||||
}
|
||||
wikiName, err := wiki_service.FilenameToName(entry.Name())
|
||||
if err != nil {
|
||||
if models.IsErrWikiInvalidFileName(err) {
|
||||
if repo_model.IsErrWikiInvalidFileName(err) {
|
||||
continue
|
||||
}
|
||||
ctx.ServerError("WikiFilenameToName", err)
|
||||
@@ -693,10 +693,10 @@ func NewWikiPost(ctx *context.Context) {
|
||||
}
|
||||
|
||||
if err := wiki_service.AddWikiPage(ctx, ctx.Doer, ctx.Repo.Repository, wikiName, form.Content, form.Message); err != nil {
|
||||
if models.IsErrWikiReservedName(err) {
|
||||
if repo_model.IsErrWikiReservedName(err) {
|
||||
ctx.Data["Err_Title"] = true
|
||||
ctx.RenderWithErr(ctx.Tr("repo.wiki.reserved_page", wikiName), tplWikiNew, &form)
|
||||
} else if models.IsErrWikiAlreadyExist(err) {
|
||||
} else if repo_model.IsErrWikiAlreadyExist(err) {
|
||||
ctx.Data["Err_Title"] = true
|
||||
ctx.RenderWithErr(ctx.Tr("repo.wiki.page_already_exists"), tplWikiNew, &form)
|
||||
} else {
|
||||
|
@@ -14,7 +14,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
activities_model "code.gitea.io/gitea/models/activities"
|
||||
asymkey_model "code.gitea.io/gitea/models/asymkey"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
@@ -56,7 +56,7 @@ func getDashboardContextUser(ctx *context.Context) *user_model.User {
|
||||
}
|
||||
ctx.Data["ContextUser"] = ctxUser
|
||||
|
||||
orgs, err := models.GetUserOrgsList(ctx.Doer)
|
||||
orgs, err := organization.GetUserOrgsList(ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetUserOrgsList", err)
|
||||
return nil
|
||||
@@ -91,7 +91,7 @@ func Dashboard(ctx *context.Context) {
|
||||
}
|
||||
|
||||
if setting.Service.EnableUserHeatmap {
|
||||
data, err := models.GetUserHeatmapDataByUserTeam(ctxUser, ctx.Org.Team, ctx.Doer)
|
||||
data, err := activities_model.GetUserHeatmapDataByUserTeam(ctxUser, ctx.Org.Team, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetUserHeatmapDataByUserTeam", err)
|
||||
return
|
||||
@@ -100,7 +100,7 @@ func Dashboard(ctx *context.Context) {
|
||||
}
|
||||
|
||||
var err error
|
||||
ctx.Data["Feeds"], err = models.GetFeeds(ctx, models.GetFeedsOptions{
|
||||
ctx.Data["Feeds"], err = activities_model.GetFeeds(ctx, activities_model.GetFeedsOptions{
|
||||
RequestedUser: ctxUser,
|
||||
RequestedTeam: ctx.Org.Team,
|
||||
Actor: ctx.Doer,
|
||||
|
@@ -12,7 +12,7 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
activities_model "code.gitea.io/gitea/models/activities"
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
@@ -36,7 +36,7 @@ func GetNotificationCount(c *context.Context) {
|
||||
}
|
||||
|
||||
c.Data["NotificationUnreadCount"] = func() int64 {
|
||||
count, err := models.GetNotificationCount(c, c.Doer, models.NotificationStatusUnread)
|
||||
count, err := activities_model.GetNotificationCount(c, c.Doer, activities_model.NotificationStatusUnread)
|
||||
if err != nil {
|
||||
if err != goctx.Canceled {
|
||||
log.Error("Unable to GetNotificationCount for user:%-v: %v", c.Doer, err)
|
||||
@@ -65,7 +65,7 @@ func Notifications(c *context.Context) {
|
||||
func getNotifications(c *context.Context) {
|
||||
var (
|
||||
keyword = c.FormTrim("q")
|
||||
status models.NotificationStatus
|
||||
status activities_model.NotificationStatus
|
||||
page = c.FormInt("page")
|
||||
perPage = c.FormInt("perPage")
|
||||
)
|
||||
@@ -78,12 +78,12 @@ func getNotifications(c *context.Context) {
|
||||
|
||||
switch keyword {
|
||||
case "read":
|
||||
status = models.NotificationStatusRead
|
||||
status = activities_model.NotificationStatusRead
|
||||
default:
|
||||
status = models.NotificationStatusUnread
|
||||
status = activities_model.NotificationStatusUnread
|
||||
}
|
||||
|
||||
total, err := models.GetNotificationCount(c, c.Doer, status)
|
||||
total, err := activities_model.GetNotificationCount(c, c.Doer, status)
|
||||
if err != nil {
|
||||
c.ServerError("ErrGetNotificationCount", err)
|
||||
return
|
||||
@@ -96,8 +96,8 @@ func getNotifications(c *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
statuses := []models.NotificationStatus{status, models.NotificationStatusPinned}
|
||||
notifications, err := models.NotificationsForUser(c, c.Doer, statuses, page, perPage)
|
||||
statuses := []activities_model.NotificationStatus{status, activities_model.NotificationStatusPinned}
|
||||
notifications, err := activities_model.NotificationsForUser(c, c.Doer, statuses, page, perPage)
|
||||
if err != nil {
|
||||
c.ServerError("ErrNotificationsForUser", err)
|
||||
return
|
||||
@@ -151,22 +151,22 @@ func NotificationStatusPost(c *context.Context) {
|
||||
var (
|
||||
notificationID = c.FormInt64("notification_id")
|
||||
statusStr = c.FormString("status")
|
||||
status models.NotificationStatus
|
||||
status activities_model.NotificationStatus
|
||||
)
|
||||
|
||||
switch statusStr {
|
||||
case "read":
|
||||
status = models.NotificationStatusRead
|
||||
status = activities_model.NotificationStatusRead
|
||||
case "unread":
|
||||
status = models.NotificationStatusUnread
|
||||
status = activities_model.NotificationStatusUnread
|
||||
case "pinned":
|
||||
status = models.NotificationStatusPinned
|
||||
status = activities_model.NotificationStatusPinned
|
||||
default:
|
||||
c.ServerError("InvalidNotificationStatus", errors.New("Invalid notification status"))
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := models.SetNotificationStatus(notificationID, c.Doer, status); err != nil {
|
||||
if _, err := activities_model.SetNotificationStatus(notificationID, c.Doer, status); err != nil {
|
||||
c.ServerError("SetNotificationStatus", err)
|
||||
return
|
||||
}
|
||||
@@ -188,7 +188,7 @@ func NotificationStatusPost(c *context.Context) {
|
||||
|
||||
// NotificationPurgePost is a route for 'purging' the list of notifications - marking all unread as read
|
||||
func NotificationPurgePost(c *context.Context) {
|
||||
err := models.UpdateNotificationStatuses(c.Doer, models.NotificationStatusUnread, models.NotificationStatusRead)
|
||||
err := activities_model.UpdateNotificationStatuses(c.Doer, activities_model.NotificationStatusUnread, activities_model.NotificationStatusRead)
|
||||
if err != nil {
|
||||
c.ServerError("ErrUpdateNotificationStatuses", err)
|
||||
return
|
||||
@@ -199,5 +199,5 @@ func NotificationPurgePost(c *context.Context) {
|
||||
|
||||
// NewAvailable returns the notification counts
|
||||
func NewAvailable(ctx *context.Context) {
|
||||
ctx.JSON(http.StatusOK, structs.NotificationCount{New: models.CountUnread(ctx, ctx.Doer.ID)})
|
||||
ctx.JSON(http.StatusOK, structs.NotificationCount{New: activities_model.CountUnread(ctx, ctx.Doer.ID)})
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
activities_model "code.gitea.io/gitea/models/activities"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/models/organization"
|
||||
project_model "code.gitea.io/gitea/models/project"
|
||||
@@ -69,7 +69,7 @@ func Profile(ctx *context.Context) {
|
||||
ctx.Data["IsFollowing"] = isFollowing
|
||||
|
||||
if setting.Service.EnableUserHeatmap {
|
||||
data, err := models.GetUserHeatmapDataByUser(ctx.ContextUser, ctx.Doer)
|
||||
data, err := activities_model.GetUserHeatmapDataByUser(ctx.ContextUser, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetUserHeatmapDataByUser", err)
|
||||
return
|
||||
@@ -188,7 +188,7 @@ func Profile(ctx *context.Context) {
|
||||
|
||||
total = int(count)
|
||||
case "activity":
|
||||
ctx.Data["Feeds"], err = models.GetFeeds(ctx, models.GetFeedsOptions{
|
||||
ctx.Data["Feeds"], err = activities_model.GetFeeds(ctx, activities_model.GetFeedsOptions{
|
||||
RequestedUser: ctx.ContextUser,
|
||||
Actor: ctx.Doer,
|
||||
IncludePrivate: showPrivate,
|
||||
|
@@ -7,10 +7,10 @@ package setting
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
repo_module "code.gitea.io/gitea/modules/repository"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
repo_service "code.gitea.io/gitea/services/repository"
|
||||
@@ -46,7 +46,7 @@ func AdoptOrDeleteRepository(ctx *context.Context) {
|
||||
if has || !isDir {
|
||||
// Fallthrough to failure mode
|
||||
} else if action == "adopt" && allowAdopt {
|
||||
if _, err := repo_service.AdoptRepository(ctxUser, ctxUser, models.CreateRepoOptions{
|
||||
if _, err := repo_service.AdoptRepository(ctxUser, ctxUser, repo_module.CreateRepoOptions{
|
||||
Name: dir,
|
||||
IsPrivate: true,
|
||||
}); err != nil {
|
||||
|
@@ -8,8 +8,7 @@ package setting
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/auth"
|
||||
auth_model "code.gitea.io/gitea/models/auth"
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
@@ -44,12 +43,12 @@ func ApplicationsPost(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
t := &models.AccessToken{
|
||||
t := &auth_model.AccessToken{
|
||||
UID: ctx.Doer.ID,
|
||||
Name: form.Name,
|
||||
}
|
||||
|
||||
exist, err := models.AccessTokenByNameExists(t)
|
||||
exist, err := auth_model.AccessTokenByNameExists(t)
|
||||
if err != nil {
|
||||
ctx.ServerError("AccessTokenByNameExists", err)
|
||||
return
|
||||
@@ -60,7 +59,7 @@ func ApplicationsPost(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := models.NewAccessToken(t); err != nil {
|
||||
if err := auth_model.NewAccessToken(t); err != nil {
|
||||
ctx.ServerError("NewAccessToken", err)
|
||||
return
|
||||
}
|
||||
@@ -73,7 +72,7 @@ func ApplicationsPost(ctx *context.Context) {
|
||||
|
||||
// DeleteApplication response for delete user access token
|
||||
func DeleteApplication(ctx *context.Context) {
|
||||
if err := models.DeleteAccessTokenByID(ctx.FormInt64("id"), ctx.Doer.ID); err != nil {
|
||||
if err := auth_model.DeleteAccessTokenByID(ctx.FormInt64("id"), ctx.Doer.ID); err != nil {
|
||||
ctx.Flash.Error("DeleteAccessTokenByID: " + err.Error())
|
||||
} else {
|
||||
ctx.Flash.Success(ctx.Tr("settings.delete_token_success"))
|
||||
@@ -85,7 +84,7 @@ func DeleteApplication(ctx *context.Context) {
|
||||
}
|
||||
|
||||
func loadApplicationsData(ctx *context.Context) {
|
||||
tokens, err := models.ListAccessTokens(models.ListAccessTokensOptions{UserID: ctx.Doer.ID})
|
||||
tokens, err := auth_model.ListAccessTokens(auth_model.ListAccessTokensOptions{UserID: ctx.Doer.ID})
|
||||
if err != nil {
|
||||
ctx.ServerError("ListAccessTokens", err)
|
||||
return
|
||||
@@ -93,12 +92,12 @@ func loadApplicationsData(ctx *context.Context) {
|
||||
ctx.Data["Tokens"] = tokens
|
||||
ctx.Data["EnableOAuth2"] = setting.OAuth2.Enable
|
||||
if setting.OAuth2.Enable {
|
||||
ctx.Data["Applications"], err = auth.GetOAuth2ApplicationsByUserID(ctx, ctx.Doer.ID)
|
||||
ctx.Data["Applications"], err = auth_model.GetOAuth2ApplicationsByUserID(ctx, ctx.Doer.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetOAuth2ApplicationsByUserID", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Grants"], err = auth.GetOAuth2GrantsByUserID(ctx, ctx.Doer.ID)
|
||||
ctx.Data["Grants"], err = auth_model.GetOAuth2GrantsByUserID(ctx, ctx.Doer.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetOAuth2GrantsByUserID", err)
|
||||
return
|
||||
|
@@ -8,8 +8,7 @@ package security
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/auth"
|
||||
auth_model "code.gitea.io/gitea/models/auth"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
@@ -56,21 +55,21 @@ func DeleteAccountLink(ctx *context.Context) {
|
||||
}
|
||||
|
||||
func loadSecurityData(ctx *context.Context) {
|
||||
enrolled, err := auth.HasTwoFactorByUID(ctx.Doer.ID)
|
||||
enrolled, err := auth_model.HasTwoFactorByUID(ctx.Doer.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("SettingsTwoFactor", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["TOTPEnrolled"] = enrolled
|
||||
|
||||
credentials, err := auth.GetWebAuthnCredentialsByUID(ctx.Doer.ID)
|
||||
credentials, err := auth_model.GetWebAuthnCredentialsByUID(ctx.Doer.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetWebAuthnCredentialsByUID", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["WebAuthnCredentials"] = credentials
|
||||
|
||||
tokens, err := models.ListAccessTokens(models.ListAccessTokensOptions{UserID: ctx.Doer.ID})
|
||||
tokens, err := auth_model.ListAccessTokens(auth_model.ListAccessTokensOptions{UserID: ctx.Doer.ID})
|
||||
if err != nil {
|
||||
ctx.ServerError("ListAccessTokens", err)
|
||||
return
|
||||
@@ -84,9 +83,9 @@ func loadSecurityData(ctx *context.Context) {
|
||||
}
|
||||
|
||||
// map the provider display name with the AuthSource
|
||||
sources := make(map[*auth.Source]string)
|
||||
sources := make(map[*auth_model.Source]string)
|
||||
for _, externalAccount := range accountLinks {
|
||||
if authSource, err := auth.GetSourceByID(externalAccount.LoginSourceID); err == nil {
|
||||
if authSource, err := auth_model.GetSourceByID(externalAccount.LoginSourceID); err == nil {
|
||||
var providerDisplayName string
|
||||
|
||||
type DisplayNamed interface {
|
||||
|
@@ -8,16 +8,16 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
admin_model "code.gitea.io/gitea/models/admin"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
)
|
||||
|
||||
// TaskStatus returns task's status
|
||||
func TaskStatus(ctx *context.Context) {
|
||||
task, opts, err := models.GetMigratingTaskByID(ctx.ParamsInt64("task"), ctx.Doer.ID)
|
||||
task, opts, err := admin_model.GetMigratingTaskByID(ctx.ParamsInt64("task"), ctx.Doer.ID)
|
||||
if err != nil {
|
||||
if models.IsErrTaskDoesNotExist(err) {
|
||||
if admin_model.IsErrTaskDoesNotExist(err) {
|
||||
ctx.JSON(http.StatusNotFound, map[string]interface{}{
|
||||
"error": "task `" + strconv.FormatInt(ctx.ParamsInt64("task"), 10) + "` does not exist",
|
||||
})
|
||||
@@ -33,9 +33,9 @@ func TaskStatus(ctx *context.Context) {
|
||||
|
||||
if task.Message != "" && task.Message[0] == '{' {
|
||||
// assume message is actually a translatable string
|
||||
var translatableMessage models.TranslatableMessage
|
||||
var translatableMessage admin_model.TranslatableMessage
|
||||
if err := json.Unmarshal([]byte(message), &translatableMessage); err != nil {
|
||||
translatableMessage = models.TranslatableMessage{
|
||||
translatableMessage = admin_model.TranslatableMessage{
|
||||
Format: "migrate.migrating_failed.error",
|
||||
Args: []interface{}{task.Message},
|
||||
}
|
||||
|
Reference in New Issue
Block a user