Added advanced thread and post editing for admins

This commit is contained in:
2018-06-03 08:52:38 +09:00
parent 0fd8692100
commit b5f4585edd
6 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,29 @@
package editthread
import (
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/utils/editform"
)
// Get thread edit page.
func Get(ctx *aero.Context) string {
id := ctx.Get("id")
user := utils.GetUser(ctx)
if user == nil || (user.Role != "editor" && user.Role != "admin") {
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this thread", nil)
}
thread, err := arn.GetThread(id)
if err != nil {
return ctx.Error(http.StatusNotFound, "Thread not found", err)
}
return ctx.HTML(components.EditThreadTabs(thread) + editform.Render(thread, "Edit thread", user))
}

View File

@ -0,0 +1,7 @@
component EditThreadTabs(thread *arn.Thread)
.tabs
a.tab(href=thread.Link())
Icon("comments")
span Thread
Tab("Edit", "pencil", thread.Link() + "/edit")