Ejemplo n.º 1
0
def update_pre_questions(project_id, user_id, data):
    log("User updated pre question list", "MEDIUM", "PASS")
    val_num(user_id)
    val_num(project_id)
    clear_question_pre_rows = db.session.query(question_pre_results).filter(question_pre_results.projectID == project_id)
    clear_question_pre_rows.delete(synchronize_session=False)
    clear_checklists_results_rows = db.session.query(checklists_results).filter(checklists_results.preItem == 'True').filter(checklists_results.projectID == project_id)
    clear_checklists_results_rows.delete(synchronize_session=False)
    db.session.commit()
    project_results = project_sprints.query.filter(project_sprints.projectID == project_id).one()
    sprint_id = project_results.sprintID
    projects_result = projects.query.filter(projects.projectID == project_id).one()
    project_lvl = projects_result.level
    status = 1
    pre_item = "True"
    for result in data.get('questions'):
        val_num(result['question_pre_ID'])
        val_alpha(result['result'])
        question_pre_ID = result['question_pre_ID']
        question_result = result['result']
        questions = question_pre_results(project_id, question_pre_ID, question_result)
        db.session.add(questions)
        db.session.commit()
        questions_results = question_pre_results.query.filter(question_pre_results.projectID == project_id).filter(question_pre_results.result == "False").all()
    for results in questions_results:
        projectID = results.projectID
        questionpreID = results.question_pre_ID
        if project_lvl == 1:
            checklists = checklists_kb.query.filter(checklists_kb.checklist_items.has(level = 0) | checklists_kb.checklist_items.has(level = 1)).group_by(checklists_kb.checklistID).order_by(checklists_kb.checklistID).all()
        elif project_lvl == 2:
            checklists = checklists_kb.query.filter(checklists_kb.checklist_items.has(level = 0) | checklists_kb.checklist_items.has(level = 1) | checklists_kb.checklist_items.has(level = 2)).group_by(checklists_kb.checklistID).order_by(checklists_kb.checklistID).all()
        elif project_lvl == 3:
            checklists = checklists_kb.query.filter(checklists_kb.checklist_items.has(level = 0) | checklists_kb.checklist_items.has(level = 1) | checklists_kb.checklist_items.has(level = 2) | checklists_kb.checklist_items.has(level = 3)).group_by(checklists_kb.checklistID).order_by(checklists_kb.checklistID).all()
        for row in checklists:
            checklists_query = checklists_results(row.checklistID, projectID, sprint_id, status, pre_item, row.kbID)
            db.session.add(checklists_query)
            db.session.commit()
        if project_lvl == 1:
            checklists_first = checklists_kb.query.filter(checklists_kb.include_first == "True").filter(checklists_kb.checklist_items.has(level = 0) | checklists_kb.checklist_items.has(level = 1)).group_by(checklists_kb.checklistID).order_by(checklists_kb.checklistID).all()
        elif project_lvl == 2:
            checklists_first = checklists_kb.query.filter(checklists_kb.include_first == "True").filter(checklists_kb.checklist_items.has(level = 0) | checklists_kb.checklist_items.has(level = 1) | checklists_kb.checklist_items.has(level = 2)).group_by(checklists_kb.checklistID).order_by(checklists_kb.checklistID).all()
        elif project_lvl == 3:
            checklists_first = checklists_kb.query.filter(checklists_kb.include_first == "True").filter(checklists_kb.checklist_items.has(level = 0) | checklists_kb.checklist_items.has(level = 1) | checklists_kb.checklist_items.has(level = 2) | checklists_kb.checklist_items.has(level = 3)).group_by(checklists_kb.checklistID).order_by(checklists_kb.checklistID).all()
    for row in checklists_first:
        checklists_query_first = checklists_results(row.checklistID, projectID, sprint_id, status, pre_item, row.kbID)
        db.session.add(checklists_query_first)
        db.session.commit()
    return {'message': 'Pre questions successfully updated'}
Ejemplo n.º 2
0
def store_sprint_questions(user_id, data):
    log("User stored new sprint question list", "MEDIUM", "PASS")
    val_num(user_id)
    for result in data.get('questions'):
        val_num(result['question_sprint_ID'])
        val_alpha(result['result'])
        val_num(result['projectID'])
        val_num(result['sprintID'])
        question_sprint_ID = result['question_sprint_ID']
        question_result = result['result']
        question_project_id = result['projectID']
        sprint_id = result['sprintID']
        questions = question_sprint_results(question_project_id, sprint_id, question_sprint_ID, question_result)
        db.session.add(questions)
        db.session.commit()
        projects_result = projects.query.filter(projects.projectID == question_project_id).one()
        project_lvl = projects_result.level
        status = 1
        pre_item = "False"
        questions_results = question_sprint_results.query.filter(question_sprint_results.sprintID == sprint_id).filter(question_sprint_results.projectID == question_project_id).filter(question_sprint_results.result == "True").all()
        for results in questions_results:
            projectID = results.projectID
            questionsprintID = results.question_sprint_ID
            if project_lvl == 1:
                checklists = checklists_kb.query.filter(checklists_kb.question_pre_ID == 0).filter(checklists_kb.question_sprint_ID == questionsprintID).filter(checklists_kb.checklist_items.has(level = 0) | checklists_kb.checklist_items.has(level = 1)).group_by(checklists_kb.checklistID).group_by(checklists_kb.checklistID).order_by(checklists_kb.checklistID).all()
            elif project_lvl == 2:
                checklists = checklists_kb.query.filter(checklists_kb.question_pre_ID == 0).filter(checklists_kb.question_sprint_ID == questionsprintID).filter(checklists_kb.checklist_items.has(level = 0) | checklists_kb.checklist_items.has(level = 1) | checklists_kb.checklist_items.has(level = 2)).group_by(checklists_kb.checklistID).group_by(checklists_kb.checklistID).order_by(checklists_kb.checklistID).all()
            elif project_lvl == 3:
                checklists = checklists_kb.query.filter(checklists_kb.question_pre_ID == 0).filter(checklists_kb.question_sprint_ID == questionsprintID).filter(checklists_kb.checklist_items.has(level = 0) | checklists_kb.checklist_items.has(level = 1) | checklists_kb.checklist_items.has(level = 2) | checklists_kb.checklist_items.has(level = 3)).group_by(checklists_kb.checklistID).group_by(checklists_kb.checklistID).order_by(checklists_kb.checklistID).all()
            for row in checklists:
                checkID = row.checklistID
                checklists_query = checklists_results(checkID, projectID, sprint_id, status, pre_item, row.kbID)
                db.session.add(checklists_query)
                db.session.commit()
        if project_lvl == 1:
            checklists_always = checklists_kb.query.filter(checklists_kb.include_always == "True").filter(checklists_kb.checklist_items.has(level = 0) | checklists_kb.checklist_items.has(level = 1)).group_by(checklists_kb.checklistID).group_by(checklists_kb.checklistID).order_by(checklists_kb.checklistID).all()
        elif project_lvl == 2:
            checklists_always = checklists_kb.query.filter(checklists_kb.include_always == "True").filter(checklists_kb.checklist_items.has(level = 0) | checklists_kb.checklist_items.has(level = 1) | checklists_kb.checklist_items.has(level = 2)).group_by(checklists_kb.checklistID).group_by(checklists_kb.checklistID).order_by(checklists_kb.checklistID).all()
        elif project_lvl == 3:
            checklists_always = checklists_kb.query.filter(checklists_kb.include_always == "True").filter(checklists_kb.checklist_items.has(level = 0) | checklists_kb.checklist_items.has(level = 1) | checklists_kb.checklist_items.has(level = 2) | checklists_kb.checklist_items.has(level = 3)).group_by(checklists_kb.checklistID).group_by(checklists_kb.checklistID).order_by(checklists_kb.checklistID).all()
        for row in checklists_always:
            checklists_query_always = checklists_results(row.checklistID, question_project_id, sprint_id, status, pre_item, row.kbID)
            db.session.add(checklists_query_always)
            db.session.commit()
    return {'message': 'Sprint questions successfully created'}
Ejemplo n.º 3
0
def store_questions(checklist_type, data):
    log("User stored new sprint question list", "MEDIUM", "PASS")
    #Store the result of the questionaire if answer was true in checklists_kb
    for result in data.get('questions'):
        val_num(result['question_ID'])
        val_alpha(result['result'])
        val_num(result['projectID'])
        val_num(result['sprintID'])
        question_ID = result['question_ID']
        question_result = result['result']
        question_project_id = result['projectID']
        checklist_type = result['checklist_type']
        sprint_id = result['sprintID']
        status = 1
        if question_result == "True":
            checklists = checklists_kb.query.filter(
                checklists_kb.question_ID == question_ID).filter(
                    checklists_kb.checklist_type == checklist_type).all()
            for row in checklists:
                checklists_query = checklists_results(row.id,
                                                      question_project_id,
                                                      sprint_id, status,
                                                      row.kbID)
                db.session.add(checklists_query)
                db.session.commit()
    #Also check for the include always marked items so they are taken in account
    checklists_always = checklists_kb.query.filter(
        checklists_kb.include_always == "True").filter(
            checklists_kb.checklist_type == checklist_type).all()
    for row in checklists_always:
        checklists_query_always = checklists_results(row.id,
                                                     question_project_id,
                                                     sprint_id, status,
                                                     row.kbID)
        db.session.add(checklists_query_always)
        db.session.commit()
    return {'message': 'Sprint successfully created'}
Ejemplo n.º 4
0
def update_pre_questions(project_id, user_id, data):
    log("User updated pre question list", "MEDIUM", "PASS")
    val_num(user_id)
    val_num(project_id)
    clear_question_pre_rows = db.session.query(question_pre_results).filter(
        question_pre_results.projectID == project_id)
    clear_question_pre_rows.delete(synchronize_session=False)
    clear_checklists_results_rows = db.session.query(
        checklists_results).filter(
            checklists_results.preItem == 'True').filter(
                checklists_results.projectID == project_id)
    clear_checklists_results_rows.delete(synchronize_session=False)
    db.session.commit()
    project_results = project_sprints.query.filter(
        project_sprints.projectID == project_id).one()
    sprint_id = project_results.sprintID
    projects_result = projects.query.filter(
        projects.projectID == project_id).one()
    project_lvl = projects_result.level
    status = 1
    pre_item = "True"
    for result in data.get('questions'):
        val_num(result['question_pre_ID'])
        val_alpha(result['result'])
        question_pre_ID = result['question_pre_ID']
        question_result = result['result']
        questions = question_pre_results(project_id, question_pre_ID,
                                         question_result)
        db.session.add(questions)
        db.session.commit()
        questions_results = question_pre_results.query.filter(
            question_pre_results.projectID == project_id).filter(
                question_pre_results.result == "False").all()
    for results in questions_results:
        projectID = results.projectID
        questionpreID = results.question_pre_ID
        if project_lvl == 1:
            checklists = checklists_kb.query.filter(
                checklists_kb.checklist_items.has(level=0)
                | checklists_kb.checklist_items.has(level=1)).group_by(
                    checklists_kb.checklistID).order_by(
                        checklists_kb.checklistID).all()
        elif project_lvl == 2:
            checklists = checklists_kb.query.filter(
                checklists_kb.checklist_items.has(level=0)
                | checklists_kb.checklist_items.has(level=1)
                | checklists_kb.checklist_items.has(level=2)).group_by(
                    checklists_kb.checklistID).order_by(
                        checklists_kb.checklistID).all()
        elif project_lvl == 3:
            checklists = checklists_kb.query.filter(
                checklists_kb.checklist_items.has(level=0)
                | checklists_kb.checklist_items.has(level=1)
                | checklists_kb.checklist_items.has(level=2)
                | checklists_kb.checklist_items.has(level=3)).group_by(
                    checklists_kb.checklistID).order_by(
                        checklists_kb.checklistID).all()
        for row in checklists:
            checklists_query = checklists_results(row.checklistID, projectID,
                                                  sprint_id, status, pre_item,
                                                  row.kbID)
            db.session.add(checklists_query)
            db.session.commit()
        if project_lvl == 1:
            checklists_first = checklists_kb.query.filter(
                checklists_kb.include_first == "True").filter(
                    checklists_kb.checklist_items.has(level=0)
                    | checklists_kb.checklist_items.has(level=1)).group_by(
                        checklists_kb.checklistID).order_by(
                            checklists_kb.checklistID).all()
        elif project_lvl == 2:
            checklists_first = checklists_kb.query.filter(
                checklists_kb.include_first == "True").filter(
                    checklists_kb.checklist_items.has(level=0)
                    | checklists_kb.checklist_items.has(level=1)
                    | checklists_kb.checklist_items.has(level=2)).group_by(
                        checklists_kb.checklistID).order_by(
                            checklists_kb.checklistID).all()
        elif project_lvl == 3:
            checklists_first = checklists_kb.query.filter(
                checklists_kb.include_first == "True").filter(
                    checklists_kb.checklist_items.has(level=0)
                    | checklists_kb.checklist_items.has(level=1)
                    | checklists_kb.checklist_items.has(level=2)
                    | checklists_kb.checklist_items.has(level=3)).group_by(
                        checklists_kb.checklistID).order_by(
                            checklists_kb.checklistID).all()
    for row in checklists_first:
        checklists_query_first = checklists_results(row.checklistID, projectID,
                                                    sprint_id, status,
                                                    pre_item, row.kbID)
        db.session.add(checklists_query_first)
        db.session.commit()
    return {'message': 'Pre questions successfully updated'}