Finished
Cette révision appartient à :
Parent
42de73fa78
révision
5f60970eb9
5 fichiers modifiés avec 28 ajouts et 7 suppressions
router
templates
translations
|
@ -98,6 +98,7 @@ type UserProfileVariables struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserProfileNotifVariables struct {
|
type UserProfileNotifVariables struct {
|
||||||
|
Infos map[string][]string
|
||||||
Search SearchForm
|
Search SearchForm
|
||||||
Navigation Navigation
|
Navigation Navigation
|
||||||
User *model.User
|
User *model.User
|
||||||
|
|
|
@ -7,10 +7,12 @@ import (
|
||||||
|
|
||||||
"github.com/NyaaPantsu/nyaa/model"
|
"github.com/NyaaPantsu/nyaa/model"
|
||||||
"github.com/NyaaPantsu/nyaa/service/captcha"
|
"github.com/NyaaPantsu/nyaa/service/captcha"
|
||||||
|
"github.com/NyaaPantsu/nyaa/service/notifier"
|
||||||
"github.com/NyaaPantsu/nyaa/service/user"
|
"github.com/NyaaPantsu/nyaa/service/user"
|
||||||
"github.com/NyaaPantsu/nyaa/service/user/form"
|
"github.com/NyaaPantsu/nyaa/service/user/form"
|
||||||
"github.com/NyaaPantsu/nyaa/service/user/permission"
|
"github.com/NyaaPantsu/nyaa/service/user/permission"
|
||||||
"github.com/NyaaPantsu/nyaa/util/languages"
|
"github.com/NyaaPantsu/nyaa/util/languages"
|
||||||
|
msg "github.com/NyaaPantsu/nyaa/util/messages"
|
||||||
"github.com/NyaaPantsu/nyaa/util/modelHelper"
|
"github.com/NyaaPantsu/nyaa/util/modelHelper"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
@ -327,8 +329,14 @@ func UserFollowHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
func UserNotificationsHandler(w http.ResponseWriter, r *http.Request) {
|
func UserNotificationsHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
currentUser := GetUser(r)
|
currentUser := GetUser(r)
|
||||||
if currentUser.ID > 0 {
|
if currentUser.ID > 0 {
|
||||||
languages.SetTranslationFromRequest(viewProfileNotifTemplate, r)
|
messages := msg.GetMessages(r)
|
||||||
htv := UserProfileNotifVariables{NewSearchForm(), NewNavigation(), currentUser, r.URL, mux.CurrentRoute(r)}
|
T := languages.SetTranslationFromRequest(viewProfileNotifTemplate, r)
|
||||||
|
if r.URL.Query()["clear"] != nil {
|
||||||
|
notifierService.DeleteAllNotifications(currentUser.ID)
|
||||||
|
messages.AddInfo("infos", T("notifications_cleared"))
|
||||||
|
currentUser.Notifications = []model.Notification{}
|
||||||
|
}
|
||||||
|
htv := UserProfileNotifVariables{messages.GetAllInfos(), NewSearchForm(), NewNavigation(), currentUser, r.URL, mux.CurrentRoute(r)}
|
||||||
err := viewProfileNotifTemplate.ExecuteTemplate(w, "index.html", htv)
|
err := viewProfileNotifTemplate.ExecuteTemplate(w, "index.html", htv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/NyaaPantsu/nyaa/db"
|
"github.com/NyaaPantsu/nyaa/db"
|
||||||
"github.com/NyaaPantsu/nyaa/model"
|
"github.com/NyaaPantsu/nyaa/model"
|
||||||
"github.com/NyaaPantsu/nyaa/service/captcha"
|
"github.com/NyaaPantsu/nyaa/service/captcha"
|
||||||
|
"github.com/NyaaPantsu/nyaa/service/notifier"
|
||||||
"github.com/NyaaPantsu/nyaa/service/torrent"
|
"github.com/NyaaPantsu/nyaa/service/torrent"
|
||||||
"github.com/NyaaPantsu/nyaa/service/user/permission"
|
"github.com/NyaaPantsu/nyaa/service/user/permission"
|
||||||
"github.com/NyaaPantsu/nyaa/util"
|
"github.com/NyaaPantsu/nyaa/util"
|
||||||
|
@ -22,19 +23,24 @@ func ViewHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
id := vars["id"]
|
id := vars["id"]
|
||||||
messages := msg.GetMessages(r)
|
messages := msg.GetMessages(r)
|
||||||
|
user := GetUser(r)
|
||||||
|
|
||||||
if (r.URL.Query()["success"] != nil) {
|
if (r.URL.Query()["success"] != nil) {
|
||||||
messages.AddInfo("infos", "Torrent uploaded successfully!")
|
messages.AddInfo("infos", "Torrent uploaded successfully!")
|
||||||
}
|
}
|
||||||
|
|
||||||
torrent, err := torrentService.GetTorrentById(id)
|
torrent, err := torrentService.GetTorrentById(id)
|
||||||
|
|
||||||
|
if (r.URL.Query()["notif"] != nil) {
|
||||||
|
notifierService.ToggleReadNotification(torrent.Identifier(), user.ID)
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
NotFoundHandler(w, r)
|
NotFoundHandler(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
b := torrent.ToJSON()
|
b := torrent.ToJSON()
|
||||||
captchaID := ""
|
captchaID := ""
|
||||||
user := GetUser(r)
|
|
||||||
if userPermission.NeedsCaptcha(user) {
|
if userPermission.NeedsCaptcha(user) {
|
||||||
captchaID = captcha.GetID()
|
captchaID = captcha.GetID()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
{{define "profile_notifications_content"}}
|
{{define "profile_notifications_content"}}
|
||||||
{{with .User}}
|
{{with .User}}
|
||||||
<div style="padding: 0.5rem; background: grey;">
|
<div style="padding: 0.5rem; background: grey;">
|
||||||
<a href="" class="btn btn-danger pull-right"><i class="glyphicon glyphicon-trash"></i> Clear Notifications</a>
|
<a href="{{ genRoute "user_notifications" }}?clear" class="btn btn-danger pull-right"><i class="glyphicon glyphicon-trash"></i> Clear Notifications</a>
|
||||||
<div style="clear: both;"></div>
|
<div style="clear: both;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
{{ range (index $.Infos "infos")}}
|
||||||
|
<div class="alert alert-info"><a class="panel-close close" data-dismiss="alert">×</a><i class="glyphicon glyphicon-info-sign"></i> {{ . }}</div>
|
||||||
|
{{end}}
|
||||||
<table class="table table-hover table-striped">
|
<table class="table table-hover table-striped">
|
||||||
{{ range .Notifications }}
|
{{ range .Notifications }}
|
||||||
<tr><td>
|
<tr><td>
|
||||||
<div style="margin: 1rem;">
|
<div style="padding: 0 1rem 1rem;">
|
||||||
<i class="glyphicon glyphicon-bell pull-left" style="margin: -0.5rem;"></i>
|
<a href="{{ .Url }}?notif"><h3><i class="glyphicon glyphicon-bell profile-usertitle-name" ></i>{{ .Content }}</h3></a>
|
||||||
<a href="{{ .Url }}"><h3>{{ .Content }}</h3></a>
|
|
||||||
</div>
|
</div>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -759,6 +759,10 @@
|
||||||
"id": "no_database_dumps_available",
|
"id": "no_database_dumps_available",
|
||||||
"translation": "No database dumps are available at this moment."
|
"translation": "No database dumps are available at this moment."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "notifications_cleared",
|
||||||
|
"translation": "Notifications erased!"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "my_notifications",
|
"id": "my_notifications",
|
||||||
"translation": "My Notifications"
|
"translation": "My Notifications"
|
||||||
|
|
Référencer dans un nouveau ticket