Esempio n. 1
0
    def post(data):
        # TODO Add protection against insufficient permissions
        if DepartmentModel.find() is None:
            department = DepartmentModel()

            department.add_role("department")
            department.save()
Esempio n. 2
0
    def get(self, id):
        department = DepartmentModel.find(id=id)
        children = []

        for child in department.children:
            children.append(child.id)

        model = {
            "department": {
                "id": department.id,
                "parent_id": department.parent_id,
                "name": department.name,
                "description": department.description,
                "children": children,
            }
        }
        return jsonify(model)