Streamlined selection of rejected and unpublished articles

This commit is contained in:
Jason Streifling 2024-04-01 15:42:51 +02:00
parent 0139f7ab9a
commit 7e7de28b14
4 changed files with 38 additions and 50 deletions

View File

@ -54,8 +54,14 @@ func main() {
mux.HandleFunc("GET /edit-user/", view.EditUser(args, db, store))
mux.HandleFunc("GET /hub/", view.ShowHub(args, db, store))
mux.HandleFunc("GET /logout/", view.Logout(args, store))
mux.HandleFunc("GET /publish-issue/", view.PublishLatestIssue(args, db, store))
mux.HandleFunc("GET /rejected-articles/", view.ShowRejectedArticles(args, db, store))
mux.HandleFunc("GET /publish-issue/",
view.PublishLatestIssue(args, db, store))
mux.HandleFunc("GET /rejected-articles/",
view.ShowRejectedArticles(args, db, store))
mux.HandleFunc("GET /review-rejected-article/{id}/",
view.ReviewRejectedArticle(args, db, store))
mux.HandleFunc("GET /review-unpublished-article/{id}/",
view.ReviewUnpublishedArticle(args, db, store))
mux.HandleFunc("GET /rss/", view.ShowRSS(args,
db,
"Freimaurer Distrikt Niedersachsen und Sachsen-Anhalt",
@ -63,17 +69,19 @@ func main() {
"Freiheit, Gleichheit, Brüderlichkeit, Toleranz und Humanität",
))
mux.HandleFunc("GET /this-issue/", view.ShowCurrentArticles(args, db))
mux.HandleFunc("GET /unpublished-articles/", view.ShowUnpublishedArticles(args, db))
mux.HandleFunc("GET /unpublished-articles/",
view.ShowUnpublishedArticles(args, db))
mux.HandleFunc("GET /write-article/", view.WriteArticle(args, db))
mux.HandleFunc("POST /add-tag/", view.AddTag(args, db, store))
mux.HandleFunc("POST /add-user/", view.AddUser(args, db, store))
mux.HandleFunc("POST /login/", view.Login(args, db, store))
mux.HandleFunc("POST /publish-article/{id}/", view.PublishArticle(args, db, store))
mux.HandleFunc("POST /reject-article/{id}/", view.RejectArticle(args, db, store))
mux.HandleFunc("POST /resubmit-article/{id}/", view.ResubmitArticle(args, db, store))
mux.HandleFunc("POST /review-rejected-article/", view.ReviewRejectedArticle(args, db, store))
mux.HandleFunc("POST /review-unpublished-article/", view.ReviewUnpublishedArticle(args, db, store))
mux.HandleFunc("POST /publish-article/{id}/",
view.PublishArticle(args, db, store))
mux.HandleFunc("POST /reject-article/{id}/",
view.RejectArticle(args, db, store))
mux.HandleFunc("POST /resubmit-article/{id}/",
view.ResubmitArticle(args, db, store))
mux.HandleFunc("POST /submit-article/", view.SubmitArticle(args, db, store))
mux.HandleFunc("POST /update-user/", view.UpdateUser(args, db, store))
mux.HandleFunc("POST /upload-image/", view.UploadImage(args))

View File

@ -202,7 +202,7 @@ func ReviewUnpublishedArticle(c *control.CliArgs, db *model.DB, s *control.Cooki
}
data := new(htmlData)
id, err := strconv.ParseInt(r.PostFormValue("id"), 10, 64)
id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
if err != nil {
log.Println(err)
http.Error(w, err.Error(), http.StatusInternalServerError)
@ -238,7 +238,7 @@ func ReviewRejectedArticle(c *control.CliArgs, db *model.DB, s *control.CookieSt
}
data := new(htmlData)
id, err := strconv.ParseInt(r.PostFormValue("id"), 10, 64)
id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
if err != nil {
log.Println(err)
http.Error(w, err.Error(), http.StatusInternalServerError)

View File

@ -1,23 +1,14 @@
{{define "page-content"}}
<form>
<div class="flex flex-col gap-4">
{{range .RejectedArticles}}
<div class="border px-2 py-1 rounded-md flex gap-2">
{{if index $.MyIDs .ID}}
<input required id="{{.ID}}" name="id" type="radio" value="{{.ID}}" />
<label class="w-full" for="{{.ID}}">
<h1 class="font-bold text-2xl">{{.Title}}</h1>
<p>{{.Description}}</p>
</label>
{{end}}
</div>
{{end}}
</div>
<div class="flex flex-col gap-4">
{{range .RejectedArticles}}
{{if index $.MyIDs .ID}}
<button class="btn" hx-get="/review-rejected-article/{{.ID}}/" hx-target="#page-content">
<h1 class="font-bold text-2xl">{{.Title}}</h1>
<p>{{.Description}}</p>
</button>
{{end}}
{{end}}
<div class="btn-area">
<input class="action-btn" type="submit" value="Auswählen" hx-post="/review-rejected-article/"
hx-target="#page-content" />
<button class="btn" hx-get="/hub/" hx-target="#page-content">Zurück</button>
</div>
</form>
<button class="action-btn" hx-get="/hub/" hx-target="#page-content">Zurück</button>
</div>
{{end}}

View File

@ -1,22 +1,11 @@
{{define "page-content"}}
<form>
<div class="flex flex-col gap-4">
{{range .}}
<div class="border px-2 py-1 rounded-md flex gap-2">
<input required id="{{.ID}}" name="id" type="radio" value="{{.ID}}" />
<label class="w-full" for="{{.ID}}">
<h1 class="font-bold text-2xl">{{.Title}}</h1>
<p>{{.Description}}</p>
</label>
</div>
{{end}}
</div>
<div class="btn-area">
<input class="action-btn" type="submit" value="Auswählen" hx-post="/review-unpublished-article/"
hx-target="#page-content" />
<button class="btn" hx-get="/hub/" hx-target="#page-content">Zurück</button>
</div>
</form>
<div class="flex flex-col gap-4">
{{range .}}
<button class="btn" hx-get="/review-unpublished-article/{{.ID}}/" hx-target="#page-content">
<h1 class="font-bold text-2xl">{{.Title}}</h1>
<p>{{.Description}}</p>
</button>
{{end}}
<button class="btn" hx-get="/hub/" hx-target="#page-content">Zurück</button>
</div>
{{end}}