// PublicStoreMiddleware populates all views and relations to display a store
PublicStoreMiddleware populates all views and relations to display a store
// PublicStoreMiddleware populates all views and relations to display a store
func (c *Context) PublicStoreMiddleware(w web.ResponseWriter, r *web.Request, next web.NextMiddlewareFunc) {
	store, _ := CacheFindStoreByStorename(r.PathParams["store"])
	if store == nil {
		http.NotFound(w, r.Request)
		return
	}
	warnings := FindStoreWarningsForStore(store.Uuid)
	for _, w := range warnings {
		if !w.HasExpired() && !w.IsApproved {
			store.Warnings = append(store.Warnings, w)
		}
	}
	c.ViewStoreWarnings = warnings.ViewStoreWarnings(c.ViewUser.Language)
	c.ViewItems = store.Items.ViewItems(c.ViewUser.Language)
	viewStore := store.ViewStore(c.ViewUser.Language)
	c.ViewStore = &viewStore
	c.CanEdit = store.UserIsAdministration(c.ViewUser.Uuid) || c.ViewUser.IsAdmin || c.ViewUser.IsStaff
	next(w, r)
}
func ( c * Context ) PublicStoreMiddleware ( w web . ResponseWriter , r * web . Request , next web . NextMiddlewareFunc ) { store , _ := CacheFindStoreByStorename ( r . PathParams [ " " ] ) if store == nil { http . NotFound ( w , r . Request ) return } warnings := FindStoreWarningsForStore ( store . Uuid ) for _ , w := range warnings { if ! w . HasExpired ( ) && ! w . IsApproved { store . Warnings = append ( store . Warnings , w ) } } c . ViewStoreWarnings = warnings . ViewStoreWarnings ( c . ViewUser . Language ) c . ViewItems = store . Items . ViewItems ( c . ViewUser . Language ) viewStore := store . ViewStore ( c . ViewUser . Language ) c . ViewStore = & viewStore c . CanEdit = store . UserIsAdministration ( c . ViewUser . Uuid ) || c . ViewUser . IsAdmin || c . ViewUser . IsStaff next ( w , r ) }
PublicStoreMiddleware populates all views and relations to display a store
PublicStoreMiddleware populates all views and relations to display a store
// Warnings // TODO: Add to Preload // Items // View Model // Editing rights