Exemplo n.º 1
0
from wheelcms_axe.models import Content
from wheelcms_spokes.models import formfactory

class Type1(Content):
    pass

class Type2(Content):
    pass


from wheelcms_axe.models import type_registry

type_registry.register("type1", Type1, formfactory(Type1))
type_registry.register("type2", Type1, formfactory(Type2))
Exemplo n.º 2
0
def formfactory(type):
    class Form(BaseForm):
        class Meta:
            model = type
            exclude = ["node", "meta_type", "created", "modified"]
    return Form


class Page(Content):
    """ A simple page object """
    body = models.TextField(blank=False)

class News(Content):
    """ A news object """
    intro = models.TextField(blank=False)
    body = models.TextField(blank=False)

##
## Idee: combineer Model, Form en type-metadata in een aparte class,
## e.g.
## class PageType(..):
##   model = Page
##   form = formfactory(..)
##   name = "spokes.page"
##   title = "A simple webpage"
##
## type_registry.register(PageType)

type_registry.register("page", Page, formfactory(Page))
type_registry.register("news", News, formfactory(News))