Code cleanup
This commit is contained in:
parent
8078ff8755
commit
77a9d9a7fd
|
@ -15,7 +15,6 @@ import (
|
||||||
|
|
||||||
// BatchEdit controller (/photo/batch-edit?id=N) to change properties about your picture.
|
// BatchEdit controller (/photo/batch-edit?id=N) to change properties about your picture.
|
||||||
func BatchEdit() http.HandlerFunc {
|
func BatchEdit() http.HandlerFunc {
|
||||||
// Reuse the upload page but with an EditPhoto variable.
|
|
||||||
tmpl := templates.Must("photo/batch_edit.html")
|
tmpl := templates.Must("photo/batch_edit.html")
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
var (
|
var (
|
||||||
|
@ -35,8 +34,6 @@ func BatchEdit() http.HandlerFunc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Error("photoIDs: %+v", photoIDs)
|
|
||||||
|
|
||||||
// Validation.
|
// Validation.
|
||||||
if len(photoIDs) == 0 || len(photoIDs) > 100 {
|
if len(photoIDs) == 0 || len(photoIDs) > 100 {
|
||||||
session.FlashError(w, r, "Invalid number of photo IDs.")
|
session.FlashError(w, r, "Invalid number of photo IDs.")
|
||||||
|
@ -59,17 +56,11 @@ func BatchEdit() http.HandlerFunc {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// In case an admin is editing this photo: remember the HTTP request current user,
|
|
||||||
// before the currentUser may be set to the photo's owner below.
|
|
||||||
// var requestUser = currentUser
|
|
||||||
|
|
||||||
// Validate permission to edit all of these photos.
|
// Validate permission to edit all of these photos.
|
||||||
var (
|
var (
|
||||||
ownerIDs []uint64
|
ownerIDs []uint64
|
||||||
mapPhotos = map[uint64]*models.Photo{}
|
|
||||||
)
|
)
|
||||||
for _, photo := range photos {
|
for _, photo := range photos {
|
||||||
mapPhotos[photo.ID] = photo
|
|
||||||
|
|
||||||
if !photo.CanBeEditedBy(currentUser) {
|
if !photo.CanBeEditedBy(currentUser) {
|
||||||
templates.ForbiddenPage(w, r)
|
templates.ForbiddenPage(w, r)
|
||||||
|
@ -95,7 +86,7 @@ func BatchEdit() http.HandlerFunc {
|
||||||
|
|
||||||
// Check if this user's profile ID is being deleted.
|
// Check if this user's profile ID is being deleted.
|
||||||
if user.ProfilePhotoID != nil {
|
if user.ProfilePhotoID != nil {
|
||||||
if _, ok := mapPhotos[*user.ProfilePhotoID]; ok {
|
if _, ok := photos[*user.ProfilePhotoID]; ok {
|
||||||
wasUserProfilePicture[user.ID] = true
|
wasUserProfilePicture[user.ID] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,7 +97,7 @@ func BatchEdit() http.HandlerFunc {
|
||||||
|
|
||||||
confirm := r.PostFormValue("confirm") == "true"
|
confirm := r.PostFormValue("confirm") == "true"
|
||||||
if !confirm {
|
if !confirm {
|
||||||
session.FlashError(w, r, "Confirm you want to delete this photo.")
|
session.FlashError(w, r, "Confirm you want to modify this photo.")
|
||||||
templates.Redirect(w, redirectURI)
|
templates.Redirect(w, redirectURI)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user