Exemplo n.º 1
0
def get_key(name):
    data = [{"date": k.date, "keyboard": k.keyboard} for k in Key.list(name=name)] or missing("key")
    return jsonify(data=data)
Exemplo n.º 2
0
def get_keys():
    data = [{"date": k.date, "keyboard": k.keyboard, "name": k.name} for k in Key.list()]
    return jsonify(data=data)
Exemplo n.º 3
0
 def get_keys(self, **kwargs):
     from kb14.backends.key import Key
     limit = kwargs.pop("limit", 100)
     kwargs.update({"keyboard": self.color})
     return list(Key.objects(**kwargs).order_by("-_id")[:limit])
Exemplo n.º 4
0
 def add_key(self, name):
     from kb14.backends.key import Key
     key = Key(name=name, keyboard=self)
     key.save(force_insert=True)
     return key
Exemplo n.º 5
0
def post_keyboard_key(color):
    json = request.get_json() or specify("key name")
    name = json.get("name") or specify("key name")
    add_key.spawn(name=name, keyboard=color)
    Key.update_metrics(name=name, keyboard=color)
    return jsonify(name=name, keyboard=color)