parent
c2fc8a0887
commit
d1f68e4f7a
4 changed files with 25 additions and 15 deletions
|
@ -6,11 +6,13 @@ import (
|
|||
"path/filepath"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
"github.com/photoprism/photoprism/internal/acl"
|
||||
"github.com/photoprism/photoprism/internal/event"
|
||||
"github.com/photoprism/photoprism/internal/i18n"
|
||||
"github.com/photoprism/photoprism/internal/service"
|
||||
"github.com/photoprism/photoprism/pkg/fs"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// GetConfig returns client config values.
|
||||
|
@ -133,7 +135,7 @@ func SaveConfigOptions(router *gin.RouterGroup) {
|
|||
|
||||
UpdateClientConfig()
|
||||
|
||||
log.Infof(i18n.Msg(i18n.MsgSettingsSaved))
|
||||
event.InfoMsg(i18n.MsgSettingsSaved)
|
||||
|
||||
c.JSON(http.StatusOK, conf.Options())
|
||||
})
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
func findFileMarker(c *gin.Context) (file *entity.File, marker *entity.Marker, err error) {
|
||||
// Check authorization.
|
||||
s := Auth(SessionID(c), acl.ResourceFiles, acl.ActionUpdate)
|
||||
|
||||
if s.Invalid() {
|
||||
AbortUnauthorized(c)
|
||||
return nil, nil, fmt.Errorf("unauthorized")
|
||||
|
@ -75,22 +76,21 @@ func UpdateMarker(router *gin.RouterGroup) {
|
|||
return
|
||||
}
|
||||
|
||||
markerForm, err := form.NewMarker(*marker)
|
||||
// Initialize form.
|
||||
f, err := form.NewMarker(*marker)
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("marker: %s (new form)", err)
|
||||
AbortSaveFailed(c)
|
||||
return
|
||||
}
|
||||
|
||||
if err := c.BindJSON(&markerForm); err != nil {
|
||||
} else if err := c.BindJSON(&f); err != nil {
|
||||
log.Errorf("marker: %s (update form)", err)
|
||||
AbortBadRequest(c)
|
||||
return
|
||||
}
|
||||
|
||||
// Update marker from form values.
|
||||
if changed, err := marker.SaveForm(markerForm); err != nil {
|
||||
if changed, err := marker.SaveForm(f); err != nil {
|
||||
log.Errorf("marker: %s", err)
|
||||
AbortSaveFailed(c)
|
||||
return
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/photoprism/photoprism/internal/acl"
|
||||
"github.com/photoprism/photoprism/internal/event"
|
||||
"github.com/photoprism/photoprism/internal/i18n"
|
||||
"github.com/photoprism/photoprism/internal/service"
|
||||
)
|
||||
|
@ -58,7 +59,7 @@ func SaveSettings(router *gin.RouterGroup) {
|
|||
|
||||
UpdateClientConfig()
|
||||
|
||||
log.Infof(i18n.Msg(i18n.MsgSettingsSaved))
|
||||
event.InfoMsg(i18n.MsgSettingsSaved)
|
||||
|
||||
c.JSON(http.StatusOK, settings)
|
||||
})
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
|
||||
"github.com/photoprism/photoprism/internal/acl"
|
||||
"github.com/photoprism/photoprism/internal/entity"
|
||||
"github.com/photoprism/photoprism/internal/event"
|
||||
|
@ -84,13 +85,6 @@ func UpdateSubject(router *gin.RouterGroup) {
|
|||
return
|
||||
}
|
||||
|
||||
var f form.Subject
|
||||
|
||||
if err := c.BindJSON(&f); err != nil {
|
||||
AbortBadRequest(c)
|
||||
return
|
||||
}
|
||||
|
||||
uid := c.Param("uid")
|
||||
m := entity.FindSubject(uid)
|
||||
|
||||
|
@ -99,6 +93,19 @@ func UpdateSubject(router *gin.RouterGroup) {
|
|||
return
|
||||
}
|
||||
|
||||
// Initialize form.
|
||||
f, err := form.NewSubject(*m)
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("subject: %s (new form)", err)
|
||||
AbortSaveFailed(c)
|
||||
return
|
||||
} else if err := c.BindJSON(&f); err != nil {
|
||||
log.Errorf("subject: %s (update form)", err)
|
||||
AbortBadRequest(c)
|
||||
return
|
||||
}
|
||||
|
||||
// Update subject from form values.
|
||||
if changed, err := m.SaveForm(f); err != nil {
|
||||
log.Errorf("subject: %s", err)
|
||||
|
|
Loading…
Reference in a new issue