36 lines
959 B
Go
Raw Normal View History

2017-11-18 23:34:03 +00:00
package company
import (
"net/http"
"github.com/aerogo/aero"
2019-06-03 09:32:43 +00:00
"github.com/animenotifier/notify.moe/arn"
2019-06-01 04:55:49 +00:00
"github.com/animenotifier/notify.moe/assets"
2017-11-18 23:34:03 +00:00
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/server/middleware"
2017-11-18 23:34:03 +00:00
"github.com/animenotifier/notify.moe/utils/editform"
)
2018-04-10 19:00:33 +00:00
// Edit company.
2019-06-01 04:55:49 +00:00
func Edit(ctx aero.Context) error {
2017-11-18 23:34:03 +00:00
id := ctx.Get("id")
company, err := arn.GetCompany(id)
2019-11-17 07:59:34 +00:00
user := arn.GetUserFromContext(ctx)
2017-11-18 23:34:03 +00:00
if err != nil {
return ctx.Error(http.StatusNotFound, "Company not found", err)
}
2019-06-01 04:55:49 +00:00
customCtx := ctx.(*middleware.OpenGraphContext)
customCtx.OpenGraph = &arn.OpenGraph{
2017-11-18 23:34:03 +00:00
Tags: map[string]string{
"og:title": company.Name.English,
2019-06-01 04:55:49 +00:00
"og:url": "https://" + assets.Domain + company.Link(),
2017-11-18 23:34:03 +00:00
"og:site_name": "notify.moe",
2018-04-08 15:30:32 +00:00
// "og:image": company.Image,
2017-11-18 23:34:03 +00:00
},
}
return ctx.HTML(components.CompanyTabs(company, user) + editform.Render(company, "Edit company", user))
}