def edit_sprint(project_id, sprint_id):
    response = requests.get(app.config['SCRUM_API'] + '/get/project/{0}'.format(project_id, sprint_id))
    project_data = response.json()

    response = requests.get(app.config['SCRUM_API'] + '/get/project/{0}/{1}'.format(project_id, sprint_id))
    sprint_data = response.json()

    sprint_data_update = sprint_data


    form = SprintForm(request.form)
    form.sprint_days.data = str(sprint_data['sprint_days'])
    form.delivered_points.data = sprint_data['delivered_points']

    if request.method == 'GET':
        form.sprint_number.data = sprint_data['sprint_number']
        form.end_date.data = datetime.strptime(sprint_data['end_date'], '%Y-%m-%d')
        form.start_date.data = datetime.strptime(sprint_data['start_date'], '%Y-%m-%d')
        form.sprint_rag.data = sprint_data['sprint_rag']
        form.burndown_type.data = str(sprint_data['burndown_type'])

        return render_template('edit_sprint.html', project_data=project_data, sprint_data=sprint_data, form=form)
    else:
        if form.validate_on_submit():

            sprint_num_found = False;
            for d in project_data['sprint_array']:
                if d['sprint_number'] == form.sprint_number.data:
                    if str(d['id']) != sprint_id:
                        sprint_num_found = True

            if sprint_num_found == False:

                sprint_data_update['sprint_number'] = form.sprint_number.data
                sprint_data_update['end_date'] = str(form.end_date.data)
                sprint_data_update['start_date'] = str(form.start_date.data)
                sprint_data_update['sprint_rag'] = form.sprint_rag.data
                sprint_data_update['burndown_type'] = str(form.burndown_type.data)

                payload = sprint_data_update
                requests.post(app.config['SCRUM_API'] + '/update/sprint/{0}'.format(sprint_id), data=json.dumps(payload))
                sprint_data = response.json()

                flash('Sprint Updated')
                return redirect(url_for('sprint', project_id=project_id, sprint_id=sprint_id))
            else:
                flash('That Sprint Number is already used elsewhere')
        else:
            flash('There was an error, please review')
    return render_template('edit_sprint.html', project_data=project_data, sprint_data=sprint_data, form=form)
Ejemplo n.º 2
0
def edit_sprint(project_id, sprint_id):
    response = requests.get(app.config['SCRUM_API'] +
                            '/get/project/{0}'.format(project_id, sprint_id))
    project_data = response.json()

    response = requests.get(
        app.config['SCRUM_API'] +
        '/get/project/{0}/{1}'.format(project_id, sprint_id))
    sprint_data = response.json()

    sprint_data_update = sprint_data

    form = SprintForm(request.form)
    form.sprint_days.data = str(sprint_data['sprint_days'])
    form.delivered_points.data = sprint_data['delivered_points']

    if request.method == 'GET':
        form.sprint_number.data = sprint_data['sprint_number']
        form.end_date.data = datetime.strptime(sprint_data['end_date'],
                                               '%Y-%m-%d')
        form.start_date.data = datetime.strptime(sprint_data['start_date'],
                                                 '%Y-%m-%d')
        form.sprint_rag.data = sprint_data['sprint_rag']
        form.burndown_type.data = str(sprint_data['burndown_type'])

        return render_template('edit_sprint.html',
                               project_data=project_data,
                               sprint_data=sprint_data,
                               form=form)
    else:
        if form.validate_on_submit():

            sprint_num_found = False
            for d in project_data['sprint_array']:
                if d['sprint_number'] == form.sprint_number.data:
                    if str(d['id']) != sprint_id:
                        sprint_num_found = True

            if sprint_num_found == False:

                sprint_data_update['sprint_number'] = form.sprint_number.data
                sprint_data_update['end_date'] = str(form.end_date.data)
                sprint_data_update['start_date'] = str(form.start_date.data)
                sprint_data_update['sprint_rag'] = form.sprint_rag.data
                sprint_data_update['burndown_type'] = str(
                    form.burndown_type.data)

                payload = sprint_data_update
                requests.post(app.config['SCRUM_API'] +
                              '/update/sprint/{0}'.format(sprint_id),
                              data=json.dumps(payload))
                sprint_data = response.json()

                flash('Sprint Updated')
                return redirect(
                    url_for('sprint',
                            project_id=project_id,
                            sprint_id=sprint_id))
            else:
                flash('That Sprint Number is already used elsewhere')
        else:
            flash('There was an error, please review')
    return render_template('edit_sprint.html',
                           project_data=project_data,
                           sprint_data=sprint_data,
                           form=form)
Ejemplo n.º 3
0
def add_sprint(project_id):
    response = requests.get(app.config['SCRUM_API'] +
                            '/get/project/{0}'.format(project_id))
    project_data = response.json()
    form = SprintForm(request.form)

    if project_data['latest_sprint_id'] != '':
        response = requests.get(
            app.config['SCRUM_API'] + '/get/project/{0}/{1}'.format(
                project_id, project_data['latest_sprint_id']))
        previous_sprint_data = response.json()

    if request.method == 'GET':

        if project_data['latest_sprint_id'] != '':
            form.sprint_number.data = int(
                previous_sprint_data['sprint_number']) + 1
            form.sprint_days.data = str(previous_sprint_data['sprint_days'])
            form.end_date.data = datetime.strptime(
                previous_sprint_data['end_date'], '%Y-%m-%d') + timedelta(
                    days=(previous_sprint_data['sprint_days'] +
                          ((previous_sprint_data['sprint_days'] / 5) * 2)))
            form.start_date.data = datetime.strptime(
                previous_sprint_data['start_date'], '%Y-%m-%d') + timedelta(
                    days=(previous_sprint_data['sprint_days'] +
                          ((previous_sprint_data['sprint_days'] / 5) * 2)))
            form.sprint_rag.data = previous_sprint_data['sprint_rag']
            form.sprint_risks.data = previous_sprint_data['sprint_risks']
            form.sprint_issues.data = previous_sprint_data['sprint_issues']
            form.sprint_dependencies.data = previous_sprint_data[
                'sprint_dependencies']
            form.burndown_type.data = str(
                previous_sprint_data['burndown_type'])
            form.burndown_total.data = previous_sprint_data['burndown_total']
            form.burndown_type.data = str(
                previous_sprint_data['burndown_type'])

        return render_template('add_sprint.html',
                               form=form,
                               project_data=project_data)
    else:
        sprint_number = form.sprint_number.data
        sprint_goal = form.sprint_goal.data
        sprint_days = form.sprint_days.data
        agreed_points = form.agreed_points.data
        start_date = str(form.start_date.data)
        end_date = str(form.end_date.data)
        sprint_rag = form.sprint_rag.data
        sprint_risks = form.sprint_risks.data
        sprint_issues = form.sprint_issues.data
        sprint_dependencies = form.sprint_dependencies.data
        burndown_type = str(form.burndown_type.data)
        burndown_total = form.burndown_total.data

        if form.validate_on_submit():
            if not any(d['sprint_number'] == str(sprint_number)
                       for d in project_data['sprint_array']):
                payload = {
                    "project_id": project_id,
                    "start_date": start_date,
                    "end_date": end_date,
                    "sprint_number": sprint_number,
                    "sprint_rag": sprint_rag,
                    "sprint_goal": sprint_goal,
                    "sprint_deliverables": "",
                    "sprint_challenges": "",
                    "agreed_points": agreed_points,
                    "delivered_points": "0",
                    "started_points": "0",
                    "sprint_issues": sprint_issues,
                    "sprint_risks": sprint_risks,
                    "sprint_dependencies": sprint_dependencies,
                    "sprint_days": sprint_days,
                    "sprint_teamdays": 0,
                    "burndown_type": burndown_type,
                    "burndown_total": burndown_total
                }
                response = requests.post(app.config['SCRUM_API'] +
                                         '/add/sprint',
                                         data=json.dumps(payload))
                sprint_data = response.json()

                print(sprint_data)

                sprint_days_array = []
                for i in range(1, (int(sprint_days) + 1)):
                    sprint_days_array.append({
                        "sprint_day": str(i),
                        "sprint_done": "0"
                    })

                    payload = {
                        "sprint_id": str(sprint_data['id']),
                        "sprint_days": sprint_days_array
                    }
                    requests.post(app.config['SCRUM_API'] +
                                  '/update/burn_down',
                                  data=json.dumps(payload))

                if project_data['last_sprint_id'] != '':
                    for person in previous_sprint_data['sprintpeople_array']:
                        print(sprint_data['id'])
                        print(person['person_name'])

                        payload = {
                            "sprint_id": str(sprint_data['id']),
                            "person_name": person['person_name']
                        }
                        response = requests.post(app.config['SCRUM_API'] +
                                                 '/add/sprintperson',
                                                 data=json.dumps(payload))
                        sprintperson_data = response.json()

                        sprintperson_days_array = []
                        for i in range(1, (int(sprint_days) + 1)):
                            sprintperson_days_array.append({
                                "sprint_day":
                                str(i),
                                "sprint_daystatus":
                                "0"
                            })

                        payload = {
                            "sprintpeople_id": str(sprintperson_data['id']),
                            "sprint_days": sprintperson_days_array
                        }
                        requests.post(app.config['SCRUM_API'] +
                                      '/update/sprintpeoplerecord',
                                      data=json.dumps(payload))

                flash('Add Sprint {0} for {1}'.format(sprint_number,
                                                      project_data['name']))
                return redirect(url_for('project', project_id=project_id))
            else:
                flash('Sprint {0} already exists in {1}'.format(
                    sprint_number, project_data['name']))

        return render_template('add_sprint.html',
                               form=form,
                               project_data=project_data)
def add_sprint(project_id):
    response = requests.get(app.config['SCRUM_API'] + '/get/project/{0}'.format(project_id))
    project_data = response.json()
    form = SprintForm(request.form)

    if project_data['latest_sprint_id'] != '':
        response = requests.get(app.config['SCRUM_API'] + '/get/project/{0}/{1}'.format(project_id, project_data['latest_sprint_id']))
        previous_sprint_data = response.json()

    if request.method == 'GET':

        if project_data['latest_sprint_id'] != '':
            form.sprint_number.data = int(previous_sprint_data['sprint_number']) + 1
            form.sprint_days.data = str(previous_sprint_data['sprint_days'])
            form.end_date.data = datetime.strptime(previous_sprint_data['end_date'], '%Y-%m-%d') + timedelta(days=(previous_sprint_data['sprint_days'] + ((previous_sprint_data['sprint_days'] /5) * 2)))
            form.start_date.data = datetime.strptime(previous_sprint_data['start_date'], '%Y-%m-%d') + timedelta(days=(previous_sprint_data['sprint_days'] + ((previous_sprint_data['sprint_days'] /5) * 2)))
            form.sprint_rag.data = previous_sprint_data['sprint_rag']
            form.sprint_risks.data = previous_sprint_data['sprint_risks']
            form.sprint_issues.data = previous_sprint_data['sprint_issues']
            form.sprint_dependencies.data = previous_sprint_data['sprint_dependencies']
            form.burndown_type.data = str(previous_sprint_data['burndown_type'])
            form.burndown_total.data = previous_sprint_data['burndown_total']
            form.burndown_type.data = str(previous_sprint_data['burndown_type'])

        return render_template('add_sprint.html', form=form, project_data=project_data)
    else:
        sprint_number = form.sprint_number.data
        sprint_goal = form.sprint_goal.data
        sprint_days = form.sprint_days.data
        agreed_points = form.agreed_points.data
        start_date = str(form.start_date.data)
        end_date = str(form.end_date.data)
        sprint_rag = form.sprint_rag.data
        sprint_risks = form.sprint_risks.data
        sprint_issues = form.sprint_issues.data
        sprint_dependencies = form.sprint_dependencies.data
        burndown_type = str(form.burndown_type.data)
        burndown_total = form.burndown_total.data

        if form.validate_on_submit():
            if not any(d['sprint_number'] == str(sprint_number) for d in project_data['sprint_array']):
                payload = {"project_id": project_id, "start_date": start_date, "end_date": end_date, "sprint_number": sprint_number, "sprint_rag": sprint_rag, "sprint_goal": sprint_goal, "sprint_deliverables": "", "sprint_challenges": "", "agreed_points": agreed_points, "delivered_points": "0", "started_points": "0", "sprint_issues": sprint_issues, "sprint_risks": sprint_risks, "sprint_dependencies": sprint_dependencies, "sprint_days": sprint_days, "sprint_teamdays": 0, "burndown_type": burndown_type, "burndown_total": burndown_total   }
                response = requests.post(app.config['SCRUM_API'] + '/add/sprint', data=json.dumps(payload))
                sprint_data = response.json()

                print(sprint_data)

                sprint_days_array = []
                for i in range(1, (int(sprint_days) + 1)):
                    sprint_days_array.append({"sprint_day": str(i), "sprint_done": "0"})

                    payload = {"sprint_id": str(sprint_data['id']), "sprint_days": sprint_days_array}
                    requests.post(app.config['SCRUM_API'] + '/update/burn_down', data=json.dumps(payload))

                if project_data['last_sprint_id'] != '':
                    for person in previous_sprint_data['sprintpeople_array']:
                        print(sprint_data['id'])
                        print(person['person_name'] )

                        payload = {"sprint_id":str(sprint_data['id']), "person_name": person['person_name'] }
                        response = requests.post(app.config['SCRUM_API'] + '/add/sprintperson', data=json.dumps(payload))
                        sprintperson_data = response.json()

                        sprintperson_days_array = []
                        for i in range(1, (int(sprint_days) + 1)):
                            sprintperson_days_array.append({"sprint_day": str(i), "sprint_daystatus": "0"})

                        payload = {"sprintpeople_id": str(sprintperson_data['id']), "sprint_days": sprintperson_days_array}
                        requests.post(app.config['SCRUM_API'] + '/update/sprintpeoplerecord', data=json.dumps(payload))


                flash('Add Sprint {0} for {1}'.format(sprint_number, project_data['name']))
                return redirect(url_for('project', project_id=project_id))
            else:
                flash('Sprint {0} already exists in {1}'.format(sprint_number, project_data['name']))


        return render_template('add_sprint.html', form=form, project_data=project_data)