Beispiel #1
0
 def dashboard(rdb):
     models = []
     obj = rdb.hgetall('models')
     for itm in obj:
         model = Model.from_json(obj[itm])
         models.append(model)
     return template("admin/dashboard.tpl", models=models)
Beispiel #2
0
 def model_new(model_name, rdb):
     jsmodel = rdb.hget('models', model_name)
     model = Model.from_json(jsmodel)
     return template(
             "admin/model_new.tpl",
             model_name=model_name,
             model=model
     )
Beispiel #3
0
 def model_edit(model_name, id, rdb):
     jsmodel = rdb.lindex("%s::%s" % ("models", model_name), id - 1)
     model = Model.from_json(jsmodel)
     return template(
             "admin/model_new.tpl",
             model_name=model_name,
             model=model
     )
Beispiel #4
0
 def models_list(model_name, rdb):
     models = []
     obj = rdb.hgetall('models')
     for itm in obj:
         model = Model.from_json(obj[itm])
         models.append(model)
     jsmodel = rdb.hget('models', model_name)
     model = Model.from_json(jsmodel)
     item_list = rdb.lrange("%s::%s" % ("models", model_name), 0, 10)
     items = []
     for a in item_list:
         items.append(Model.from_json(a))
     return template(
         "admin/model_list.tpl",
         model_name=model_name,
         model=model,
         models=models,
         items=items
     )
Beispiel #5
0
 def model_save(model_name, rdb):
     jsmodel = rdb.hget('models', model_name)
     model = Model.from_json(jsmodel)
     for f in model.fields:
         f.value = request.forms.get(f.name)
     index = rdb.lpush(
         "%s::%s" % ("models", model_name),
         model.__json__()
     )
     redirect(
         self.get_url(urls.models_edit, model_name=model_name, id=index)
     )