Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 6 files changed
  • 0 comments
  • 1 contributor
22 jobclock.bbprojectd/Scratchpad.txt
@@ -46,13 +46,27 @@ http://www.b-list.org/weblog/2007/nov/04/working-models/
46 46 bindery manager marks job as complete, system moves job data to next report and archive.
47 47
48 48
49   -for wp in wpa:
50   -... if wp.worker in total:
51   -... total[wp.worker] = total[wp.worker] + wp.duration
  49 +>>> worker_total = {}
  50 +>>> for wp in wpall:
  51 +... if wp.worker in worker_total:
  52 +... worker_total[wp.worker] = worker_total[wp.worker] + wp.duration
52 53 ... else:
53   -... total[wp.worker] = wp.duration
  54 +... worker_total[wp.worker] = wp.duration
54 55 ...
55 56
  57 +>>> job_total = {}
  58 +>>> for wp in wpall:
  59 +... if wp.job in job_total:
  60 +... job_total[wp.job] = job_total[wp.job] + wp.duration
  61 +... else:
  62 +... job_total[wp.job] = wp.duration
  63 +...
  64 +
  65 +
  66 +
  67 +>>> for jt in job_total:
  68 +... secs = job_total[jt].seconds + job_total[jt].days * 24 * 3600
  69 +... "%s - %d:%02d" % (job_total[jt] , secs/3600, secs%3600/60)
56 70
57 71
58 72 import datetime
20 templates/timeclock/clockpunchsums.html
@@ -9,16 +9,16 @@
9 9 </head>
10 10 <body>
11 11
12   -<table>
13   -{% for line in work_periods %}
14   - <tr>
15   - <td>{{ line.ticket }} </td>
16   - <td>{{ line.worker }}</td>
17   - <td>{{ line.job }}</td>
18   - <td>{{ line.duration }}</td>
19   - </tr>
20   -{% endfor %}
21   -</table>
  12 + <table>
  13 + {% for line in work_periods %}
  14 + <tr>
  15 + <td>{{ line.ticket }} </td>
  16 + <td>{{ line.worker }}</td>
  17 + <td>{{ line.job }}</td>
  18 + <td>{{ line.duration }}</td>
  19 + </tr>
  20 + {% endfor %}
  21 + </table>
22 22
23 23 </body>
24 24 </html>
48 templates/timeclock/work_totals.html
... ... @@ -0,0 +1,48 @@
  1 +<html>
  2 +<head>
  3 + <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  4 + <title>Work Totals</title>
  5 +</head>
  6 +<body>
  7 +
  8 +
  9 +<ul>
  10 +
  11 +{% for name,value in params.items %}
  12 + <li> {{ name }}: {{ value }}</li>
  13 +{% endfor %}
  14 +
  15 +{% for name,value in bugs.items %}
  16 + <li>bug {{ name }}: {{ value }}</li>
  17 +{% endfor %}
  18 +
  19 +</ul>
  20 +<h1>Work Totals</h1>
  21 +<h2>By Job</h2>
  22 +
  23 +
  24 +
  25 +
  26 +
  27 +<table>
  28 +{% for job, total_time in job_total.items %}
  29 + <tr>
  30 + <td>{{ job.ticket }}</td>
  31 + <td>{{ job.description }}</td>
  32 + <td>{{ total_time}}</td>
  33 + </tr>
  34 +{% endfor %}
  35 +</table>
  36 +
  37 +
  38 +<h2>By Person</h2>
  39 +<table>
  40 +{% for worker, total_time in worker_total.items %}
  41 + <tr>
  42 + <td>{{ worker.name }}</td>
  43 + <td>{{ total_time }}</td>
  44 + </tr>
  45 +{% endfor %}
  46 +</table>
  47 +</body>
  48 +</html>
6 timeclock/urls.py
@@ -2,13 +2,15 @@
2 2
3 3
4 4 # Our stuff
5   -from timeclock.views import ClockPunchView, ClockPunchSums, WorkPeriodView
  5 +from timeclock.views import ClockPunchView, ClockPunchSums, WorkPeriodView, WorkTotals
6 6
7 7 urlpatterns = patterns('',
8   - url(r'^$', ClockPunchView.as_view(), name='clockpunch-view'),
  8 + url(r'^$', ClockPunchView.as_view(), name='clockpunch_view'),
9 9 url(r'summary', ClockPunchSums.as_view(), name='clockpunchsums'),
10 10 url(r'workperiods/(?P<workername>\w*)/$', WorkPeriodView.as_view(), name='workperiods'),
11 11 url(r'workperiods/(?P<workername>\w*)/(?P<startdate>\d{8}/$)', WorkPeriodView.as_view(), name='workperiod_startdate'),
  12 + url(r'work_totals/$', WorkTotals.as_view(), name='work_totals_view'),
  13 + url(r'work_totals/(?P<startyear>\d{4})/(?P<startmonth>\d{1,2})/(?P<startday>\d{1,2})/(?P<endyear>\d{4})/(?P<endmonth>\d{1,2})/(?P<endday>\d{1,2})/$', WorkTotals.as_view(), name='work_totals_view'),
12 14 # Examples:
13 15 # url(r'^$', 'jobclockproj.views.home', name='home'),
14 16 # url(r'^jobclockproj/', include('jobclockproj.foo.urls')),
31 timeclock/views.py
@@ -25,9 +25,9 @@ def get_context_data(self, **kwargs):
25 25 context['last_ten_punches'] = [ {'worker': p.worker.name, 'job' : p.activity.ticket , 'tstamp': p.timestamp} for p in last_ten_punches ]
26 26 return context
27 27
28   -# success_url = reverse_lazy('clockpunch-view')
  28 +# success_url = reverse_lazy('clockpunch_view')
29 29 def get_success_url(self):
30   - return reverse('clockpunch-view')
  30 + return reverse('clockpunch_view')
31 31
32 32 def form_valid(self,form):
33 33 form.save()
@@ -66,3 +66,30 @@ def get_context_data(self, **kwargs):
66 66 context['workername'] = self.kwargs['workername']
67 67 context['work_periods'] = self._get_work_periods() #workername=self.kwargs['workername'])
68 68 return context
  69 +
  70 +class WorkTotals(TemplateView):
  71 + template_name='timeclock/work_totals.html'
  72 + work_periods=WorkPeriod.objects.all()
  73 +
  74 + def _get_work_periods(self, **kwargs):
  75 + pass #### START HERE
  76 +
  77 + def get_context_data(self, **kwargs):
  78 + context = super(WorkTotals, self).get_context_data(**kwargs)
  79 + params = context['params']
  80 + context['bugs'] = params
  81 + worker_total = {}
  82 + job_total = {}
  83 + for wp in self.work_periods:
  84 + if wp.worker in worker_total:
  85 + worker_total[wp.worker] = worker_total[wp.worker] + wp.duration
  86 + else:
  87 + worker_total[wp.worker] = wp.duration
  88 + if wp.job in job_total:
  89 + job_total[wp.job] = job_total[wp.job] + wp.duration
  90 + else:
  91 + job_total[wp.job] = wp.duration
  92 + context['worker_total'] = worker_total
  93 + context['job_total'] = job_total
  94 + return context
  95 +
1  urls.py
@@ -8,4 +8,5 @@
8 8 url(r'^jobclock/', include('timeclock.urls')),
9 9 # Uncomment the next line to enable the admin:
10 10 url(r'^admin/', include(admin.site.urls)),
  11 + # url(r'^$', ),
11 12 )

No commit comments for this range

Something went wrong with that request. Please try again.