Example #1
0
func (db *publishController) Preview(context *admin.Context) {
	type resource struct {
		*admin.Resource
		Value interface{}
	}

	var drafts = []resource{}

	draftDB := context.GetDB().Set(publishDraftMode, true).Unscoped()
	for _, res := range context.Admin.GetResources() {
		if visibleInterface, ok := res.Value.(visiblePublishResourceInterface); ok {
			if !visibleInterface.VisiblePublishResource() {
				continue
			}
		} else if res.Config.Invisible {
			continue
		}

		results := res.NewSlice()
		if IsPublishableModel(res.Value) || IsPublishEvent(res.Value) {
			if draftDB.Unscoped().Where("publish_status = ?", DIRTY).Find(results).RowsAffected > 0 {
				drafts = append(drafts, resource{
					Resource: res,
					Value:    results,
				})
			}
		}
	}
	context.Execute("publish_drafts", drafts)
}
Example #2
0
func (db *publishController) Preview(context *admin.Context) {
	drafts := make(map[*admin.Resource]interface{})
	draftDB := context.GetDB().Set("publish:draft_mode", true).Unscoped()
	for _, res := range context.Admin.GetResources() {
		results := res.NewSlice()
		if isPublishableModel(res.Value) {
			if draftDB.Where("publish_status = ?", DIRTY).Find(results).RowsAffected > 0 {
				drafts[res] = results
			}
		}
	}
	context.Execute("publish/drafts", drafts)
}
Example #3
0
func (controller *i18nController) Index(context *admin.Context) {
	context.Execute("index", controller.I18n)
}