50 lines
1.1 KiB
Go
Raw Normal View History

2017-10-17 21:17:04 +00:00
package group
import (
"net/http"
"github.com/aerogo/aero"
2019-06-03 09:32:43 +00:00
"github.com/animenotifier/notify.moe/arn"
2017-10-17 21:17:04 +00:00
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/utils/editform"
)
// Edit ...
2019-06-01 04:55:49 +00:00
func Edit(ctx aero.Context) error {
2017-10-17 21:17:04 +00:00
id := ctx.Get("id")
group, err := arn.GetGroup(id)
user := utils.GetUser(ctx)
if err != nil {
2018-11-21 11:35:25 +00:00
return ctx.Error(http.StatusNotFound, "Group not found", err)
2017-10-17 21:17:04 +00:00
}
2018-11-21 09:12:29 +00:00
var member *arn.GroupMember
if user != nil {
member = group.FindMember(user.ID)
}
2018-11-22 07:52:29 +00:00
return ctx.HTML(components.GroupHeader(group, member, user) + editform.Render(group, "Edit group", user))
2018-11-21 11:35:25 +00:00
}
// EditImage renders the form to edit the group images.
2019-06-01 04:55:49 +00:00
func EditImage(ctx aero.Context) error {
2018-11-21 11:35:25 +00:00
id := ctx.Get("id")
group, err := arn.GetGroup(id)
user := utils.GetUser(ctx)
if err != nil {
return ctx.Error(http.StatusNotFound, "Group not found", err)
2017-10-17 21:17:04 +00:00
}
2018-11-21 11:35:25 +00:00
var member *arn.GroupMember
if user != nil {
member = group.FindMember(user.ID)
}
return ctx.HTML(components.EditGroupImage(group, member, user))
2017-10-17 21:17:04 +00:00
}