def load_reqs(id): if id: project = Project.objects(pk=id).first() if project: classifiedReqs = classifyReqs(request.json['reqs']) for req in classifiedReqs: Requirement(text=req['text'], req_type=req['type'], parent=id).save() requirements = Requirement.objects(parent=id) return jsonify({"reqs": getResponseReqs(requirements)}), 200 return jsonify({"text": "Project id needed."}), 500
def get_project(id): if id: project = Project.objects(pk=id).first() requirements = Requirement.objects(parent=id) ers = ER.objects(parent=id) return jsonify( {"project": getResponseProject(project, requirements, ers)}), 200 return jsonify({"text": "Project id needed."}), 500
def projects(): projects = Project.objects(parent=current_user.id).only('name') response_projects = list( map( lambda x: { "name": x.name, "id": str(x.pk), "reqsNum": Requirement.objects(parent=x.id).count() }, projects)) return {"projects": response_projects}
def update_req(project_id): if id: project = Project.objects(pk=project_id).first() if project: success = Requirement(pk=request.json['req']['id']).update( text=request.json['req']['text'], req_type=request.json['req']['type'], parent=project_id) if success: return jsonify({"text": "Req was updated"}), 200 else: return jsonify({"text": "Req was not updated"}), 500 return jsonify({"text": "Project id needed."}), 500
def check_user(self, user): for req in self.requirements: requirement_type = Requirement.get_type(req) if requirement_type == 'year': year_name = Year.convert_to_name(user.year) if year_name != req: return False elif requirement_type == 'major': if user.major != req: return False elif requirement_type == 'department': department = Major.get_department(user.major) if department != req: return False return True
def delete_req(project_id, req_id): if req_id: Requirement(pk=req_id).delete() return jsonify({"text": "Requirement deleted."}), 200 return jsonify({"text": "Requirement id needed."}), 500
("validationLevel", "strict")]) db.command(query) u1 = User(email="*****@*****.**", password_hash=generate_password_hash("12345678"), isAgreeToCollectData=True).save() p1 = Project(name="test_project1", parent=u1.id).save() reqs = [{ "text": "Система должна обновлять дисплей каждые 60 секунд.", "rtype": "PE" }, { "text": "Приложение должно соответствовать цвету схемы, установленной Министерством внутренней безопасности.", "rtype": "LF" }, { "text": "Продукт должен быть доступен в обычное рабочее время.", "rtype": "A" }, { "text": "Система должна отображать все события в упражнении.", "rtype": "F" }, { "text": "Продукт должен иметь согласованную цветовую гамму и шрифты.", "rtype": "LF" }] for req in reqs: r = Requirement(text=req["text"], req_type=req["rtype"], parent=p1.id).save()