Now everyone only sees their own rejected articles
This commit is contained in:
parent
450dd79e51
commit
ceab7281e9
@ -140,16 +140,36 @@ func ShowUnpublishedArticles(db *model.DB) http.HandlerFunc {
|
|||||||
|
|
||||||
func ShowRejectedArticles(db *model.DB, s *control.CookieStore) http.HandlerFunc {
|
func ShowRejectedArticles(db *model.DB, s *control.CookieStore) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
rejectedArticles, err := db.GetCertainArticles(false, true)
|
type htmlData struct {
|
||||||
|
RejectedArticles []*model.Article
|
||||||
|
MyIDs map[int64]bool
|
||||||
|
}
|
||||||
|
data := new(htmlData)
|
||||||
|
|
||||||
|
session, err := s.Get(r, "cookie")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.RejectedArticles, err = db.GetCertainArticles(false, true)
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
data.MyIDs = make(map[int64]bool)
|
||||||
|
for _, article := range data.RejectedArticles {
|
||||||
|
if article.AuthorID == session.Values["id"].(int64) {
|
||||||
|
data.MyIDs[article.ID] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles("web/templates/rejected-articles.html")
|
tmpl, err := template.ParseFiles("web/templates/rejected-articles.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
tmpl = template.Must(tmpl, err)
|
||||||
tmpl.ExecuteTemplate(w, "page-content", rejectedArticles)
|
tmpl.ExecuteTemplate(w, "page-content", data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
{{define "page-content"}}
|
{{define "page-content"}}
|
||||||
<form>
|
<form>
|
||||||
{{range .}}
|
{{range .RejectedArticles}}
|
||||||
|
{{if index $.MyIDs .ID}}
|
||||||
<input required id="{{.ID}}" name="id" type="radio" value="{{.ID}}" />
|
<input required id="{{.ID}}" name="id" type="radio" value="{{.ID}}" />
|
||||||
<label for="{{.ID}}">{{.Title}}</label>
|
<label for="{{.ID}}">{{.Title}}</label>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{end}}
|
||||||
<input type="submit" value="Auswählen" hx-post="/review-rejected-article/" hx-target="#page-content" />
|
<input type="submit" value="Auswählen" hx-post="/review-rejected-article/" hx-target="#page-content" />
|
||||||
</form>
|
</form>
|
||||||
<button hx-get="/hub/" hx-target="#page-content">Zurück</button>
|
<button hx-get="/hub/" hx-target="#page-content">Zurück</button>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user