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:
@@ -7,7 +7,7 @@ package nuget
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
auth_model "code.gitea.io/gitea/models/auth"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
@@ -22,9 +22,9 @@ func (a *Auth) Name() string {
|
||||
|
||||
// https://docs.microsoft.com/en-us/nuget/api/package-publish-resource#request-parameters
|
||||
func (a *Auth) Verify(req *http.Request, w http.ResponseWriter, store auth.DataStore, sess auth.SessionStore) *user_model.User {
|
||||
token, err := models.GetAccessTokenBySHA(req.Header.Get("X-NuGet-ApiKey"))
|
||||
token, err := auth_model.GetAccessTokenBySHA(req.Header.Get("X-NuGet-ApiKey"))
|
||||
if err != nil {
|
||||
if !(models.IsErrAccessTokenNotExist(err) || models.IsErrAccessTokenEmpty(err)) {
|
||||
if !(auth_model.IsErrAccessTokenNotExist(err) || auth_model.IsErrAccessTokenEmpty(err)) {
|
||||
log.Error("GetAccessTokenBySHA: %v", err)
|
||||
}
|
||||
return nil
|
||||
@@ -37,7 +37,7 @@ func (a *Auth) Verify(req *http.Request, w http.ResponseWriter, store auth.DataS
|
||||
}
|
||||
|
||||
token.UpdatedUnix = timeutil.TimeStampNow()
|
||||
if err := models.UpdateAccessToken(token); err != nil {
|
||||
if err := auth_model.UpdateAccessToken(token); err != nil {
|
||||
log.Error("UpdateAccessToken: %v", err)
|
||||
}
|
||||
|
||||
|
@@ -7,10 +7,10 @@ package admin
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"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/util"
|
||||
"code.gitea.io/gitea/routers/api/v1/utils"
|
||||
repo_service "code.gitea.io/gitea/services/repository"
|
||||
@@ -110,7 +110,7 @@ func AdoptRepository(ctx *context.APIContext) {
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
if _, err := repo_service.AdoptRepository(ctx.Doer, ctxUser, models.CreateRepoOptions{
|
||||
if _, err := repo_service.AdoptRepository(ctx.Doer, ctxUser, repo_module.CreateRepoOptions{
|
||||
Name: repoName,
|
||||
IsPrivate: true,
|
||||
}); err != nil {
|
||||
|
@@ -8,7 +8,7 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
activities_model "code.gitea.io/gitea/models/activities"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/routers/api/v1/utils"
|
||||
@@ -22,16 +22,16 @@ func NewAvailable(ctx *context.APIContext) {
|
||||
// responses:
|
||||
// "200":
|
||||
// "$ref": "#/responses/NotificationCount"
|
||||
ctx.JSON(http.StatusOK, api.NotificationCount{New: models.CountUnread(ctx, ctx.Doer.ID)})
|
||||
ctx.JSON(http.StatusOK, api.NotificationCount{New: activities_model.CountUnread(ctx, ctx.Doer.ID)})
|
||||
}
|
||||
|
||||
func getFindNotificationOptions(ctx *context.APIContext) *models.FindNotificationOptions {
|
||||
func getFindNotificationOptions(ctx *context.APIContext) *activities_model.FindNotificationOptions {
|
||||
before, since, err := context.GetQueryBeforeSince(ctx.Context)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusUnprocessableEntity, "GetQueryBeforeSince", err)
|
||||
return nil
|
||||
}
|
||||
opts := &models.FindNotificationOptions{
|
||||
opts := &activities_model.FindNotificationOptions{
|
||||
ListOptions: utils.GetListOptions(ctx),
|
||||
UserID: ctx.Doer.ID,
|
||||
UpdatedBeforeUnix: before,
|
||||
@@ -50,17 +50,17 @@ func getFindNotificationOptions(ctx *context.APIContext) *models.FindNotificatio
|
||||
return opts
|
||||
}
|
||||
|
||||
func subjectToSource(value []string) (result []models.NotificationSource) {
|
||||
func subjectToSource(value []string) (result []activities_model.NotificationSource) {
|
||||
for _, v := range value {
|
||||
switch strings.ToLower(v) {
|
||||
case "issue":
|
||||
result = append(result, models.NotificationSourceIssue)
|
||||
result = append(result, activities_model.NotificationSourceIssue)
|
||||
case "pull":
|
||||
result = append(result, models.NotificationSourcePullRequest)
|
||||
result = append(result, activities_model.NotificationSourcePullRequest)
|
||||
case "commit":
|
||||
result = append(result, models.NotificationSourceCommit)
|
||||
result = append(result, activities_model.NotificationSourceCommit)
|
||||
case "repository":
|
||||
result = append(result, models.NotificationSourceRepository)
|
||||
result = append(result, activities_model.NotificationSourceRepository)
|
||||
}
|
||||
}
|
||||
return result
|
||||
|
@@ -9,31 +9,31 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
activities_model "code.gitea.io/gitea/models/activities"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/convert"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
func statusStringToNotificationStatus(status string) models.NotificationStatus {
|
||||
func statusStringToNotificationStatus(status string) activities_model.NotificationStatus {
|
||||
switch strings.ToLower(strings.TrimSpace(status)) {
|
||||
case "unread":
|
||||
return models.NotificationStatusUnread
|
||||
return activities_model.NotificationStatusUnread
|
||||
case "read":
|
||||
return models.NotificationStatusRead
|
||||
return activities_model.NotificationStatusRead
|
||||
case "pinned":
|
||||
return models.NotificationStatusPinned
|
||||
return activities_model.NotificationStatusPinned
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
func statusStringsToNotificationStatuses(statuses, defaultStatuses []string) []models.NotificationStatus {
|
||||
func statusStringsToNotificationStatuses(statuses, defaultStatuses []string) []activities_model.NotificationStatus {
|
||||
if len(statuses) == 0 {
|
||||
statuses = defaultStatuses
|
||||
}
|
||||
results := make([]models.NotificationStatus, 0, len(statuses))
|
||||
results := make([]activities_model.NotificationStatus, 0, len(statuses))
|
||||
for _, status := range statuses {
|
||||
notificationStatus := statusStringToNotificationStatus(status)
|
||||
if notificationStatus > 0 {
|
||||
@@ -109,13 +109,13 @@ func ListRepoNotifications(ctx *context.APIContext) {
|
||||
}
|
||||
opts.RepoID = ctx.Repo.Repository.ID
|
||||
|
||||
totalCount, err := models.CountNotifications(opts)
|
||||
totalCount, err := activities_model.CountNotifications(opts)
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
}
|
||||
|
||||
nl, err := models.GetNotifications(ctx, opts)
|
||||
nl, err := activities_model.GetNotifications(ctx, opts)
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
@@ -192,7 +192,7 @@ func ReadRepoNotifications(ctx *context.APIContext) {
|
||||
}
|
||||
}
|
||||
|
||||
opts := &models.FindNotificationOptions{
|
||||
opts := &activities_model.FindNotificationOptions{
|
||||
UserID: ctx.Doer.ID,
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
UpdatedBeforeUnix: lastRead,
|
||||
@@ -203,7 +203,7 @@ func ReadRepoNotifications(ctx *context.APIContext) {
|
||||
opts.Status = statusStringsToNotificationStatuses(statuses, []string{"unread"})
|
||||
log.Error("%v", opts.Status)
|
||||
}
|
||||
nl, err := models.GetNotifications(ctx, opts)
|
||||
nl, err := activities_model.GetNotifications(ctx, opts)
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
@@ -211,13 +211,13 @@ func ReadRepoNotifications(ctx *context.APIContext) {
|
||||
|
||||
targetStatus := statusStringToNotificationStatus(ctx.FormString("to-status"))
|
||||
if targetStatus == 0 {
|
||||
targetStatus = models.NotificationStatusRead
|
||||
targetStatus = activities_model.NotificationStatusRead
|
||||
}
|
||||
|
||||
changed := make([]*structs.NotificationThread, 0, len(nl))
|
||||
|
||||
for _, n := range nl {
|
||||
notif, err := models.SetNotificationStatus(n.ID, ctx.Doer, targetStatus)
|
||||
notif, err := activities_model.SetNotificationStatus(n.ID, ctx.Doer, targetStatus)
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
|
@@ -8,7 +8,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
activities_model "code.gitea.io/gitea/models/activities"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
@@ -86,10 +86,10 @@ func ReadThread(ctx *context.APIContext) {
|
||||
|
||||
targetStatus := statusStringToNotificationStatus(ctx.FormString("to-status"))
|
||||
if targetStatus == 0 {
|
||||
targetStatus = models.NotificationStatusRead
|
||||
targetStatus = activities_model.NotificationStatusRead
|
||||
}
|
||||
|
||||
notif, err := models.SetNotificationStatus(n.ID, ctx.Doer, targetStatus)
|
||||
notif, err := activities_model.SetNotificationStatus(n.ID, ctx.Doer, targetStatus)
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
@@ -101,8 +101,8 @@ func ReadThread(ctx *context.APIContext) {
|
||||
ctx.JSON(http.StatusResetContent, convert.ToNotificationThread(notif))
|
||||
}
|
||||
|
||||
func getThread(ctx *context.APIContext) *models.Notification {
|
||||
n, err := models.GetNotificationByID(ctx.ParamsInt64(":id"))
|
||||
func getThread(ctx *context.APIContext) *activities_model.Notification {
|
||||
n, err := activities_model.GetNotificationByID(ctx.ParamsInt64(":id"))
|
||||
if err != nil {
|
||||
if db.IsErrNotExist(err) {
|
||||
ctx.Error(http.StatusNotFound, "GetNotificationByID", err)
|
||||
|
@@ -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"
|
||||
"code.gitea.io/gitea/modules/convert"
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
@@ -69,13 +69,13 @@ func ListNotifications(ctx *context.APIContext) {
|
||||
return
|
||||
}
|
||||
|
||||
totalCount, err := models.CountNotifications(opts)
|
||||
totalCount, err := activities_model.CountNotifications(opts)
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
}
|
||||
|
||||
nl, err := models.GetNotifications(ctx, opts)
|
||||
nl, err := activities_model.GetNotifications(ctx, opts)
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
@@ -140,7 +140,7 @@ func ReadNotifications(ctx *context.APIContext) {
|
||||
lastRead = tmpLastRead.Unix()
|
||||
}
|
||||
}
|
||||
opts := &models.FindNotificationOptions{
|
||||
opts := &activities_model.FindNotificationOptions{
|
||||
UserID: ctx.Doer.ID,
|
||||
UpdatedBeforeUnix: lastRead,
|
||||
}
|
||||
@@ -148,7 +148,7 @@ func ReadNotifications(ctx *context.APIContext) {
|
||||
statuses := ctx.FormStrings("status-types")
|
||||
opts.Status = statusStringsToNotificationStatuses(statuses, []string{"unread"})
|
||||
}
|
||||
nl, err := models.GetNotifications(ctx, opts)
|
||||
nl, err := activities_model.GetNotifications(ctx, opts)
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
@@ -156,13 +156,13 @@ func ReadNotifications(ctx *context.APIContext) {
|
||||
|
||||
targetStatus := statusStringToNotificationStatus(ctx.FormString("to-status"))
|
||||
if targetStatus == 0 {
|
||||
targetStatus = models.NotificationStatusRead
|
||||
targetStatus = activities_model.NotificationStatusRead
|
||||
}
|
||||
|
||||
changed := make([]*structs.NotificationThread, 0, len(nl))
|
||||
|
||||
for _, n := range nl {
|
||||
notif, err := models.SetNotificationStatus(n.ID, ctx.Doer, targetStatus)
|
||||
notif, err := activities_model.SetNotificationStatus(n.ID, ctx.Doer, targetStatus)
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
|
@@ -22,6 +22,7 @@ import (
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
"code.gitea.io/gitea/routers/api/v1/user"
|
||||
"code.gitea.io/gitea/routers/api/v1/utils"
|
||||
org_service "code.gitea.io/gitea/services/org"
|
||||
)
|
||||
|
||||
// ListTeams list all the teams of an organization
|
||||
@@ -656,8 +657,8 @@ func AddTeamRepository(ctx *context.APIContext) {
|
||||
ctx.Error(http.StatusForbidden, "", "Must have admin-level access to the repository")
|
||||
return
|
||||
}
|
||||
if err := models.AddRepository(ctx.Org.Team, repo); err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "AddRepository", err)
|
||||
if err := org_service.TeamAddRepository(ctx.Org.Team, repo); err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "TeamAddRepository", err)
|
||||
return
|
||||
}
|
||||
ctx.Status(http.StatusNoContent)
|
||||
|
@@ -16,6 +16,7 @@ import (
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/convert"
|
||||
repo_module "code.gitea.io/gitea/modules/repository"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
"code.gitea.io/gitea/routers/api/v1/utils"
|
||||
@@ -174,7 +175,7 @@ func AddCollaborator(ctx *context.APIContext) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := models.AddCollaborator(ctx.Repo.Repository, collaborator); err != nil {
|
||||
if err := repo_module.AddCollaborator(ctx.Repo.Repository, collaborator); err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "AddCollaborator", err)
|
||||
return
|
||||
}
|
||||
|
@@ -170,7 +170,7 @@ func Migrate(ctx *context.APIContext) {
|
||||
opts.Releases = false
|
||||
}
|
||||
|
||||
repo, err := repo_module.CreateRepository(ctx.Doer, repoOwner, models.CreateRepoOptions{
|
||||
repo, err := repo_module.CreateRepository(ctx.Doer, repoOwner, repo_module.CreateRepoOptions{
|
||||
Name: opts.RepoName,
|
||||
Description: opts.Description,
|
||||
OriginalURL: form.CloneAddr,
|
||||
|
@@ -14,6 +14,7 @@ import (
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
activities_model "code.gitea.io/gitea/models/activities"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
access_model "code.gitea.io/gitea/models/perm/access"
|
||||
pull_model "code.gitea.io/gitea/models/pull"
|
||||
@@ -753,7 +754,7 @@ func MergePullRequest(ctx *context.APIContext) {
|
||||
|
||||
if ctx.IsSigned {
|
||||
// Update issue-user.
|
||||
if err = models.SetIssueReadBy(ctx, pr.Issue.ID, ctx.Doer.ID); err != nil {
|
||||
if err = activities_model.SetIssueReadBy(ctx, pr.Issue.ID, ctx.Doer.ID); err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "ReadBy", err)
|
||||
return
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/perm"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unit"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/convert"
|
||||
@@ -49,12 +50,12 @@ func GetRelease(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/notFound"
|
||||
|
||||
id := ctx.ParamsInt64(":id")
|
||||
release, err := models.GetReleaseByID(ctx, id)
|
||||
if err != nil && !models.IsErrReleaseNotExist(err) {
|
||||
release, err := repo_model.GetReleaseByID(ctx, id)
|
||||
if err != nil && !repo_model.IsErrReleaseNotExist(err) {
|
||||
ctx.Error(http.StatusInternalServerError, "GetReleaseByID", err)
|
||||
return
|
||||
}
|
||||
if err != nil && models.IsErrReleaseNotExist(err) ||
|
||||
if err != nil && repo_model.IsErrReleaseNotExist(err) ||
|
||||
release.IsTag || release.RepoID != ctx.Repo.Repository.ID {
|
||||
ctx.NotFound()
|
||||
return
|
||||
@@ -114,7 +115,7 @@ func ListReleases(ctx *context.APIContext) {
|
||||
listOptions.PageSize = ctx.FormInt("per_page")
|
||||
}
|
||||
|
||||
opts := models.FindReleasesOptions{
|
||||
opts := repo_model.FindReleasesOptions{
|
||||
ListOptions: listOptions,
|
||||
IncludeDrafts: ctx.Repo.AccessMode >= perm.AccessModeWrite || ctx.Repo.UnitAccessMode(unit.TypeReleases) >= perm.AccessModeWrite,
|
||||
IncludeTags: false,
|
||||
@@ -122,7 +123,7 @@ func ListReleases(ctx *context.APIContext) {
|
||||
IsPreRelease: ctx.FormOptionalBool("pre-release"),
|
||||
}
|
||||
|
||||
releases, err := models.GetReleasesByRepoID(ctx.Repo.Repository.ID, opts)
|
||||
releases, err := repo_model.GetReleasesByRepoID(ctx.Repo.Repository.ID, opts)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "GetReleasesByRepoID", err)
|
||||
return
|
||||
@@ -136,7 +137,7 @@ func ListReleases(ctx *context.APIContext) {
|
||||
rels[i] = convert.ToRelease(release)
|
||||
}
|
||||
|
||||
filteredCount, err := models.CountReleasesByRepoID(ctx.Repo.Repository.ID, opts)
|
||||
filteredCount, err := repo_model.CountReleasesByRepoID(ctx.Repo.Repository.ID, opts)
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
@@ -179,9 +180,9 @@ func CreateRelease(ctx *context.APIContext) {
|
||||
// "409":
|
||||
// "$ref": "#/responses/error"
|
||||
form := web.GetForm(ctx).(*api.CreateReleaseOption)
|
||||
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.Error(http.StatusInternalServerError, "GetRelease", err)
|
||||
return
|
||||
}
|
||||
@@ -189,7 +190,7 @@ func CreateRelease(ctx *context.APIContext) {
|
||||
if len(form.Target) == 0 {
|
||||
form.Target = ctx.Repo.Repository.DefaultBranch
|
||||
}
|
||||
rel = &models.Release{
|
||||
rel = &repo_model.Release{
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
PublisherID: ctx.Doer.ID,
|
||||
Publisher: ctx.Doer,
|
||||
@@ -203,7 +204,7 @@ func CreateRelease(ctx *context.APIContext) {
|
||||
Repo: ctx.Repo.Repository,
|
||||
}
|
||||
if err := release_service.CreateRelease(ctx.Repo.GitRepo, rel, nil, ""); err != nil {
|
||||
if models.IsErrReleaseAlreadyExist(err) {
|
||||
if repo_model.IsErrReleaseAlreadyExist(err) {
|
||||
ctx.Error(http.StatusConflict, "ReleaseAlreadyExist", err)
|
||||
} else {
|
||||
ctx.Error(http.StatusInternalServerError, "CreateRelease", err)
|
||||
@@ -272,12 +273,12 @@ func EditRelease(ctx *context.APIContext) {
|
||||
|
||||
form := web.GetForm(ctx).(*api.EditReleaseOption)
|
||||
id := ctx.ParamsInt64(":id")
|
||||
rel, err := models.GetReleaseByID(ctx, id)
|
||||
if err != nil && !models.IsErrReleaseNotExist(err) {
|
||||
rel, err := repo_model.GetReleaseByID(ctx, id)
|
||||
if err != nil && !repo_model.IsErrReleaseNotExist(err) {
|
||||
ctx.Error(http.StatusInternalServerError, "GetReleaseByID", err)
|
||||
return
|
||||
}
|
||||
if err != nil && models.IsErrReleaseNotExist(err) ||
|
||||
if err != nil && repo_model.IsErrReleaseNotExist(err) ||
|
||||
rel.IsTag || rel.RepoID != ctx.Repo.Repository.ID {
|
||||
ctx.NotFound()
|
||||
return
|
||||
@@ -307,7 +308,7 @@ func EditRelease(ctx *context.APIContext) {
|
||||
}
|
||||
|
||||
// reload data from database
|
||||
rel, err = models.GetReleaseByID(ctx, id)
|
||||
rel, err = repo_model.GetReleaseByID(ctx, id)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "GetReleaseByID", err)
|
||||
return
|
||||
@@ -350,12 +351,12 @@ func DeleteRelease(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/empty"
|
||||
|
||||
id := ctx.ParamsInt64(":id")
|
||||
rel, err := models.GetReleaseByID(ctx, id)
|
||||
if err != nil && !models.IsErrReleaseNotExist(err) {
|
||||
rel, err := repo_model.GetReleaseByID(ctx, id)
|
||||
if err != nil && !repo_model.IsErrReleaseNotExist(err) {
|
||||
ctx.Error(http.StatusInternalServerError, "GetReleaseByID", err)
|
||||
return
|
||||
}
|
||||
if err != nil && models.IsErrReleaseNotExist(err) ||
|
||||
if err != nil && repo_model.IsErrReleaseNotExist(err) ||
|
||||
rel.IsTag || rel.RepoID != ctx.Repo.Repository.ID {
|
||||
ctx.NotFound()
|
||||
return
|
||||
|
@@ -7,7 +7,6 @@ package repo
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/convert"
|
||||
@@ -102,9 +101,9 @@ func ListReleaseAttachments(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/AttachmentList"
|
||||
|
||||
releaseID := ctx.ParamsInt64(":id")
|
||||
release, err := models.GetReleaseByID(ctx, releaseID)
|
||||
release, err := repo_model.GetReleaseByID(ctx, releaseID)
|
||||
if err != nil {
|
||||
if models.IsErrReleaseNotExist(err) {
|
||||
if repo_model.IsErrReleaseNotExist(err) {
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
@@ -172,9 +171,9 @@ func CreateReleaseAttachment(ctx *context.APIContext) {
|
||||
|
||||
// Check if release exists an load release
|
||||
releaseID := ctx.ParamsInt64(":id")
|
||||
release, err := models.GetReleaseByID(ctx, releaseID)
|
||||
release, err := repo_model.GetReleaseByID(ctx, releaseID)
|
||||
if err != nil {
|
||||
if models.IsErrReleaseNotExist(err) {
|
||||
if repo_model.IsErrReleaseNotExist(err) {
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/convert"
|
||||
releaseservice "code.gitea.io/gitea/services/release"
|
||||
@@ -44,9 +45,9 @@ func GetReleaseByTag(ctx *context.APIContext) {
|
||||
|
||||
tag := ctx.Params(":tag")
|
||||
|
||||
release, err := models.GetRelease(ctx.Repo.Repository.ID, tag)
|
||||
release, err := repo_model.GetRelease(ctx.Repo.Repository.ID, tag)
|
||||
if err != nil {
|
||||
if models.IsErrReleaseNotExist(err) {
|
||||
if repo_model.IsErrReleaseNotExist(err) {
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
@@ -97,9 +98,9 @@ func DeleteReleaseByTag(ctx *context.APIContext) {
|
||||
|
||||
tag := ctx.Params(":tag")
|
||||
|
||||
release, err := models.GetRelease(ctx.Repo.Repository.ID, tag)
|
||||
release, err := repo_model.GetRelease(ctx.Repo.Repository.ID, tag)
|
||||
if err != nil {
|
||||
if models.IsErrReleaseNotExist(err) {
|
||||
if repo_model.IsErrReleaseNotExist(err) {
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
@@ -11,7 +11,6 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/models/organization"
|
||||
"code.gitea.io/gitea/models/perm"
|
||||
@@ -232,7 +231,7 @@ func CreateUserRepo(ctx *context.APIContext, owner *user_model.User, opt api.Cre
|
||||
if opt.AutoInit && opt.Readme == "" {
|
||||
opt.Readme = "Default"
|
||||
}
|
||||
repo, err := repo_service.CreateRepository(ctx.Doer, owner, models.CreateRepoOptions{
|
||||
repo, err := repo_service.CreateRepository(ctx.Doer, owner, repo_module.CreateRepoOptions{
|
||||
Name: opt.Name,
|
||||
Description: opt.Description,
|
||||
IssueLabels: opt.IssueLabels,
|
||||
|
@@ -10,6 +10,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/convert"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
@@ -249,9 +250,9 @@ func DeleteTag(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/conflict"
|
||||
tagName := ctx.Params("*")
|
||||
|
||||
tag, err := models.GetRelease(ctx.Repo.Repository.ID, tagName)
|
||||
tag, err := repo_model.GetRelease(ctx.Repo.Repository.ID, tagName)
|
||||
if err != nil {
|
||||
if models.IsErrReleaseNotExist(err) {
|
||||
if repo_model.IsErrReleaseNotExist(err) {
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
"code.gitea.io/gitea/models/organization"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/convert"
|
||||
org_service "code.gitea.io/gitea/services/org"
|
||||
)
|
||||
|
||||
// ListTeams list a repository's teams
|
||||
@@ -199,7 +200,7 @@ func changeRepoTeam(ctx *context.APIContext, add bool) {
|
||||
ctx.Error(http.StatusUnprocessableEntity, "alreadyAdded", fmt.Errorf("team '%s' is already added to repo", team.Name))
|
||||
return
|
||||
}
|
||||
err = models.AddRepository(team, ctx.Repo.Repository)
|
||||
err = org_service.TeamAddRepository(team, ctx.Repo.Repository)
|
||||
} else {
|
||||
if !repoHasTeam {
|
||||
ctx.Error(http.StatusUnprocessableEntity, "notAdded", fmt.Errorf("team '%s' was not added to repo", team.Name))
|
||||
|
@@ -10,7 +10,7 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/convert"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
@@ -72,9 +72,9 @@ func NewWikiPage(ctx *context.APIContext) {
|
||||
form.ContentBase64 = string(content)
|
||||
|
||||
if err := wiki_service.AddWikiPage(ctx, ctx.Doer, ctx.Repo.Repository, wikiName, form.ContentBase64, form.Message); err != nil {
|
||||
if models.IsErrWikiReservedName(err) {
|
||||
if repo_model.IsErrWikiReservedName(err) {
|
||||
ctx.Error(http.StatusBadRequest, "IsErrWikiReservedName", err)
|
||||
} else if models.IsErrWikiAlreadyExist(err) {
|
||||
} else if repo_model.IsErrWikiAlreadyExist(err) {
|
||||
ctx.Error(http.StatusBadRequest, "IsErrWikiAlreadyExists", err)
|
||||
} else {
|
||||
ctx.Error(http.StatusInternalServerError, "AddWikiPage", err)
|
||||
@@ -314,7 +314,7 @@ func ListWikiPages(ctx *context.APIContext) {
|
||||
}
|
||||
wikiName, err := wiki_service.FilenameToName(entry.Name())
|
||||
if err != nil {
|
||||
if models.IsErrWikiInvalidFileName(err) {
|
||||
if repo_model.IsErrWikiInvalidFileName(err) {
|
||||
continue
|
||||
}
|
||||
ctx.Error(http.StatusInternalServerError, "WikiFilenameToName", err)
|
||||
|
@@ -5,7 +5,7 @@
|
||||
package swagger
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/models"
|
||||
activities_model "code.gitea.io/gitea/models/activities"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
@@ -40,7 +40,7 @@ type swaggerModelEditUserOption struct {
|
||||
// swagger:response UserHeatmapData
|
||||
type swaggerResponseUserHeatmapData struct {
|
||||
// in:body
|
||||
Body []models.UserHeatmapData `json:"body"`
|
||||
Body []activities_model.UserHeatmapData `json:"body"`
|
||||
}
|
||||
|
||||
// UserSettings
|
||||
|
@@ -11,8 +11,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/auth"
|
||||
auth_model "code.gitea.io/gitea/models/auth"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/convert"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
@@ -45,14 +44,14 @@ func ListAccessTokens(ctx *context.APIContext) {
|
||||
// "200":
|
||||
// "$ref": "#/responses/AccessTokenList"
|
||||
|
||||
opts := models.ListAccessTokensOptions{UserID: ctx.Doer.ID, ListOptions: utils.GetListOptions(ctx)}
|
||||
opts := auth_model.ListAccessTokensOptions{UserID: ctx.Doer.ID, ListOptions: utils.GetListOptions(ctx)}
|
||||
|
||||
count, err := models.CountAccessTokens(opts)
|
||||
count, err := auth_model.CountAccessTokens(opts)
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
}
|
||||
tokens, err := models.ListAccessTokens(opts)
|
||||
tokens, err := auth_model.ListAccessTokens(opts)
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
@@ -98,12 +97,12 @@ func CreateAccessToken(ctx *context.APIContext) {
|
||||
|
||||
form := web.GetForm(ctx).(*api.CreateAccessTokenOption)
|
||||
|
||||
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.InternalServerError(err)
|
||||
return
|
||||
@@ -113,7 +112,7 @@ func CreateAccessToken(ctx *context.APIContext) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := models.NewAccessToken(t); err != nil {
|
||||
if err := auth_model.NewAccessToken(t); err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "NewAccessToken", err)
|
||||
return
|
||||
}
|
||||
@@ -155,7 +154,7 @@ func DeleteAccessToken(ctx *context.APIContext) {
|
||||
tokenID, _ := strconv.ParseInt(token, 0, 64)
|
||||
|
||||
if tokenID == 0 {
|
||||
tokens, err := models.ListAccessTokens(models.ListAccessTokensOptions{
|
||||
tokens, err := auth_model.ListAccessTokens(auth_model.ListAccessTokensOptions{
|
||||
Name: token,
|
||||
UserID: ctx.Doer.ID,
|
||||
})
|
||||
@@ -180,8 +179,8 @@ func DeleteAccessToken(ctx *context.APIContext) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := models.DeleteAccessTokenByID(tokenID, ctx.Doer.ID); err != nil {
|
||||
if models.IsErrAccessTokenNotExist(err) {
|
||||
if err := auth_model.DeleteAccessTokenByID(tokenID, ctx.Doer.ID); err != nil {
|
||||
if auth_model.IsErrAccessTokenNotExist(err) {
|
||||
ctx.NotFound()
|
||||
} else {
|
||||
ctx.Error(http.StatusInternalServerError, "DeleteAccessTokenByID", err)
|
||||
@@ -213,7 +212,7 @@ func CreateOauth2Application(ctx *context.APIContext) {
|
||||
|
||||
data := web.GetForm(ctx).(*api.CreateOAuth2ApplicationOptions)
|
||||
|
||||
app, err := auth.CreateOAuth2Application(ctx, auth.CreateOAuth2ApplicationOptions{
|
||||
app, err := auth_model.CreateOAuth2Application(ctx, auth_model.CreateOAuth2ApplicationOptions{
|
||||
Name: data.Name,
|
||||
UserID: ctx.Doer.ID,
|
||||
RedirectURIs: data.RedirectURIs,
|
||||
@@ -252,7 +251,7 @@ func ListOauth2Applications(ctx *context.APIContext) {
|
||||
// "200":
|
||||
// "$ref": "#/responses/OAuth2ApplicationList"
|
||||
|
||||
apps, total, err := auth.ListOAuth2Applications(ctx.Doer.ID, utils.GetListOptions(ctx))
|
||||
apps, total, err := auth_model.ListOAuth2Applications(ctx.Doer.ID, utils.GetListOptions(ctx))
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "ListOAuth2Applications", err)
|
||||
return
|
||||
@@ -288,8 +287,8 @@ func DeleteOauth2Application(ctx *context.APIContext) {
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
appID := ctx.ParamsInt64(":id")
|
||||
if err := auth.DeleteOAuth2Application(appID, ctx.Doer.ID); err != nil {
|
||||
if auth.IsErrOAuthApplicationNotFound(err) {
|
||||
if err := auth_model.DeleteOAuth2Application(appID, ctx.Doer.ID); err != nil {
|
||||
if auth_model.IsErrOAuthApplicationNotFound(err) {
|
||||
ctx.NotFound()
|
||||
} else {
|
||||
ctx.Error(http.StatusInternalServerError, "DeleteOauth2ApplicationByID", err)
|
||||
@@ -320,9 +319,9 @@ func GetOauth2Application(ctx *context.APIContext) {
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
appID := ctx.ParamsInt64(":id")
|
||||
app, err := auth.GetOAuth2ApplicationByID(ctx, appID)
|
||||
app, err := auth_model.GetOAuth2ApplicationByID(ctx, appID)
|
||||
if err != nil {
|
||||
if auth.IsErrOauthClientIDInvalid(err) || auth.IsErrOAuthApplicationNotFound(err) {
|
||||
if auth_model.IsErrOauthClientIDInvalid(err) || auth_model.IsErrOAuthApplicationNotFound(err) {
|
||||
ctx.NotFound()
|
||||
} else {
|
||||
ctx.Error(http.StatusInternalServerError, "GetOauth2ApplicationByID", err)
|
||||
@@ -363,14 +362,14 @@ func UpdateOauth2Application(ctx *context.APIContext) {
|
||||
|
||||
data := web.GetForm(ctx).(*api.CreateOAuth2ApplicationOptions)
|
||||
|
||||
app, err := auth.UpdateOAuth2Application(auth.UpdateOAuth2ApplicationOptions{
|
||||
app, err := auth_model.UpdateOAuth2Application(auth_model.UpdateOAuth2ApplicationOptions{
|
||||
Name: data.Name,
|
||||
UserID: ctx.Doer.ID,
|
||||
ID: appID,
|
||||
RedirectURIs: data.RedirectURIs,
|
||||
})
|
||||
if err != nil {
|
||||
if auth.IsErrOauthClientIDInvalid(err) || auth.IsErrOAuthApplicationNotFound(err) {
|
||||
if auth_model.IsErrOauthClientIDInvalid(err) || auth_model.IsErrOAuthApplicationNotFound(err) {
|
||||
ctx.NotFound()
|
||||
} else {
|
||||
ctx.Error(http.StatusInternalServerError, "UpdateOauth2ApplicationByID", err)
|
||||
|
@@ -8,7 +8,7 @@ package user
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
activities_model "code.gitea.io/gitea/models/activities"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/convert"
|
||||
@@ -139,7 +139,7 @@ func GetUserHeatmapData(ctx *context.APIContext) {
|
||||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
|
||||
heatmap, err := models.GetUserHeatmapDataByUser(ctx.ContextUser, ctx.Doer)
|
||||
heatmap, err := activities_model.GetUserHeatmapDataByUser(ctx.ContextUser, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "GetUserHeatmapDataByUser", err)
|
||||
return
|
||||
|
@@ -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