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)
def get_keys(): data = [{"date": k.date, "keyboard": k.keyboard, "name": k.name} for k in Key.list()] return jsonify(data=data)
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])
def add_key(self, name): from kb14.backends.key import Key key = Key(name=name, keyboard=self) key.save(force_insert=True) return key
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)