def render( self, request, event, detail_template_name="timeline/fogbugz_event_detail.html", commands_template_name="timeline/fogbugz_event_commands.html", ): task = event.task if not task: return HttpResponse() cmds = [] events = [] tracker = BugTrackerFactory.get_bug_tracker_instance(task.bug_tracker) if tracker: cmds, events = tracker.get_events_for_bug(task.bug_tracker.base_url, task.remote_tracker_id) return HttpResponse( simplejson.dumps( { "commands": render_to_string(commands_template_name, {"commands": cmds}), "detail": render_to_string( detail_template_name, {"events": events, "task": task, "snap": task.get_latest_snapshot()} ), } ) )
def render(self, request, event, detail_template_name='timeline/fogbugz_event_detail.html', commands_template_name='timeline/fogbugz_event_commands.html'): task = event.task if not task: return HttpResponse() cmds = [] events = [] tracker = BugTrackerFactory.get_bug_tracker_instance(task.bug_tracker) if tracker: cmds, events = tracker.get_events_for_bug( task.bug_tracker.base_url, task.remote_tracker_id) return HttpResponse( simplejson.dumps({ 'commands': render_to_string(commands_template_name, {'commands': cmds}), 'detail': render_to_string( detail_template_name, { 'events': events, 'task': task, 'snap': task.get_latest_snapshot() }) }))
def snapshot_statistics(self): """ Fetches the latest statistics about the milestone from the remote tracker. """ client = BugTrackerFactory.get_bug_tracker_instance(self.bug_tracker) if not client: return None stats = client.get_stats_for_milestone(self.bug_tracker.product, self.remote_tracker_name) stat, created = MilestoneStatisticsCache.objects.get_or_create( date=date.today(), milestone=self) stat.total_open_tasks = stats[0] stat.total_estimated_hours = stats[1] stat.total_remaining_hours = stats[2] stat.save() return stat
def snapshot_statistics(self): """ Fetches the latest statistics about the milestone from the remote tracker. """ client = BugTrackerFactory.get_bug_tracker_instance(self.bug_tracker) if not client: return None stats = client.get_stats_for_milestone(self.bug_tracker.product, self.remote_tracker_name) stat, created = MilestoneStatisticsCache.objects.get_or_create(date=date.today(), milestone=self) stat.total_open_tasks = stats[0] stat.total_estimated_hours = stats[1] stat.total_remaining_hours = stats[2] stat.save() return stat
def snapshot(self): """ Creates a new TaskSnapshot from the most recent bug tracke data. Returns the new snapshot if successful, None otherwise. """ def lookup_user(email): users = User.objects.filter(email=email) return users[0] if users.count() > 0 else None client = BugTrackerFactory.get_bug_tracker_instance(self.bug_tracker) if not client: return None bug = client.get_bug(self.remote_tracker_id) return TaskSnapshot.objects.create(task=self, title=bug.summary, component=bug.component, status=bug.status, submitted_by=lookup_user(bug.submitted_by), assigned_to=lookup_user(bug.assigned_to), estimated_hours=int(bug.estimated_time), actual_hours=int(bug.actual_time), remaining_hours=int(bug.remaining_time))
def snapshot(self): """ Creates a new TaskSnapshot from the most recent bug tracke data. Returns the new snapshot if successful, None otherwise. """ def lookup_user(email): users = User.objects.filter(email=email) return users[0] if users.count() > 0 else None client = BugTrackerFactory.get_bug_tracker_instance(self.bug_tracker) if not client: return None bug = client.get_bug(self.remote_tracker_id) return TaskSnapshot.objects.create( task=self, title=bug.summary, component=bug.component, status=bug.status, submitted_by=lookup_user(bug.submitted_by), assigned_to=lookup_user(bug.assigned_to), estimated_hours=int(bug.estimated_time), actual_hours=int(bug.actual_time), remaining_hours=int(bug.remaining_time))