[gsoc-admin] EmailTemplate: Allow usage of time values



commit 9365917dbc0415853b35020c513eca89231d1d25
Author: Lasse Schuirmann <lasse schuirmann gmail com>
Date:   Wed Aug 12 20:25:25 2015 +0200

    EmailTemplate: Allow usage of time values

 maillib/email.py |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/maillib/email.py b/maillib/email.py
index 8a2f3f3..fca8bd4 100755
--- a/maillib/email.py
+++ b/maillib/email.py
@@ -1,5 +1,7 @@
 #!/usr/bin/env python3
 
+import datetime
+
 
 def send_mail(text, sender, recipient, cc, bcc):
     raise NotImplementedError
@@ -27,6 +29,19 @@ class EmailTemplate:
         self.bcc = bcc
 
     def get_specific(self, data_dict):
+        """
+        Applies the data to the template.
+
+        :param data_dict: Will be modified (mutable)! Data about the current
+                          time will be added.
+        """
+        now = datetime.datetime.now()
+        data_dict.update({
+            'year': now.year,
+            'month': now.month,
+            'day': now.day,
+            'hour': now.hour,
+            'minute': now.minute})
         return self.text.format(**data_dict)
 
     def send(self, data_dict):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]