aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/user
diff options
context:
space:
mode:
Diffstat (limited to 'routers/web/user')
-rw-r--r--routers/web/user/home.go8
-rw-r--r--routers/web/user/notification.go30
-rw-r--r--routers/web/user/profile.go6
-rw-r--r--routers/web/user/setting/adopt.go4
-rw-r--r--routers/web/user/setting/applications.go17
-rw-r--r--routers/web/user/setting/security/security.go13
-rw-r--r--routers/web/user/task.go10
7 files changed, 43 insertions, 45 deletions
diff --git a/routers/web/user/home.go b/routers/web/user/home.go
index c4aa749ce2..837caedc84 100644
--- a/routers/web/user/home.go
+++ b/routers/web/user/home.go
@@ -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,
diff --git a/routers/web/user/notification.go b/routers/web/user/notification.go
index 9e658bcb14..5e8142cec7 100644
--- a/routers/web/user/notification.go
+++ b/routers/web/user/notification.go
@@ -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)})
}
diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go
index c804be3c5f..a3452fd692 100644
--- a/routers/web/user/profile.go
+++ b/routers/web/user/profile.go
@@ -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,
diff --git a/routers/web/user/setting/adopt.go b/routers/web/user/setting/adopt.go
index c7139f8bb1..a92aa6e989 100644
--- a/routers/web/user/setting/adopt.go
+++ b/routers/web/user/setting/adopt.go
@@ -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 {
diff --git a/routers/web/user/setting/applications.go b/routers/web/user/setting/applications.go
index 4ffec47801..e9572a07a6 100644
--- a/routers/web/user/setting/applications.go
+++ b/routers/web/user/setting/applications.go
@@ -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
diff --git a/routers/web/user/setting/security/security.go b/routers/web/user/setting/security/security.go
index 218cf57ab7..57ea24eeb1 100644
--- a/routers/web/user/setting/security/security.go
+++ b/routers/web/user/setting/security/security.go
@@ -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 {
diff --git a/routers/web/user/task.go b/routers/web/user/task.go
index fd561cdd4c..7f5ef792ad 100644
--- a/routers/web/user/task.go
+++ b/routers/web/user/task.go
@@ -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},
}