예제 #1
0
파일: resource.py 프로젝트: ish/adminish
def _form_for_type(request, C, defn, add_id_and_rev=False):
    """
    Create a form for the given model type.
    """
    form = build(defn, C, add_id_and_rev=add_id_and_rev,
                 widget_registry=_widget_registry(request))
    form.renderer =  request.environ['restish.templating'].renderer
    return form
예제 #2
0
def _form_for_type(request, C, defn, add_id_and_rev=False):
    """
    Create a form for the given model type.
    """
    form = build(defn,
                 C,
                 add_id_and_rev=add_id_and_rev,
                 widget_registry=_widget_registry(request))
    form.renderer = request.environ['restish.templating'].renderer
    return form
    def test_simple(self):
        book_definition = yaml.load( open(DATADIR%'test_couchish_book.yaml').read() )
        dvd_definition = yaml.load( open(DATADIR%'test_couchish_dvd.yaml').read() )
        post_definition = yaml.load( open(DATADIR%'test_couchish_post.yaml').read() )
        author_definition = yaml.load( open(DATADIR%'test_couchish_author.yaml').read() )
        views_definition = yaml.load( open(DATADIR%'test_couchish_views.yaml').read() )

        f = build(author_definition)
        self.assertIdHasValue(f, 'first_name', '')
        # Test None data
        f = build(author_definition)
        testdata = {'first_name': None, 'last_name': None}
        f.defaults = testdata
        self.assertIdHasValue(f, 'first_name', '')
        self.assertRoundTrip(f, testdata)
        # Test sample data
        f = build(author_definition)
        testdata = {'first_name': None, 'last_name': 'Goodall'}
        f.defaults = testdata
        self.assertIdHasValue(f, 'last_name', 'Goodall')
        self.assertRoundTrip(f, testdata)
예제 #4
0
파일: resource.py 프로젝트: ish/adminish
def category_form(C, facet, model_type, request):
    # Take copies of the facet and category definitios so we can modify them
    # without affecting the core config.
    facet_definition = list(C.config.types['facet_%s'%facet]['fields'])
    category_definition = [dict(i) for i in C.config.types[model_type]['fields']]
    for cat in category_definition:
        cat['name'] = 'category.*.new_category.%s'%cat['name']
    category_group = {'name': 'category.*.new_category', 'type': 'Structure'}
    checkbox = {'name': 'category.*.new_category.is_new','type': 'Boolean', 'widget': {'type': 'Checkbox'}}
    facet_definition.append( category_group )
    facet_definition.append( checkbox )
    defn = {'fields': facet_definition + category_definition }
    b = build(defn, C, widget_registry=_widget_registry(request))
    b.renderer =  request.environ['restish.templating'].renderer
    return b
예제 #5
0
def category_form(C, facet, model_type, request):
    # Take copies of the facet and category definitios so we can modify them
    # without affecting the core config.
    facet_definition = list(C.config.types['facet_%s' % facet]['fields'])
    category_definition = [
        dict(i) for i in C.config.types[model_type]['fields']
    ]
    for cat in category_definition:
        cat['name'] = 'category.*.new_category.%s' % cat['name']
    category_group = {'name': 'category.*.new_category', 'type': 'Structure'}
    checkbox = {
        'name': 'category.*.new_category.is_new',
        'type': 'Boolean',
        'widget': {
            'type': 'Checkbox'
        }
    }
    facet_definition.append(category_group)
    facet_definition.append(checkbox)
    defn = {'fields': facet_definition + category_definition}
    b = build(defn, C, widget_registry=_widget_registry(request))
    b.renderer = request.environ['restish.templating'].renderer
    return b
 def test_fileupload(self):
     upload_definition = yaml.load( open(DATADIR%'test_upload.yaml').read() )
     f = build(upload_definition)