예제 #1
0
 def GET(self):
     form = model_form()
     models = get_active_models()
     templates = get_templates()
     req = web.ctx.req
     req.update({
         'form': form,
         'templates': templates,
         'models': models,
         'fields': [],
         'relations': [],
         })
     return admin_render.model_edit(**req)
예제 #2
0
 def GET(self):
     form = model_form()
     models = get_active_models()
     templates = get_templates()
     req = web.ctx.req
     req.update({
         'form': form,
         'templates': templates,
         'models': models,
         'fields': [],
         'relations': [],
     })
     return admin_render.model_edit(**req)
예제 #3
0
 def POST(self):
     form = model_form()
     valid = form.validates()
     is_unique_name = get_model_by_name(form.name.get_value()) is None
     if not valid or not is_unique_name:
         if not is_unique_name:
             form.name.note = u"%s已存在,请重新指定。" % (form.name.get_value())
         templates = get_templates()
         models = get_active_models()
         req = web.ctx.req
         req.update({
             'form': form,
             'templates': templates,
             'models': models,
             'fields': [],
             'relations': [],
             })
         return admin_render.model_edit(**req)
     save_model(-1, form.d)
     raise web.seeother('/model/index')
예제 #4
0
 def POST(self):
     form = model_form()
     valid = form.validates()
     is_unique_name = get_model_by_name(form.name.get_value()) is None
     if not valid or not is_unique_name:
         if not is_unique_name:
             form.name.note = u"%s已存在,请重新指定。" % (form.name.get_value())
         templates = get_templates()
         models = get_active_models()
         req = web.ctx.req
         req.update({
             'form': form,
             'templates': templates,
             'models': models,
             'fields': [],
             'relations': [],
         })
         return admin_render.model_edit(**req)
     save_model(-1, form.d)
     raise web.seeother('/model/index')
예제 #5
0
 def GET(self, id):
     model = get_model(id)
     if model.is_active:
         raise web.seeother('/model/%s/view' % id)
     templates = get_templates()
     models = get_active_models()
     form = model_form()
     fields = get_fields(id)
     relations = get_relations(id)
     form.fill(model)
     req = web.ctx.req
     req.update({
         'mid': id,
         'form': form,
         'templates': templates,
         'models': models,
         'fields': fields,
         'relations': relations,
         '_typetext': typetext,
         })
     return admin_render.model_edit(**req)
예제 #6
0
 def GET(self, id):
     model = get_model(id)
     if model.is_active:
         raise web.seeother('/model/%s/view' % id)
     templates = get_templates()
     models = get_active_models()
     form = model_form()
     fields = get_fields(id)
     relations = get_relations(id)
     form.fill(model)
     req = web.ctx.req
     req.update({
         'mid': id,
         'form': form,
         'templates': templates,
         'models': models,
         'fields': fields,
         'relations': relations,
         '_typetext': typetext,
     })
     return admin_render.model_edit(**req)
예제 #7
0
 def POST(self, id):
     form = model_form()
     valid = form.validates()
     is_unique_name = not get_other_models(int(id), form.name.get_value())
     if not valid or not is_unique_name:
         if not is_unique_name:
             form.name.note = u"%s已存在,请重新指定。" % (form.name.get_value())
         templates = get_templates()
         models = get_active_models()
         fields = get_fields(id)
         relations = get_relations(id)
         req = web.ctx.req
         req.update({
             'mid': id,
             'form': form,
             'templates': templates,
             'models': models,
             'fields': fields,
             'relations': relations,
             })
         return admin_render.model_edit(**req)
     save_model(int(id), form.d)
     raise web.seeother('/model/index')
예제 #8
0
 def POST(self, id):
     form = model_form()
     valid = form.validates()
     is_unique_name = not get_other_models(int(id), form.name.get_value())
     if not valid or not is_unique_name:
         if not is_unique_name:
             form.name.note = u"%s已存在,请重新指定。" % (form.name.get_value())
         templates = get_templates()
         models = get_active_models()
         fields = get_fields(id)
         relations = get_relations(id)
         req = web.ctx.req
         req.update({
             'mid': id,
             'form': form,
             'templates': templates,
             'models': models,
             'fields': fields,
             'relations': relations,
         })
         return admin_render.model_edit(**req)
     save_model(int(id), form.d)
     raise web.seeother('/model/index')