Merge pull request #278 from ripdog/master
Fix broken menu on user profile page and fix advanced search showing on profile page
Cette révision appartient à :
révision
1229accfa2
5 fichiers modifiés avec 53 ajouts et 45 suppressions
1
.gitignore
externe
Fichier normal → Fichier exécutable
1
.gitignore
externe
Fichier normal → Fichier exécutable
|
@ -1,4 +1,5 @@
|
||||||
*.sqlite
|
*.sqlite
|
||||||
|
*.db-journal
|
||||||
*.db
|
*.db
|
||||||
*.sql
|
*.sql
|
||||||
main
|
main
|
||||||
|
|
4
router/router.go
Fichier normal → Fichier exécutable
4
router/router.go
Fichier normal → Fichier exécutable
|
@ -37,6 +37,7 @@ func init() {
|
||||||
gzipUserLogoutHandler := handlers.CompressHandler(http.HandlerFunc(UserLogoutHandler))
|
gzipUserLogoutHandler := handlers.CompressHandler(http.HandlerFunc(UserLogoutHandler))
|
||||||
gzipUserProfileHandler := handlers.CompressHandler(http.HandlerFunc(UserProfileHandler))
|
gzipUserProfileHandler := handlers.CompressHandler(http.HandlerFunc(UserProfileHandler))
|
||||||
gzipUserFollowHandler := handlers.CompressHandler(http.HandlerFunc(UserFollowHandler))
|
gzipUserFollowHandler := handlers.CompressHandler(http.HandlerFunc(UserFollowHandler))
|
||||||
|
gzipUserDetailsHandler := handlers.CompressHandler(http.HandlerFunc(UserDetailsHandler))
|
||||||
gzipUserProfileFormHandler := handlers.CompressHandler(http.HandlerFunc(UserProfileFormHandler))
|
gzipUserProfileFormHandler := handlers.CompressHandler(http.HandlerFunc(UserProfileFormHandler))
|
||||||
|
|
||||||
gzipIndexModPanel := handlers.CompressHandler(http.HandlerFunc(IndexModPanel))
|
gzipIndexModPanel := handlers.CompressHandler(http.HandlerFunc(IndexModPanel))
|
||||||
|
@ -81,7 +82,8 @@ func init() {
|
||||||
Router.Handle("/user/logout", gzipUserLogoutHandler).Name("user_logout")
|
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}", wrapHandler(gzipUserProfileHandler)).Name("user_profile").Methods("GET")
|
||||||
Router.Handle("/user/{id}/{username}/follow", gzipUserFollowHandler).Name("user_follow").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", gzipIndexModPanel).Name("mod_index")
|
||||||
Router.Handle("/mod/torrents", gzipTorrentsListPanel).Name("mod_tlist")
|
Router.Handle("/mod/torrents", gzipTorrentsListPanel).Name("mod_tlist")
|
||||||
|
|
40
router/userHandler.go
Fichier normal → Fichier exécutable
40
router/userHandler.go
Fichier normal → Fichier exécutable
|
@ -54,30 +54,21 @@ func UserProfileHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
userProfile, _, errorUser := userService.RetrieveUserForAdmin(id)
|
userProfile, _, errorUser := userService.RetrieveUserForAdmin(id)
|
||||||
if errorUser == nil {
|
if errorUser == nil {
|
||||||
currentUser := GetUser(r)
|
currentUser := GetUser(r)
|
||||||
view := r.URL.Query()["edit"]
|
|
||||||
follow := r.URL.Query()["followed"]
|
follow := r.URL.Query()["followed"]
|
||||||
unfollow := r.URL.Query()["unfollowed"]
|
unfollow := r.URL.Query()["unfollowed"]
|
||||||
infosForm := form.NewInfos()
|
infosForm := form.NewInfos()
|
||||||
deleteVar := r.URL.Query()["delete"]
|
deleteVar := r.URL.Query()["delete"]
|
||||||
|
|
||||||
if (view != nil) && (userPermission.CurrentOrAdmin(currentUser, userProfile.ID)) {
|
if (deleteVar != nil) && (userPermission.CurrentOrAdmin(currentUser, userProfile.ID)) {
|
||||||
b := form.UserForm{}
|
|
||||||
modelHelper.BindValueForm(&b, r)
|
|
||||||
languages.SetTranslationFromRequest(viewProfileEditTemplate, r, "en-us")
|
|
||||||
htv := UserProfileEditVariables{&userProfile, b, form.NewErrors(), form.NewInfos(), NewSearchForm(), 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)) {
|
|
||||||
err := form.NewErrors()
|
err := form.NewErrors()
|
||||||
_, errUser := userService.DeleteUser(w, currentUser, id)
|
_, errUser := userService.DeleteUser(w, currentUser, id)
|
||||||
if errUser != nil {
|
if errUser != nil {
|
||||||
err["errors"] = append(err["errors"], errUser.Error())
|
err["errors"] = append(err["errors"], errUser.Error())
|
||||||
}
|
}
|
||||||
languages.SetTranslationFromRequest(viewUserDeleteTemplate, r, "en-us")
|
languages.SetTranslationFromRequest(viewUserDeleteTemplate, r, "en-us")
|
||||||
htv := UserVerifyTemplateVariables{err, NewSearchForm(), Navigation{}, GetUser(r), r.URL, mux.CurrentRoute(r)}
|
searchForm := NewSearchForm()
|
||||||
|
searchForm.HideAdvancedSearch = true
|
||||||
|
htv := UserVerifyTemplateVariables{err, searchForm, Navigation{}, GetUser(r), r.URL, mux.CurrentRoute(r)}
|
||||||
errorTmpl := viewUserDeleteTemplate.ExecuteTemplate(w, "index.html", htv)
|
errorTmpl := viewUserDeleteTemplate.ExecuteTemplate(w, "index.html", htv)
|
||||||
if errorTmpl != nil {
|
if errorTmpl != nil {
|
||||||
http.Error(w, errorTmpl.Error(), http.StatusInternalServerError)
|
http.Error(w, errorTmpl.Error(), http.StatusInternalServerError)
|
||||||
|
@ -90,7 +81,9 @@ func UserProfileHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
if unfollow != nil {
|
if unfollow != nil {
|
||||||
infosForm["infos"] = append(infosForm["infos"], fmt.Sprintf(T("user_unfollowed_msg"), userProfile.Username))
|
infosForm["infos"] = append(infosForm["infos"], fmt.Sprintf(T("user_unfollowed_msg"), userProfile.Username))
|
||||||
}
|
}
|
||||||
htv := UserProfileVariables{&userProfile, infosForm, NewSearchForm(), Navigation{}, currentUser, r.URL, mux.CurrentRoute(r)}
|
searchForm := NewSearchForm()
|
||||||
|
searchForm.HideAdvancedSearch = true
|
||||||
|
htv := UserProfileVariables{&userProfile, infosForm, searchForm, Navigation{}, currentUser, r.URL, mux.CurrentRoute(r)}
|
||||||
|
|
||||||
err := viewProfileTemplate.ExecuteTemplate(w, "index.html", htv)
|
err := viewProfileTemplate.ExecuteTemplate(w, "index.html", htv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -109,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
|
// Getting View User Profile Update
|
||||||
func UserProfileFormHandler(w http.ResponseWriter, r *http.Request) {
|
func UserProfileFormHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
|
|
23
templates/user/profile.html
Fichier normal → Fichier exécutable
23
templates/user/profile.html
Fichier normal → Fichier exécutable
|
@ -26,13 +26,13 @@
|
||||||
<!-- SIDEBAR BUTTONS -->
|
<!-- SIDEBAR BUTTONS -->
|
||||||
<div class="profile-userbuttons">
|
<div class="profile-userbuttons">
|
||||||
{{if gt $.User.ID 0 }}
|
{{if gt $.User.ID 0 }}
|
||||||
{{if not (CurrentUserIdentical $.User .ID) }}
|
{{if not (CurrentUserIdentical $.User .ID) }}
|
||||||
{{if not (IsFollower . $.User)}}
|
{{if not (IsFollower . $.User)}}
|
||||||
<a href="{{ genRoute "user_follow" "id" ( print .ID ) "username" .Username }}" class="btn btn-success btn-sm">{{ T "follow"}}</a>
|
<a href="{{ genRoute "user_follow" "id" ( print .ID ) "username" .Username }}" class="btn btn-success btn-sm">{{ T "follow"}}</a>
|
||||||
{{else}}
|
{{else}}
|
||||||
<a href="{{ genRoute "user_follow" "id" ( print .ID ) "username" .Username }}" class="btn btn-danger btn-sm">{{ T "unfollow"}}</a>
|
<a href="{{ genRoute "user_follow" "id" ( print .ID ) "username" .Username }}" class="btn btn-danger btn-sm">{{ T "unfollow"}}</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
<!-- <button type="button" class="btn btn-danger btn-sm">Message</button> -->
|
<!-- <button type="button" class="btn btn-danger btn-sm">Message</button> -->
|
||||||
</div>
|
</div>
|
||||||
|
@ -41,16 +41,13 @@
|
||||||
<div class="profile-usermenu">
|
<div class="profile-usermenu">
|
||||||
<ul class="nav">
|
<ul class="nav">
|
||||||
<li class="active">
|
<li class="active">
|
||||||
<a href="#">
|
<a href="{{ genRoute "user_profile" "id" ( print .ID ) "username" .Username }}"><i class="glyphicon glyphicon-home"></i>{{T "torrents"}}</a>
|
||||||
<i class="glyphicon glyphicon-home"></i>
|
|
||||||
{{T "torrents"}} </a>
|
|
||||||
</li>
|
</li>
|
||||||
{{if gt $.User.ID 0 }}
|
{{if gt $.User.ID 0 }}
|
||||||
{{if CurrentOrAdmin $.User .ID }}
|
{{if CurrentOrAdmin $.User .ID }}
|
||||||
<li>
|
<li>
|
||||||
<a href="?edit">
|
<a href="{{ genRoute "user_profile_details" "id" ( print .ID ) "username" .Username }}"><i class="glyphicon glyphicon-user"></i>{{T "settings"}}</a>
|
||||||
<i class="glyphicon glyphicon-user"></i>
|
|
||||||
{{T "settings"}} </a>
|
|
||||||
</li>
|
</li>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
30
templates/user/profile_edit.html
Fichier normal → Fichier exécutable
30
templates/user/profile_edit.html
Fichier normal → Fichier exécutable
|
@ -23,13 +23,13 @@
|
||||||
<!-- SIDEBAR BUTTONS -->
|
<!-- SIDEBAR BUTTONS -->
|
||||||
<div class="profile-userbuttons">
|
<div class="profile-userbuttons">
|
||||||
{{if gt $.User.ID 0 }}
|
{{if gt $.User.ID 0 }}
|
||||||
{{if not (CurrentUserIdentical $.User .ID) }}
|
{{if not (CurrentUserIdentical $.User .ID) }}
|
||||||
{{if not (IsFollower . $.User)}}
|
{{if not (IsFollower . $.User)}}
|
||||||
<a href="{{ genRoute "user_follow" "id" (print .ID)}}" class="btn btn-success btn-sm">{{ T "follow"}}</a>
|
<a href="{{ genRoute "user_follow" "id" (print .ID) "username" .Username }}" class="btn btn-success btn-sm">{{ T "follow"}}</a>
|
||||||
{{else}}
|
{{else}}
|
||||||
<a href="{{ genRoute "user_follow" "id" (print .ID)}}" class="btn btn-danger btn-sm">{{ T "unfollow"}}</a>
|
<a href="{{ genRoute "user_follow" "id" (print .ID) "username" .Username }}" class="btn btn-danger btn-sm">{{ T "unfollow"}}</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
<!-- <button type="button" class="btn btn-danger btn-sm">Message</button> -->
|
<!-- <button type="button" class="btn btn-danger btn-sm">Message</button> -->
|
||||||
</div>
|
</div>
|
||||||
|
@ -38,18 +38,14 @@
|
||||||
<div class="profile-usermenu">
|
<div class="profile-usermenu">
|
||||||
<ul class="nav">
|
<ul class="nav">
|
||||||
<li>
|
<li>
|
||||||
<a href="#">
|
<a href="{{ genRoute "user_profile" "id" (print .ID) "username" .Username }}"><i class="glyphicon glyphicon-home"></i>{{T "torrents"}}</a>
|
||||||
<i class="glyphicon glyphicon-home"></i>
|
|
||||||
{{T "torrents"}} </a>
|
|
||||||
</li>
|
</li>
|
||||||
{{if gt $.User.ID 0 }}
|
{{if gt $.User.ID 0 }}
|
||||||
{{if CurrentOrAdmin $.User .ID }}
|
{{if CurrentOrAdmin $.User .ID }}
|
||||||
<li class="active">
|
<li class="active">
|
||||||
<a href="?edit">
|
<a href="{{ genRoute "user_profile_edit" "id" (print .ID) "username" .Username }}"><i class="glyphicon glyphicon-user"></i>{{T "settings"}}</a>
|
||||||
<i class="glyphicon glyphicon-user"></i>
|
</li>
|
||||||
{{T "settings"}} </a>
|
{{end}}
|
||||||
</li>
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
{{end}}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
Référencer dans un nouveau ticket