def getDepartment(dep): if not dep: return None d = Department.nodes.get_or_none(name=dep) if not d: d = Department(name=dep).save() return d
def get(self): departmentlist = [] for department in DepartmentModel.list(): children = [] for child in department.children: children.append({ 'id': child.id, 'parent_id': child.parent_id, 'name': child.name, 'description': child.description, }) model = { 'id': department.id, 'parent_id': department.parent_id, 'name': department.name, 'description': department.description, 'children': children } departmentlist.append(model) return jsonify({'departments': departmentlist})
def post(self): json = request.json['department'] department = DepartmentModel(name=json['name'], description=json['description'], parent_id=json['parent_id'], id=json['id']) department.save() model = { 'department': { 'id': department.id, 'name': department.name, 'description': department.description, 'parent_id': department.parent_id } } print model return jsonify(model), 201
def post(data): # TODO Add protection against insufficient permissions if DepartmentModel.find() is None: department = DepartmentModel() department.add_role("department") department.save()
def post(self): json = request.json['department'] department = DepartmentModel( name=json['name'], description=json['description'], parent_id=json['parent_id'], id=json['id'] ) department.save() model = { 'department': { 'id': department.id, 'name': department.name, 'description': department.description, 'parent_id': department.parent_id } } print model return jsonify(model), 201
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)
def get(self): departments = Department.all() comp = None for dep in departments: course = Course(cour_name = 'course1 of '+ dep.dep_name, cour_department=dep) course.put() if dep.dep_name == 'Department of Computer Science and Information Engineering': comp = dep i2c = Course(cour_name = 'Introduction to Computers', cour_department=comp) i2c.put() template_values = {'title': 'data loaded', 'message': 'courses loaded', 'method': 'get', 'action': '/', 'value': 'continue' } path = os.path.join(os.path.dirname(__file__), 'html/message.html') self.response.out.write(template.render(path, template_values))