示例#1
0
文件: views.py 项目: alarin/carrot
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)
示例#2
0
文件: tests.py 项目: alarin/carrot
 def test_full_week(self):
     monday = self.get_date_for_weekday(0)
     self.assertEquals(40, work_hours(monday, monday + timedelta(days=6)))
     self.assertEquals(80, work_hours(monday, monday + timedelta(days=13)))
示例#3
0
文件: tests.py 项目: alarin/carrot
 def test_workhours_holidays(self):
     friday = self.get_date_for_weekday(4)
     self.assertEquals(16, work_hours(friday, friday + timedelta(days=3)))
示例#4
0
文件: tests.py 项目: alarin/carrot
 def test_workhours_simple(self):
     monday = self.get_date_for_weekday(0)
     self.assertEquals(16, work_hours(monday, monday + timedelta(days=1)))