Example #1
0
def projects():
    projects = projects_db.select_project_collection(g.connection)
    data = []
    project_rank_data = []
    timeline_aux_data = {}
    for i, p in enumerate(projects):
        status = projects_util.compute_status(p.target_date, p.est_end_date)
        target_date = dovetail.util.format_date(p.target_date)
        est_end_date = dovetail.util.format_date(p.est_end_date)
        effort_left_d = dovetail.util.format_effort_left(p.total_effort(), 0)
        d = {
            'project_id': p.project_id,
            'rank': i + 1,
            'name': p.name,
            'target_date': target_date,
            'est_end_date': est_end_date,
            'status': status,
            'effort_left_d': effort_left_d,
            'detail_url': '/projects/%d' % p.project_id
        }
        data.append(d)
        project_rank_data.append('%d %s' % (p.project_id, p.name))

        timeline_aux_data[p.project_id] = {
            'title':
            p.name,
            'content':
            '''
            <p class="label %s">%s</p>
            <p>Total effort left: %s</p>
            <p>%s (estimated)</p>
            <p>%s (target)</p>
            ''' % (status['class'], status['label'], effort_left_d,
                   est_end_date, target_date)
        }

    project_ids = json.dumps([p.project_id for p in projects])

    # TODO: Only select the most recently completed
    done_projects = projects_db.select_done_project_collection(g.connection)

    if request.args.get('timeline'):
        chart = ProjectCollectionTimelineChart(datetime.now(), projects)
        return render_template('projects/collection_timeline.html',
                               project_data=data,
                               projects_url='/projects',
                               projects_timeline_url='/projects?timeline=true',
                               timeline_data=chart.as_json(),
                               timeline_aux_data=json.dumps(timeline_aux_data),
                               project_rank_data='\n'.join(project_rank_data),
                               project_ids=project_ids,
                               done_projects=done_projects)
    else:
        return render_template('projects/collection.html',
                               project_data=data,
                               projects_url='/projects',
                               projects_timeline_url='/projects?timeline=true',
                               project_rank_data='\n'.join(project_rank_data),
                               project_ids=project_ids,
                               done_projects=done_projects)
Example #2
0
def projects():
    projects = projects_db.select_project_collection(g.connection)
    data = []
    project_rank_data = []
    timeline_aux_data = {}
    for i, p in enumerate(projects):
        status = projects_util.compute_status(p.target_date, p.est_end_date)
        target_date = dovetail.util.format_date(p.target_date)
        est_end_date = dovetail.util.format_date(p.est_end_date)
        effort_left_d = dovetail.util.format_effort_left(p.total_effort(), 0)
        d = {
            'project_id': p.project_id,
            'rank': i + 1,
            'name': p.name,
            'target_date': target_date,
            'est_end_date': est_end_date,
            'status': status,
            'effort_left_d': effort_left_d,
            'detail_url': '/projects/%d' % p.project_id
        }
        data.append(d)
        project_rank_data.append('%d %s' % (p.project_id, p.name))

        timeline_aux_data[p.project_id] = {
            'title': p.name,
            'content': '''
            <p class="label %s">%s</p>
            <p>Total effort left: %s</p>
            <p>%s (estimated)</p>
            <p>%s (target)</p>
            ''' % (status['class'], status['label'], effort_left_d, est_end_date, target_date)
        }

    project_ids = json.dumps([p.project_id for p in projects])

    # TODO: Only select the most recently completed
    done_projects = projects_db.select_done_project_collection(g.connection)

    if request.args.get('timeline'):
        chart = ProjectCollectionTimelineChart(datetime.now(), projects)
        return render_template('projects/collection_timeline.html',
                project_data = data,
                projects_url = '/projects',
                projects_timeline_url = '/projects?timeline=true',
                timeline_data = chart.as_json(),
                timeline_aux_data = json.dumps(timeline_aux_data),
                project_rank_data = '\n'.join(project_rank_data),
                project_ids = project_ids,
                done_projects = done_projects
                )
    else:
        return render_template('projects/collection.html',
                project_data = data,
                projects_url = '/projects',
                projects_timeline_url = '/projects?timeline=true',
                project_rank_data = '\n'.join(project_rank_data),
                project_ids = project_ids,
                done_projects = done_projects
                )
Example #3
0
def project(project_id):
    project = projects_db.select_project(g.connection, project_id)
    projects_util.format_work_dates(project.work)
    project_data = {
            'project_id': project.project_id,
            'name': project.name,
            'target_date': dovetail.util.format_date(project.target_date),
            'est_end_date': dovetail.util.format_date(project.est_end_date),
            'status': projects_util.compute_status(project.target_date, project.est_end_date),
            'effort_left_d': dovetail.util.format_effort_left(project.total_effort(), 1),
            'work': project.work,
            'work_ids': json.dumps([w.work_id for w in project.work]),
            'participants': project.participants,
            'details_url': '/projects/%d' % project_id,
            'details_timeline_url': '/projects/%d?timeline=true' % project_id
            }

    if request.args.get('timeline'):
        assignee_ids = set([w.assignee.person_id for w in project.work])
        timelines = work_db.select_timelines_for_people(g.connection, assignee_ids)
        timeline_aux_data = {}
        for bars in timelines.values():
            for bar in bars:
                timeline_aux_data[bar['work_id']] = {
                    'title': '[%s] %s' % (bar['project_name'], bar['label']),
                    'content': '''
                    <p>%s</p>
                    <p>%s</p>
                    <p>Start: %s</p>
                    <p>Finish: %s</p>
                    ''' % (
                        bar['assignee_name'],
                        dovetail.util.format_effort_left(bar['effort_left_d']),
                        dovetail.util.format_date(bar['start_date']),
                        dovetail.util.format_date(bar['end_date'])
                        )
                }

        chart = ProjectTimelineChart(project_id, datetime.now(), timelines)

        return render_template('projects/details_timeline.html',
                project_data = project_data,
                timeline_data = chart.as_json(),
                timeline_aux_data = json.dumps(timeline_aux_data),
                work_data = projects_util.project_work_to_string(project.work),
                participants = people_db.select_project_participants(g.connection, project_id),
                people = people_db.select_people(g.connection))
    else:
        done_work = work_db.select_done_work_for_project(g.connection, project_id)
        projects_util.format_work_dates(done_work)
        return render_template('projects/details.html',
                project_data = project_data,
                work_data = projects_util.project_work_to_string(project.work),
                participants = people_db.select_project_participants(g.connection, project_id),
                done_work = done_work,
                people = people_db.select_people(g.connection))
Example #4
0
def project(project_id):
    project = projects_db.select_project(g.connection, project_id)
    projects_util.format_work_dates(project.work)
    project_data = {
        'project_id':
        project.project_id,
        'name':
        project.name,
        'target_date':
        dovetail.util.format_date(project.target_date),
        'est_end_date':
        dovetail.util.format_date(project.est_end_date),
        'status':
        projects_util.compute_status(project.target_date,
                                     project.est_end_date),
        'effort_left_d':
        dovetail.util.format_effort_left(project.total_effort(), 1),
        'work':
        project.work,
        'work_ids':
        json.dumps([w.work_id for w in project.work]),
        'participants':
        project.participants,
        'details_url':
        '/projects/%d' % project_id,
        'details_timeline_url':
        '/projects/%d?timeline=true' % project_id
    }

    if request.args.get('timeline'):
        assignee_ids = set([w.assignee.person_id for w in project.work])
        timelines = work_db.select_timelines_for_people(
            g.connection, assignee_ids)
        timeline_aux_data = {}
        for bars in timelines.values():
            for bar in bars:
                timeline_aux_data[bar['work_id']] = {
                    'title':
                    '[%s] %s' % (bar['project_name'], bar['label']),
                    'content':
                    '''
                    <p>%s</p>
                    <p>%s</p>
                    <p>Start: %s</p>
                    <p>Finish: %s</p>
                    ''' %
                    (bar['assignee_name'],
                     dovetail.util.format_effort_left(bar['effort_left_d']),
                     dovetail.util.format_date(bar['start_date']),
                     dovetail.util.format_date(bar['end_date']))
                }

        chart = ProjectTimelineChart(project_id, datetime.now(), timelines)

        return render_template(
            'projects/details_timeline.html',
            project_data=project_data,
            timeline_data=chart.as_json(),
            timeline_aux_data=json.dumps(timeline_aux_data),
            work_data=projects_util.project_work_to_string(project.work),
            participants=people_db.select_project_participants(
                g.connection, project_id),
            people=people_db.select_people(g.connection))
    else:
        done_work = work_db.select_done_work_for_project(
            g.connection, project_id)
        projects_util.format_work_dates(done_work)
        return render_template(
            'projects/details.html',
            project_data=project_data,
            work_data=projects_util.project_work_to_string(project.work),
            participants=people_db.select_project_participants(
                g.connection, project_id),
            done_work=done_work,
            people=people_db.select_people(g.connection))