示例#1
0
// missingUsersAndPages returns true if we have 0 users and 0 pages
func missingUsersAndPages() bool {

	pageCount, err := pages.Query().Count()
	if err != nil {
		return true
	}

	userCount, err := users.Query().Count()
	if err != nil {
		return true
	}

	if pageCount > 0 || userCount > 0 {
		return false
	}

	return true
}
示例#2
0
// HandleIndex serves a GET request at /users
func HandleIndex(context router.Context) error {

	// Authorise
	err := authorise.Path(context)
	if err != nil {
		return router.NotAuthorizedError(err)
	}

	// Fetch the users
	q := users.Query().Order("name asc")
	userList, err := users.FindAll(q)
	if err != nil {
		context.Logf("#error Error indexing users %s", err)
		return router.InternalError(err)
	}

	// Serve template
	view := view.New(context)
	view.AddKey("users", userList)
	return view.Render()

}