[gsoc-admin] EmailTemplate: Add date
- From: Lasse Schuirmann <lschuirma src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gsoc-admin] EmailTemplate: Add date
- Date: Thu, 13 Aug 2015 10:25:40 +0000 (UTC)
commit d060441485a8de0949a811a193bcc845b822954e
Author: Lasse Schuirmann <lasse schuirmann gmail com>
Date: Thu Aug 13 12:25:02 2015 +0200
EmailTemplate: Add date
data/config.cfg | 3 ++-
maillib/config.py | 7 ++++++-
maillib/email.py | 5 ++++-
3 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/data/config.cfg b/data/config.cfg
index 44f4e3a..f4e8f72 100644
--- a/data/config.cfg
+++ b/data/config.cfg
@@ -15,7 +15,8 @@ description_regex = .*[fF]inal evaluation deadline.*
[FOO]
type = mail_template
path = data/templates/foo
-when = FINAL_EVALS - 3d
+related_to = FINAL_EVALS
+days_before = 3
sender = lasse schuirmann gmail com
recipients = GSoC_Students
recipients_mail_column = mail
diff --git a/maillib/config.py b/maillib/config.py
index 2d156db..e6e5eb2 100644
--- a/maillib/config.py
+++ b/maillib/config.py
@@ -6,6 +6,7 @@ import csv
import re
from ics import Calendar
from urllib import request
+from datetime import timedelta
from maillib.email import Contact, EmailTemplate
@@ -89,8 +90,12 @@ class EventConfig:
name = row.get(recipients_name_column, None)
recipients.append(Contact(mail, name))
+ days_before = int(section.get('days_before', '0'))
+ related_to = self.dates[section['related_to']].begin
+ related_to -= timedelta(days=days_before)
+
self.mail_templates.append(
- EmailTemplate(text, sender, recipients, cc, bcc))
+ EmailTemplate(text, sender, recipients, cc, bcc, related_to))
def append_ics_from_section(self, section):
ics_data = get_main_data_from_section(section)
diff --git a/maillib/email.py b/maillib/email.py
index e836c8b..c3b421b 100755
--- a/maillib/email.py
+++ b/maillib/email.py
@@ -31,7 +31,7 @@ class Contact:
class EmailTemplate:
- def __init__(self, text, sender, recipients, cc="", bcc=""):
+ def __init__(self, text, sender, recipients, cc="", bcc="", date=None):
"""
Creates a new mail template.
@@ -40,12 +40,15 @@ class EmailTemplate:
:param recipients: A list of Contact objects.
:param cc: The mail adress(es) to CC (string).
:param bcc: The mail adress(es) to BCC (string).
+ :param date: An Arrow object indicating when this template is to
+ be sent.
"""
self.text = text
self.sender = sender
self.recipients = recipients
self.cc = cc
self.bcc = bcc
+ self.date = date
def get_specific(self, data_dict):
"""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]