diff options
author | 6543 <6543@obermui.de> | 2020-12-25 09:59:32 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-25 11:59:32 +0200 |
commit | a19447aed128ecadfcd938d6a80cd4951af1f4ce (patch) | |
tree | 6312bf946d601aab29731645a4777feeaea66036 /routers/admin | |
parent | 04ae0f2f3f4556c6d0b4adc5f2cffd0cc7d25151 (diff) | |
download | gitea-a19447aed128ecadfcd938d6a80cd4951af1f4ce.tar.gz gitea-a19447aed128ecadfcd938d6a80cd4951af1f4ce.zip |
migrate from com.* to alternatives (#14103)
* remove github.com/unknwon/com from models
* dont use "com.ToStr()"
* replace "com.ToStr" with "fmt.Sprint" where its easy to do
* more refactor
* fix test
* just "proxy" Copy func for now
* as per @lunny
Diffstat (limited to 'routers/admin')
-rw-r--r-- | routers/admin/auths.go | 3 | ||||
-rw-r--r-- | routers/admin/emails.go | 4 | ||||
-rw-r--r-- | routers/admin/notice.go | 6 | ||||
-rw-r--r-- | routers/admin/users.go | 17 |
4 files changed, 14 insertions, 16 deletions
diff --git a/routers/admin/auths.go b/routers/admin/auths.go index bae1c863e9..ce9dd38360 100644 --- a/routers/admin/auths.go +++ b/routers/admin/auths.go @@ -20,7 +20,6 @@ import ( "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" - "github.com/unknwon/com" "xorm.io/xorm/convert" ) @@ -373,7 +372,7 @@ func EditAuthSourcePost(ctx *context.Context, form auth.AuthenticationForm) { log.Trace("Authentication changed by admin(%s): %d", ctx.User.Name, source.ID) ctx.Flash.Success(ctx.Tr("admin.auths.update_success")) - ctx.Redirect(setting.AppSubURL + "/admin/auths/" + com.ToStr(form.ID)) + ctx.Redirect(setting.AppSubURL + "/admin/auths/" + fmt.Sprint(form.ID)) } // DeleteAuthSource response for deleting an auth source diff --git a/routers/admin/emails.go b/routers/admin/emails.go index f0b14ce5e5..4cc7253ca9 100644 --- a/routers/admin/emails.go +++ b/routers/admin/emails.go @@ -14,8 +14,6 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" - - "github.com/unknwon/com" ) const ( @@ -114,7 +112,7 @@ func ActivateEmail(ctx *context.Context) { truefalse := map[string]bool{"1": true, "0": false} - uid := com.StrTo(ctx.Query("uid")).MustInt64() + uid := ctx.QueryInt64("uid") email := ctx.Query("email") primary, okp := truefalse[ctx.Query("primary")] activate, oka := truefalse[ctx.Query("activate")] diff --git a/routers/admin/notice.go b/routers/admin/notice.go index ad2bad2163..2ee1b59730 100644 --- a/routers/admin/notice.go +++ b/routers/admin/notice.go @@ -6,13 +6,13 @@ package admin import ( + "strconv" + "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" - - "github.com/unknwon/com" ) const ( @@ -50,7 +50,7 @@ func DeleteNotices(ctx *context.Context) { strs := ctx.QueryStrings("ids[]") ids := make([]int64, 0, len(strs)) for i := range strs { - id := com.StrTo(strs[i]).MustInt64() + id, _ := strconv.ParseInt(strs[i], 10, 64) if id > 0 { ids = append(ids, id) } diff --git a/routers/admin/users.go b/routers/admin/users.go index 06c391b8e0..2ea496624b 100644 --- a/routers/admin/users.go +++ b/routers/admin/users.go @@ -6,6 +6,8 @@ package admin import ( + "fmt" + "strconv" "strings" "code.gitea.io/gitea/models" @@ -17,8 +19,6 @@ import ( "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/routers" "code.gitea.io/gitea/services/mailer" - - "github.com/unknwon/com" ) const ( @@ -92,8 +92,9 @@ func NewUserPost(ctx *context.Context, form auth.AdminCreateUserForm) { if len(form.LoginType) > 0 { fields := strings.Split(form.LoginType, "-") if len(fields) == 2 { - u.LoginType = models.LoginType(com.StrTo(fields[0]).MustInt()) - u.LoginSource = com.StrTo(fields[1]).MustInt64() + lType, _ := strconv.ParseInt(fields[0], 10, 0) + u.LoginType = models.LoginType(lType) + u.LoginSource, _ = strconv.ParseInt(fields[1], 10, 64) u.LoginName = form.LoginName } } @@ -154,7 +155,7 @@ func NewUserPost(ctx *context.Context, form auth.AdminCreateUserForm) { } ctx.Flash.Success(ctx.Tr("admin.users.new_success", u.Name)) - ctx.Redirect(setting.AppSubURL + "/admin/users/" + com.ToStr(u.ID)) + ctx.Redirect(setting.AppSubURL + "/admin/users/" + fmt.Sprint(u.ID)) } func prepareUserInfo(ctx *context.Context) *models.User { @@ -220,12 +221,12 @@ func EditUserPost(ctx *context.Context, form auth.AdminEditUserForm) { fields := strings.Split(form.LoginType, "-") if len(fields) == 2 { - loginType := models.LoginType(com.StrTo(fields[0]).MustInt()) - loginSource := com.StrTo(fields[1]).MustInt64() + loginType, _ := strconv.ParseInt(fields[0], 10, 0) + loginSource, _ := strconv.ParseInt(fields[1], 10, 64) if u.LoginSource != loginSource { u.LoginSource = loginSource - u.LoginType = loginType + u.LoginType = models.LoginType(loginType) } } |