示例#1
0
文件: entity.py 项目: leoomo/pycms
    def POST(self, mname):
        base_form = base_entity_form()
        form = entity_form(mname)
        model = get_model_by_name(mname)
        bv = base_form.validates()
        v = form.validates()
        if not bv or not v:
            categories = category_tree()
            data = web.input(cids=[])
            base_form.cids.set_value(data.cids)
            req = web.ctx.req
            req.update({
                'base_form': base_form,
                'form': form,
                'mname': mname,
                'mtitle': model.title,
                'categories': categories,
            })
            return render.entity_edit(**req)

        data = web.input(cids=[])
        base_form_data = base_form.d
        base_form_data.cids = data.cids
        base_form_data.user_id = web.ctx.session._userid
        form_data = form.d
        new_entity(model, base_form_data, form_data)
        raise web.seeother('/entity/index')
示例#2
0
文件: entity.py 项目: leoomo/pycms
 def POST(self, id):
     base_entity = get_base_entity(id)
     model = base_entity.model
     base_form = base_entity_form()
     form = entity_form(model.name)
     data = web.input()
     bv = base_form.validates()
     v = form.validates()
     if not bv or not v:
         categories = category_tree()
         data = web.input(cids=[])
         base_form.cids.set_value(data.cids)
         req = web.ctx.req
         req.update({
             'base_form': base_form,
             'form': form,
             'mname': model.name,
             'mtitle': model.title,
             'categories': categories,
         })
         return render.entity_edit(**req)
     data = web.input(cids=[])
     base_form_data = base_form.d
     base_form_data.cids = data.cids
     base_form_data.updated_time = datetime.now()
     form_data = form.d
     save_entity(model, int(id), base_form_data, form_data)
     raise web.seeother('/entity/index')
示例#3
0
文件: entity.py 项目: F9O/govsite
    def GET(self, id):
        base_entity = get_base_entity(id)
        cids = [cate.id for cate in base_entity.categories]
        model = base_entity.model
        base_form = base_entity_form()
        base_form.cids.set_value(cids)
        form = entity_form(model.name)
        entity = getattr(base_entity, model.name)
        base_form.fill(base_entity)
        base_form.cids.value = cids
        form.fill(entity)
        # populate multi value field
        pd = []
        for item in form.inputs:
            if isinstance(item, MyCheckboxGroup):
                pd.append(item.name)
        for k in pd:
            getattr(form, k).set_value(eval(getattr(entity, k)))

        categories = category_tree()
        data = web.input()
        req = web.ctx.req
        req.update({
            'base_form': base_form,
            'form': form,
            'mname': model.name,
            'mtitle': model.title,
            'categories': categories,
        })
        return render.entity_edit(**req)
示例#4
0
文件: entity.py 项目: leoomo/pycms
 def GET(self, mname):
     model = get_model_by_name(mname)
     base_form = base_entity_form()
     form = entity_form(mname)
     categories = category_tree()
     req = web.ctx.req
     req.update({
         'base_form': base_form,
         'form': form,
         'mname': mname,
         'mtitle': model.title,
         'model': model,
         'categories': categories,
         })
     return render.entity_edit(**req)
示例#5
0
文件: entity.py 项目: F9O/govsite
    def POST(self, mname):
        data = web.input(cids=[])
        base_form = base_entity_form()
        form = entity_form(mname)
        model = get_model_by_name(mname)
        bv = base_form.validates()
        v = form.validates()
        if not bv or not v:
            categories = category_tree()
            base_form.cids.set_value(data.cids)

            # populate multi value field
            pd = {}
            for item in form.inputs:
                if isinstance(item, MyCheckboxGroup):
                    pd[item.name] = []
            pdata = web.input(**pd)
            for k in pd.keys():
                getattr(form, k).set_value(getattr(pdata, k))

            req = web.ctx.req
            req.update({
                'base_form': base_form,
                'form': form,
                'mname': mname,
                'mtitle': model.title,
                'categories': categories,
            })
            return render.entity_edit(**req)

        base_form_data = base_form.d
        base_form_data.cids = data.cids
        base_form_data.user_id = web.ctx.session._userid
        form_data = form.d
        # populate multi value field
        pd = {}
        for item in form.inputs:
            if isinstance(item, MyCheckboxGroup):
                pd[item.name] = []
        pdata = web.input(**pd)
        for k in pd.keys():
            setattr(form_data, k, str(getattr(pdata, k)))

        new_entity(model, base_form_data, form_data)
        raise web.seeother('/entity/index')
示例#6
0
文件: entity.py 项目: leoomo/pycms
 def GET(self, id):
     base_entity = get_base_entity(id)
     cids = [cate.id for cate in base_entity.categories]
     model = base_entity.model
     base_form = base_entity_form()
     base_form.cids.set_value(cids)
     form = entity_form(model.name)
     entity = getattr(base_entity, model.name)
     base_form.fill(base_entity)
     base_form.cids.value = cids
     form.fill(entity)
     categories = category_tree()
     data = web.input()
     req = web.ctx.req
     req.update({
         'base_form': base_form,
         'form': form,
         'mname': model.name,
         'mtitle': model.title,
         'categories': categories,
     })
     return render.entity_edit(**req)