diff --git a/routers/web/user/package.go b/routers/web/user/package.go index 59aaf07ff..5c553d754 100644 --- a/routers/web/user/package.go +++ b/routers/web/user/package.go @@ -355,6 +355,27 @@ func PackageSettingsPost(ctx *context.Context) { ctx.Flash.Error(ctx.Tr("packages.settings.link.error")) } + ctx.Redirect(ctx.Link) + return + case "update": + success := func() bool { + description := form.Description + readme := form.Readme + + if err := packages_model.SetDescriptions(ctx, pd.Package.ID, description, readme); err != nil { + log.Error("Error updating package: %v", err) + return false + } + + return true + }() + + if success { + ctx.Flash.Success(ctx.Tr("packages.settings.descriptions.success")) + } else { + ctx.Flash.Error(ctx.Tr("packages.settings.descriptions.error")) + } + ctx.Redirect(ctx.Link) return case "delete": diff --git a/services/forms/user_form.go b/services/forms/user_form.go index c8f2b02d8..ea19152aa 100644 --- a/services/forms/user_form.go +++ b/services/forms/user_form.go @@ -434,8 +434,10 @@ func (f *WebauthnDeleteForm) Validate(req *http.Request, errs binding.Errors) bi // PackageSettingForm form for package settings type PackageSettingForm struct { - Action string - RepoID int64 `form:"repo_id"` + Action string + RepoID int64 `form:"repo_id"` + Description string `form:"description"` + Readme string `form:"readme"` } // Validate validates the fields