Example #1
0
func (pc *publishController) Diff(context *admin.Context) {
	var (
		resourceID = context.Request.URL.Query().Get(":publish_unique_key")
		params     = strings.Split(resourceID, "__") // name__primary_keys
		res        = context.Admin.GetResource(params[0])
	)

	draft := res.NewStruct()
	pc.search(context.GetDB().Set(publishDraftMode, true), res, [][]string{params[1:]}).First(draft)

	production := res.NewStruct()
	pc.search(context.GetDB().Set(publishDraftMode, false), res, [][]string{params[1:]}).First(production)

	results := map[string]interface{}{"Production": production, "Draft": draft, "Resource": res}
	fmt.Fprintf(context.Writer, string(context.Render("publish_diff", results)))
}