From 77a9d9a7fd83beaf8c9c08e053a3a85aad7ed40d Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Fri, 4 Oct 2024 21:22:52 -0700 Subject: [PATCH] Code cleanup --- pkg/controller/photo/batch_edit.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/pkg/controller/photo/batch_edit.go b/pkg/controller/photo/batch_edit.go index 0229a43..6c79967 100644 --- a/pkg/controller/photo/batch_edit.go +++ b/pkg/controller/photo/batch_edit.go @@ -15,7 +15,6 @@ import ( // BatchEdit controller (/photo/batch-edit?id=N) to change properties about your picture. func BatchEdit() http.HandlerFunc { - // Reuse the upload page but with an EditPhoto variable. tmpl := templates.Must("photo/batch_edit.html") return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { var ( @@ -35,8 +34,6 @@ func BatchEdit() http.HandlerFunc { } } - log.Error("photoIDs: %+v", photoIDs) - // Validation. if len(photoIDs) == 0 || len(photoIDs) > 100 { session.FlashError(w, r, "Invalid number of photo IDs.") @@ -59,17 +56,11 @@ func BatchEdit() http.HandlerFunc { 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. var ( - ownerIDs []uint64 - mapPhotos = map[uint64]*models.Photo{} + ownerIDs []uint64 ) for _, photo := range photos { - mapPhotos[photo.ID] = photo if !photo.CanBeEditedBy(currentUser) { templates.ForbiddenPage(w, r) @@ -95,7 +86,7 @@ func BatchEdit() http.HandlerFunc { // Check if this user's profile ID is being deleted. if user.ProfilePhotoID != nil { - if _, ok := mapPhotos[*user.ProfilePhotoID]; ok { + if _, ok := photos[*user.ProfilePhotoID]; ok { wasUserProfilePicture[user.ID] = true } } @@ -106,7 +97,7 @@ func BatchEdit() http.HandlerFunc { confirm := r.PostFormValue("confirm") == "true" 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) return }