diff options
Diffstat (limited to 'maconomy/templates.py')
-rw-r--r-- | maconomy/templates.py | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/maconomy/templates.py b/maconomy/templates.py index 07cbeb1..4889c48 100644 --- a/maconomy/templates.py +++ b/maconomy/templates.py @@ -30,11 +30,38 @@ class MissingEmailTemplate(BaseTemplate): class ManagerEmailTemplate(BaseTemplate): def __init__(self): self.set_template("templates/manager.html") + self.status_template = EmployeeStatusTemplate() - def build(self, employee, week, maconomyurl, **kwargs): - submitted = '' if 'submitted' in kwargs and kwargs['submitted'] else 'not' - approved = '' if 'approved' in kwargs and kwargs['approved'] else 'not' - return self.template.substitute(employee=employee.__unicode__(),week=week,maconomyurl=maconomyurl, submitted=submitted, approved=approved) + def build(self, timesheets, maconomyurl): + statuslist = self.build_statuslist(timesheets) + return self.template.substitute(statuslist=statuslist,maconomyurl=maconomyurl) + def build_statuslist(self, timesheets): + statuslist = [self.status_template.build(timesheet) for timesheet in timesheets] + return "\n".join(statuslist) +class EmployeeStatusTemplate(BaseTemplate): + def __init__(self, include_approver=False): + self.set_template("templates/_employee_status.html") + self.include_approver = include_approver + def build(self, timesheet): + employee = timesheet.employee + submitted = '' if timesheet.is_submitted() else 'not' + approver = timesheet.approver if self.include_approver else 'you' + approved = '' if timesheet.is_approved() else 'not' + return self.template.substitute(employee=employee.__unicode__(), submitted=submitted, approved=approved, approver=approver) + +class CEOEmailTemplate(BaseTemplate): + def __init__(self): + self.set_template("templates/ceo.html") + self.status_template = EmployeeStatusTemplate(include_approver=True) + + def build(self, timesheets): + statuslist = self.build_statuslist(timesheets) + return self.template.substitute(statuslist=statuslist) + + def build_statuslist(self, timesheets): + statuslist = [self.status_template.build(timesheet) for timesheet in timesheets] + return "\n".join(statuslist) + |