Exemplo n.º 1
0
Arquivo: field.py Projeto: F9O/govsite
    def GET(self, id):
        field = get_field(id)
        form = FIELD_FORM_TYPE[field.type+'_form']()
        form.fill(field)
        if field.props:
            prop_dict = eval(field.props)
            if field.type == 'text':
                form.lines.set_value(prop_dict['lines'])
                form.editor.set_value(prop_dict['editor'])
            elif field.type == 'select' or field.type == 'radio' or field.type == 'checkbox':
                form.options.set_value(prop_dict['options'])
                if field.type == 'select':
                    form.is_multisel.set_value(prop_dict['is_multisel'])

        data = web.input()
        mid = data.mid
        model = get_model(mid)
        req = web.ctx.req
        req.update({
            'type': field.type,
            field.type+'_form': form,
            'mid': mid,
            'mtitle': model.title,
            })
        return render.field_edit(**req)
Exemplo n.º 2
0
 def GET(self):
     form = field_form()
     data = web.input()
     mid = data.mid
     req = web.ctx.req
     req.update({
         'form': form,
         'mid': mid,
         })
     return render.field_edit(**req)
Exemplo n.º 3
0
 def GET(self, id):
     form = field_form()
     field = get_field(id)
     form.fill(field)
     data = web.input()
     mid = data.mid
     req = web.ctx.req
     req.update({
         'form': form,
         'mid': mid,
         })
     return render.field_edit(**req)
Exemplo n.º 4
0
 def POST(self, id):
     form = field_form()
     data = web.input()
     mid = data.mid
     if not form.validates():
         req = web.ctx.req
         req.update({
             'form': form,
             'mid': mid,
             })
         return render.field_edit(**req)
     save_field(int(id), form.d)
     raise web.seeother('/model/%s/edit' % mid)
Exemplo n.º 5
0
Arquivo: field.py Projeto: F9O/govsite
    def GET(self):
        forms = {}
        for form_name, form_cls in FIELD_FORM_TYPE.items():
            forms[form_name] = form_cls()

        data = web.input()
        mid = data.mid
        model = get_model(mid)
        req = web.ctx.req
        req.update(forms)
        req.update({
            'mid': mid,
            'mtitle': model.title,
            'type': '__all__',
            })
        return render.field_edit(**req)
Exemplo n.º 6
0
Arquivo: field.py Projeto: F9O/govsite
 def POST(self, id):
     data = web.input(options=[])
     form = FIELD_FORM_TYPE[data.type+'_form']()
     mid = data.mid
     if not form.validates():
         model = get_model(mid)
         if data.type == 'select' or data.type == 'radio' or data.type == 'checkbox':
             form.options.set_value(data.options)
         req = web.ctx.req
         req.update({
             'type': data.type,
             data.type+'_form': form,
             'mid': mid,
             'mtitle': model.title,
             })
         return render.field_edit(**req)
     form_data = form.d
     form_data.type = data.type
     form_data.options = data.options
     save_field(int(id), form_data)
     raise web.seeother('/model/%s/edit' % mid)