Commit 7acce55c authored by Matthieu Boileau's avatar Matthieu Boileau
Browse files

notify expiration_date for job_offer (#57)

parent 53fc881e
...@@ -3,7 +3,7 @@ Date: 2019-04-08 14:53 ...@@ -3,7 +3,7 @@ Date: 2019-04-08 14:53
Slug: job_45a72ce310de2158697917bc80a56b77 Slug: job_45a72ce310de2158697917bc80a56b77
Category: job Category: job
Authors: Roland Authors: Roland
Email: Email: roland.denis@math.univ-lyon1.fr
Job_Type: CDD Job_Type: CDD
Tags: cdd Tags: cdd
Template: job_offer Template: job_offer
...@@ -14,4 +14,4 @@ Job_Employer: CNRS ...@@ -14,4 +14,4 @@ Job_Employer: CNRS
Expiration_Date: 2019-04-09 Expiration_Date: 2019-04-09
Attachment: Attachment:
Il faut candidater très vite, cette offre disparaîtra demain \! Il faut candidater très vite, cette offre disparaîtra demain \!
\ No newline at end of file
...@@ -53,18 +53,19 @@ class Message: ...@@ -53,18 +53,19 @@ class Message:
with open(filepath) as f: with open(filepath) as f:
s = f.read() s = f.read()
# TODO: When expire_date will be in job_*.md file m = re.search(r"^Authors: (.*)$", s, re.MULTILINE)
# m = re.search("Date: (.*)$", s, re.MULTILINE)
# date = m.group(1)
# expire_date to format...
m = re.search("Authors: (.*)$", s, re.MULTILINE)
self.author_name = m.group(1).title() self.author_name = m.group(1).title()
m = re.search("Email: (.*)$", s, re.MULTILINE) m = re.search(r"^Email: (.*)$", s, re.MULTILINE)
self.author_email = m.group(1) self.author_email = m.group(1)
m = re.search("Job_Type: (.*)$", s, re.MULTILINE) m = re.search(r"^Job_Type: (.*)$", s, re.MULTILINE)
self.job_type = m.group(1).lower() self.job_type = m.group(1).lower()
m = re.search("Title: (.*)$", s, re.MULTILINE) m = re.search(r"^Title: (.*)$", s, re.MULTILINE)
self.job_title = m.group(1) self.job_title = m.group(1)
m = re.search(r"^Expiration_Date: (.*)$", s, re.MULTILINE)
if m:
self.expire_date = datetime.datetime.strptime(m.group(1), '%Y-%m-%d')
else:
self.expire_date = datetime.date.today() + datetime.timedelta(days=90)
def get_email_body(self): def get_email_body(self):
"""Virtual function""" """Virtual function"""
...@@ -112,14 +113,10 @@ $PUBLISHER_MESSAGE bureau du groupe Calcul. ...@@ -112,14 +113,10 @@ $PUBLISHER_MESSAGE bureau du groupe Calcul.
self.recipient_email = self.author_email self.recipient_email = self.author_email
def get_email_body(self): def get_email_body(self):
"""Parse job offer md file to build email body""" """Return email body from template"""
expire_date = datetime.date.today() + datetime.timedelta(days=90)
self.d['EXPIRE_DATE'] = '{d.day} {d:%B} {d.year}'.format(d=expire_date)
self.d['EXPIRE_DATE'] = '{d.day} {d:%B} {d.year}'.format(d=self.expire_date)
body = self.template.substitute(self.d) body = self.template.substitute(self.d)
return body return body
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment