add form handler
This commit is contained in:
parent
adb7da0cec
commit
86d371eb6f
|
@ -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":
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue