diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index f42f961e..9b1847a5 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.sqlite +*.db-journal *.db *.sql main diff --git a/router/router.go b/router/router.go old mode 100644 new mode 100755 index 6e640ed3..05bb50f7 --- a/router/router.go +++ b/router/router.go @@ -37,6 +37,7 @@ func init() { gzipUserLogoutHandler := handlers.CompressHandler(http.HandlerFunc(UserLogoutHandler)) gzipUserProfileHandler := handlers.CompressHandler(http.HandlerFunc(UserProfileHandler)) gzipUserFollowHandler := handlers.CompressHandler(http.HandlerFunc(UserFollowHandler)) + gzipUserDetailsHandler := handlers.CompressHandler(http.HandlerFunc(UserDetailsHandler)) gzipUserProfileFormHandler := handlers.CompressHandler(http.HandlerFunc(UserProfileFormHandler)) gzipIndexModPanel := handlers.CompressHandler(http.HandlerFunc(IndexModPanel)) @@ -81,7 +82,8 @@ func init() { Router.Handle("/user/logout", gzipUserLogoutHandler).Name("user_logout") Router.Handle("/user/{id}/{username}", wrapHandler(gzipUserProfileHandler)).Name("user_profile").Methods("GET") Router.Handle("/user/{id}/{username}/follow", gzipUserFollowHandler).Name("user_follow").Methods("GET") - Router.Handle("/user/{id}/{username}", wrapHandler(gzipUserProfileFormHandler)).Name("user_profile").Methods("POST") + Router.Handle("/user/{id}/{username}/edit", wrapHandler(gzipUserDetailsHandler)).Name("user_profile_details").Methods("GET") + Router.Handle("/user/{id}/{username}/edit", wrapHandler(gzipUserProfileFormHandler)).Name("user_profile_edit").Methods("POST") Router.Handle("/mod", gzipIndexModPanel).Name("mod_index") Router.Handle("/mod/torrents", gzipTorrentsListPanel).Name("mod_tlist") diff --git a/router/userHandler.go b/router/userHandler.go index 642eb315..3a35a654 100755 --- a/router/userHandler.go +++ b/router/userHandler.go @@ -54,25 +54,12 @@ func UserProfileHandler(w http.ResponseWriter, r *http.Request) { userProfile, _, errorUser := userService.RetrieveUserForAdmin(id) if errorUser == nil { currentUser := GetUser(r) - view := r.URL.Query()["edit"] follow := r.URL.Query()["followed"] unfollow := r.URL.Query()["unfollowed"] infosForm := form.NewInfos() deleteVar := r.URL.Query()["delete"] - if (view != nil) && (userPermission.CurrentOrAdmin(currentUser, userProfile.ID)) { - b := form.UserForm{} - modelHelper.BindValueForm(&b, r) - languages.SetTranslationFromRequest(viewProfileEditTemplate, r, "en-us") - searchForm := NewSearchForm() - searchForm.HideAdvancedSearch = true - htv := UserProfileEditVariables{&userProfile, b, form.NewErrors(), form.NewInfos(), searchForm, Navigation{}, currentUser, r.URL, mux.CurrentRoute(r)} - - err := viewProfileEditTemplate.ExecuteTemplate(w, "index.html", htv) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - } - } else if (deleteVar != nil) && (userPermission.CurrentOrAdmin(currentUser, userProfile.ID)) { + if (deleteVar != nil) && (userPermission.CurrentOrAdmin(currentUser, userProfile.ID)) { err := form.NewErrors() _, errUser := userService.DeleteUser(w, currentUser, id) if errUser != nil { @@ -115,6 +102,25 @@ func UserProfileHandler(w http.ResponseWriter, r *http.Request) { } } +//Getting User Profile Details View +func UserDetailsHandler(w http.ResponseWriter, r *http.Request) { + vars := mux.Vars(r) + id := vars["id"] + b := form.UserForm{} + userProfile, _, errorUser := userService.RetrieveUserForAdmin(id) + if errorUser == nil { + currentUser := GetUser(r) + modelHelper.BindValueForm(&b, r) + languages.SetTranslationFromRequest(viewProfileEditTemplate, r, "en-us") + searchForm := NewSearchForm() + searchForm.HideAdvancedSearch = true + htv := UserProfileEditVariables{&userProfile, b, form.NewErrors(), form.NewInfos(), searchForm, Navigation{}, currentUser, r.URL, mux.CurrentRoute(r)} + err := viewProfileEditTemplate.ExecuteTemplate(w, "index.html", htv) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + } + } +} // Getting View User Profile Update func UserProfileFormHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) diff --git a/templates/user/profile.html b/templates/user/profile.html index 283ffd55..b9b31fad 100755 --- a/templates/user/profile.html +++ b/templates/user/profile.html @@ -41,18 +41,15 @@
diff --git a/templates/user/profile_edit.html b/templates/user/profile_edit.html old mode 100644 new mode 100755 index 5378a0bc..7b6f9373 --- a/templates/user/profile_edit.html +++ b/templates/user/profile_edit.html @@ -23,13 +23,13 @@ @@ -38,18 +38,14 @@