Example #1
0
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
Example #2
0
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}
Example #3
0
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