예제 #1
0
    def test_parse_workline(self):
        # Mock out person lookup
        people_db.select_person_by_name = MagicMock(return_value=Person(21))
        connection = None

        workline = '[1, "Borvo Borvison", "0.20 d", "Make title longer", [], "?"]'
        work_data = parse_workline(connection, workline)
        fields = work_data['fields']
        self.assertEqual(work_data['id'], 1)
        self.assertEqual(fields['assignee_id'], 21)
        self.assertEqual(fields['effort_left_d'], 0.2)
        self.assertEqual(fields['title'], 'Make title longer')
        self.assertEqual(fields['prereqs'], '[]')
        self.assertEqual(fields['key_date'], None)
예제 #2
0
    def test_parse_workline(self):
        # Mock out person lookup
        people_db.select_person_by_name = MagicMock(return_value = Person(21))
        connection = None

        workline = '[1, "Borvo Borvison", "0.20 d", "Make title longer", [], "?"]'
        work_data = parse_workline(connection, workline)
        fields = work_data['fields']
        self.assertEqual(work_data['id'], 1)
        self.assertEqual(fields['assignee_id'], 21)
        self.assertEqual(fields['effort_left_d'], 0.2)
        self.assertEqual(fields['title'], 'Make title longer')
        self.assertEqual(fields['prereqs'], '[]')
        self.assertEqual(fields['key_date'], None)
예제 #3
0
def edit_project(project_id):
    name = request.values['name']
    target_date = dovetail.util.parse_date(request.values['target_date'])
    worklines = request.values['worklines'].split('\n')
    original_work_ids = set(json.loads(request.values['original_work_ids']))

    work = []
    for workline in worklines:
        try:
            work_data = projects_util.parse_workline(g.connection, workline)
            fields = work_data['fields']
            fields.update(project_id=project_id)

            # Save any changes to the work items
            # TOOD: Separate topo sort work so we only have to write to database once
            work_db.update_work(g.connection, work_data)
            fields.update(id=work_data['id'])
            work.append(work_db.fields_to_work_object(fields))
        except:
            # TODO: log something
            pass

    # Mark missing work as done
    returned_work_ids = set([w.work_id for w in work])
    done_work_ids = original_work_ids - returned_work_ids
    work_db.mark_work_done(g.connection, done_work_ids)

    project = Project(project_id)
    project.name = name
    project.target_date = target_date
    project.work = work
    project.topo_sort_work()
    work_db.update_work_topo_order(g.connection, project.work)
    #dovetail.scheduler.reschedule_world(g.connection)

    # Update project info
    projects_db.update_project(g.connection, project)

    response_data = {}
    result = Response(json.dumps(response_data),
                      status=200,
                      mimetype='application/json')
    return result
예제 #4
0
def edit_project(project_id):
    name = request.values['name']
    target_date = dovetail.util.parse_date(request.values['target_date'])
    worklines = request.values['worklines'].split('\n')
    original_work_ids = set(json.loads(request.values['original_work_ids']))

    work = []
    for workline in worklines:
        try:
            work_data = projects_util.parse_workline(g.connection, workline)
            fields = work_data['fields']
            fields.update(project_id = project_id)

            # Save any changes to the work items
            # TOOD: Separate topo sort work so we only have to write to database once
            work_db.update_work(g.connection, work_data)
            fields.update(id = work_data['id'])
            work.append(work_db.fields_to_work_object(fields))
        except:
            # TODO: log something
            pass

    # Mark missing work as done
    returned_work_ids = set([w.work_id for w in work])
    done_work_ids = original_work_ids - returned_work_ids
    work_db.mark_work_done(g.connection, done_work_ids)

    project = Project(project_id)
    project.name = name
    project.target_date = target_date
    project.work = work
    project.topo_sort_work()
    work_db.update_work_topo_order(g.connection, project.work)
    #dovetail.scheduler.reschedule_world(g.connection)

    # Update project info
    projects_db.update_project(g.connection, project)

    response_data = {}
    result = Response(json.dumps(response_data), status=200, mimetype='application/json')
    return result