Exemple #1
0
 def convert_context_to_csv(self, context):
     rows = []
     rows.append([
         'Date',
         'User',
         'Activity',
         'Location',
         'Time In',
         'Time Out',
         'Breaks',
         'Hours',
     ])
     for entry in context['entries']:
         data = [
             entry['start_time'].strftime('%x'),
             entry['user__first_name'] + ' ' + entry['user__last_name'],
             entry['activity__name'],
             entry['location__name'],
             entry['start_time'].strftime('%X'),
             entry['end_time'].strftime('%X'),
             seconds_to_hours(entry['seconds_paused']),
             entry['hours'],
         ]
         rows.append(data)
     total = context['total']
     rows.append(('', '', '', '', '', '', 'Total:', total))
     return rows
 def convert_context_to_csv(self, context):
     rows = []
     rows.append([
         'Date',
         'Weekday',
         'Name',
         'Location',
         'Time In',
         'Time Out',
         'Breaks',
         'Hours',
     ])
     for entry in context['billable_entries']:
         data = [
             entry.start_time.strftime('%x'),
             entry.start_time.strftime('%A'),
             entry.user.get_name_or_username(),
             entry.location,
             entry.start_time.strftime('%X'),
             entry.end_time.strftime('%X'),
             seconds_to_hours(entry.seconds_paused),
             entry.hours,
         ]
         rows.append(data)
     total = context['billable_entries'].aggregate(
         hours=Sum('hours'))['hours']
     rows.append(('', '', '', '', '', '', 'Total:', total))
     return rows
Exemple #3
0
 def convert_context_to_csv(self, context):
     rows = []
     rows.append([
         'Date',
         'Weekday',
         'Name',
         'Location',
         'Time In',
         'Time Out',
         'Breaks',
         'Hours',
     ])
     for entry in context['entries']:
         data = [
             entry.start_time.strftime('%x'),
             entry.start_time.strftime('%A'),
             entry.user.get_full_name(),
             entry.location,
             entry.start_time.strftime('%X'),
             entry.end_time.strftime('%X'),
             seconds_to_hours(entry.seconds_paused),
             entry.hours,
         ]
         rows.append(data)
     total = context['entries'].aggregate(hours=Sum('hours'))['hours']
     rows.append(('', '', '', '', '', '', 'Total:', total))
     return rows
Exemple #4
0
 def convert_context_to_csv(self, context):
     rows = []
     rows.append([
         'Date',
         'User',
         'Activity',
         'Location',
         'Time In',
         'Time Out',
         'Breaks',
         'Hours',
     ])
     for entry in context['entries']:
         data = [
             entry['start_time'].strftime('%x'),
             entry['user__first_name'] + ' ' + entry['user__last_name'],
             entry['activity__name'],
             entry['location__name'],
             entry['start_time'].strftime('%X'),
             entry['end_time'].strftime('%X'),
             seconds_to_hours(entry['seconds_paused']),
             entry['hours'],
         ]
         rows.append(data)
     total = context['total']
     rows.append(('', '', '', '', '', '', 'Total:', total))
     return rows
Exemple #5
0
 def convert_context_to_csv(self, context):
     rows = []
     rows.append([
         'Date',
         'Weekday',
         'Name',
         'Location',
         'Time In',
         'Time Out',
         'Breaks',
         'Hours',
     ])
     for entry in context['billable_entries']:
         data = [
             entry.start_time.strftime('%x'),
             entry.start_time.strftime('%A'),
             entry.user.get_name_or_username(),
             entry.location,
             entry.start_time.strftime('%X'),
             entry.end_time.strftime('%X'),
             seconds_to_hours(entry.seconds_paused),
             "{0:.2f}".format(entry.hours),
         ]
         rows.append(data)
     total = context['billable_entries'].aggregate(hours=Sum(
         Func(F('hours'), Value(2), function='ROUND'))
     )['hours']
     rows.append(('', '', '', '', '', '', 'Total:', "{0:.2f}".format(total)))
     return rows
Exemple #6
0
 def test_seconds_to_hours(self):
     # basic math
     self.assertEqual(0.5, tags.seconds_to_hours(1800))
     self.assertEqual(2.0, tags.seconds_to_hours(7200))
     # rounding
     self.assertEqual(2.0, tags.seconds_to_hours(7201))
 def test_seconds_to_hours(self):
     # basic math
     self.assertEqual(0.5, tags.seconds_to_hours(1800))
     self.assertEqual(2.0, tags.seconds_to_hours(7200))
     # rounding
     self.assertEqual(2.0, tags.seconds_to_hours(7201))