Esempio n. 1
0
def dash_developer(request):
    projects = request.user.carrotprofile.projects.all()
    if request.GET.get('project_slug'):
        project = projects.get(slug=request.GET.get('project_slug'))
    else:
        project = projects[0]
    versions = project.version_set.filter(is_completed=False).order_by('end_date')
    versions_data = []
    for v in versions:
        version_tickets = v.ticket_set.order_by('kind', '-priority', 'number')
        statistic = None
        if v.end_date >= datetime.datetime.now().date():
            tickets_hours = TicketEstimate.objects\
                .exclude(ticket__status__in=[TicketStatus.FIXED, TicketStatus.CLOSED, TicketStatus.REJECTED])\
                .filter(ticket__fix_version=v, is_expert=False)\
                .aggregate(Sum('hours'))['hours__sum'] or 0
            real_time_left = work_hours(v.end_date)
            all_real_time = work_hours(v.start_date, v.end_date)
            logged_time = TimeLog.objects.filter(ticket__fix_version=v)\
                .aggregate(Sum('hours'))['hours__sum'] or 0
            statistic = {
                'tickets_time': tickets_hours,
                'real_time_left': real_time_left,
                'real_time_passed': all_real_time - real_time_left,
                'logged_time': logged_time,
                'tickets_percent': int(tickets_hours/float(all_real_time) * 100),
                'real_percent': int(real_time_left/float(all_real_time) * 100),
            }
        versions_data.append((
            v,
            version_tickets,
            statistic))
    data = {
        'pm': Roles.has_role(request.user, Roles.pm),
        'project': project,
        'version': versions[0],# just for +ticket menu option
        'projects': projects,
        'versions': versions_data
    }
    return TemplateResponse(request, 'carrot/dash/developer.html', data)
Esempio n. 2
0
def home(request):
    if Roles.has_role(request.user, Roles.developer):
        return dash_developer(request)
    return TemplateResponse(request, 'carrot/site_base.html', {})