diff --git a/tailbone/templates/timesheet/index.mako b/tailbone/templates/timesheet/index.mako index 0c4e0a95..32b26ccf 100644 --- a/tailbone/templates/timesheet/index.mako +++ b/tailbone/templates/timesheet/index.mako @@ -6,6 +6,14 @@ <%def name="head_tags()"> ${parent.head_tags()} + -
- -
- ${employee} -
-
+
-
- -
- ${week_of} +
+ +
+ ${employee} +
-
+ +
+ +
+ ${week_of} +
+
+ +
+ ${h.form(url('timesheet'))} + + ${h.text('date', value=sunday.strftime('%Y-%m-%d'))} + ${h.submit('go', "Go")} + ${h.end_form()} +
+ +
diff --git a/tailbone/views/timesheet.py b/tailbone/views/timesheet.py index ecd2be24..06c426a1 100644 --- a/tailbone/views/timesheet.py +++ b/tailbone/views/timesheet.py @@ -41,10 +41,20 @@ class TimeSheetView(View): """ def __call__(self): + date = None + if 'date' in self.request.GET: + try: + date = datetime.datetime.strptime(self.request.GET['date'], '%Y-%m-%d').date() + except ValueError: + self.request.session.flash("The specified date is not valid: {}".format(self.request.GET['date']), 'error') + if not date: + date = localtime(self.rattail_config).date() + return self.render(date) + + def render(self, date): employee = self.request.user.employee assert employee - today = localtime(self.rattail_config).date() - sunday = get_sunday(today) + sunday = get_sunday(date) weekdays = [sunday] for i in range(1, 7): @@ -103,9 +113,9 @@ class TimeSheetView(View): def includeme(config): + config.add_tailbone_permission('timesheet', 'timesheet.view', "View Time Sheet") + # current user's time sheet config.add_route('timesheet', '/timesheet/') config.add_view(TimeSheetView, route_name='timesheet', - renderer='/timesheet/index.mako', - permission='timesheet.view') - config.add_tailbone_permission('timesheet', 'timesheet.view', "View Time Sheet") + renderer='/timesheet/index.mako', permission='timesheet.view')