mirror of
https://github.com/go-gitea/gitea
synced 2025-08-05 00:58:19 +00:00
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
This commit is contained in:
@@ -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
|
||||
|
@@ -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")]
|
||||
|
@@ -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)
|
||||
}
|
||||
|
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user