Example #1
0
def timesheet_index(request):
    """
    Redirects the logged-in User to their Timesheet for the current
    week.
    """
    week_commencing = week_commencing_date(datetime.date.today())
    timesheet, created = \
        Timesheet.objects.get_or_create(user=request.user,
                                        week_commencing=week_commencing)
    return HttpResponseRedirect(timesheet.get_absolute_url())
Example #2
0
 def testWeekCommencingDate(self):
     week_commencing = date(2007, 7, 23)
     self.assertEquals(week_commencing, week_commencing_date(date(2007, 7, 23)))
     self.assertEquals(week_commencing, week_commencing_date(date(2007, 7, 24)))
     self.assertEquals(week_commencing, week_commencing_date(date(2007, 7, 25)))
     self.assertEquals(week_commencing, week_commencing_date(date(2007, 7, 26)))
     self.assertEquals(week_commencing, week_commencing_date(date(2007, 7, 27)))
     self.assertEquals(week_commencing, week_commencing_date(date(2007, 7, 28)))
     self.assertEquals(week_commencing, week_commencing_date(date(2007, 7, 29)))
Example #3
0
 def testWeekCommencingDate(self):
     week_commencing = date(2007, 7, 23)
     self.assertEquals(week_commencing,
                       week_commencing_date(date(2007, 7, 23)))
     self.assertEquals(week_commencing,
                       week_commencing_date(date(2007, 7, 24)))
     self.assertEquals(week_commencing,
                       week_commencing_date(date(2007, 7, 25)))
     self.assertEquals(week_commencing,
                       week_commencing_date(date(2007, 7, 26)))
     self.assertEquals(week_commencing,
                       week_commencing_date(date(2007, 7, 27)))
     self.assertEquals(week_commencing,
                       week_commencing_date(date(2007, 7, 28)))
     self.assertEquals(week_commencing,
                       week_commencing_date(date(2007, 7, 29)))
Example #4
0
def bulk_approval(request):
    """
    Performs bulk approval of Time Entries and Expenses.
    """
    if request.method == 'POST':
        form = BulkApprovalForm(request.POST)
        if form.is_valid():
            start_date = week_commencing_date(form.cleaned_data['start_date'])
            end_date = week_ending_date(form.cleaned_data['end_date'])
            entries, expenses = Timesheet.objects.bulk_approve(request.user,
                                                               start_date,
                                                               end_date)
            return render_to_response('timesheets/bulk_approval.html', {
                'start_date': start_date,
                'end_date': end_date,
                'approved_time_entries': entries,
                'approved_expenses': expenses,
            }, RequestContext(request))
    else:
        form = BulkApprovalForm()
    return render_to_response('timesheets/bulk_approval.html', {
            'form': form,
        }, RequestContext(request))