diff options
Diffstat (limited to 'maconomy/templates.py')
-rw-r--r-- | maconomy/templates.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/maconomy/templates.py b/maconomy/templates.py new file mode 100644 index 0000000..07cbeb1 --- /dev/null +++ b/maconomy/templates.py @@ -0,0 +1,40 @@ +from string import Template + +class BaseTemplate(object): + def __init__(self, template_file): + self.set_template(template_file) + + def build(self, **kwargs): + return self.template.substitute(**kwargs) + + def set_template(self, template_file): + with open(template_file, 'r') as f: + template_base = f.read() + self.template = Template(template_base) + + +class UnsubmittedEmailTemplate(BaseTemplate): + def __init__(self): + self.set_template("templates/unsubmitted.html") + + def build(self, week, maconomyurl, helpurl): + return self.template.substitute(week=week, maconomyurl=maconomyurl, helpurl=helpurl) + +class MissingEmailTemplate(BaseTemplate): + def __init__(self): + self.set_template("templates/missing.html") + + def build(self, maconomyurl, helpurl): + return self.template.substitute(maconomyurl=maconomyurl, helpurl=helpurl) + +class ManagerEmailTemplate(BaseTemplate): + def __init__(self): + self.set_template("templates/manager.html") + + 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) + + + |