Skip to content
This repository has been archived by the owner on Aug 17, 2022. It is now read-only.

Commit

Permalink
Add Emails for submission approval process (#47)
Browse files Browse the repository at this point in the history
* emails working with template, needs refactoring

* fixing path

* fixing relative path reference

* diff template files for diff emails

* refactoring some stuff

* removing hardcoded email

* reverting db file

* reverting build file

* approval email

* changed email settings to db table pulled from config file. Code needs refactoring so that there aren't two files with dbconnections open

* updated tempaltes
  • Loading branch information
shanaxel42 authored and csweaver committed Oct 24, 2018
1 parent ad6017e commit 89fdfbf
Show file tree
Hide file tree
Showing 11 changed files with 5,413 additions and 1,292 deletions.
16 changes: 16 additions & 0 deletions database/BuildDatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class User(Base):
is_admin = Column(Boolean, nullable=False)
create_date = Column(DateTime, nullable=False, server_default=func.now())


class Challenge(Base):
__tablename__ = 'challenges'
__table_args__ = {'extend_existing': True}
Expand Down Expand Up @@ -90,6 +91,14 @@ class Result(Base):
submission_date = Column(DateTime, nullable=False, server_default=func.now())
create_date = Column(DateTime, nullable=False, server_default=func.now())

class AdminEmailSettings(Base):
__tablename__ = 'email_settings'
__table_args__ = {'extend_existing': True}
id = Column(Integer, primary_key=True, nullable=False)
email_provider = Column(String, nullable=False)
email_address = Column(String, nullable=False)
email_pass = Column(String, nullable=False)

Base.metadata.create_all(engine)


Expand All @@ -116,6 +125,13 @@ class Result(Base):
for admin in initialize_data["admins"]:
new_user = User(github_username=admin, is_admin=True)
session.add(new_user)

email_settings = initialize_data["email_settings"]
settings = AdminEmailSettings(email_provider=email_settings["email_provider"],
email_address= email_settings["admin_email"],
email_pass=email_settings["admin_pass"])
session.add(settings)

session.commit()


Expand Down
13 changes: 13 additions & 0 deletions email_templates/approvedEmail/html.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<html>
<head>
</head>
<body>
<div style="margin:0 auto;max-width:600px;">
<p>Hi, <%= userName %></p></br>
Congratulations! Your submission to Scorebaord has been approved.
</br></br>
Thank you, <br>
<a href=" https://github.com/chanzuckerberg/scoreboard">The Scoreboard Team</a>
</div>
</body>
</html>
13 changes: 13 additions & 0 deletions email_templates/submissionEmail/html.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<html>
<head>
</head>
<body>
<div style="margin:0 auto;max-width:600px;">
<p>Hi, <%= userName %></p></br>
Your solution to Scoreboard has been submitted and is in review. We will send you an email when your submission has been approved.
</br></br>
Thank you, <br>
<a href=" https://github.com/chanzuckerberg/scoreboard">The Scoreboard Team</a>
</div>
</body>
</html>
10 changes: 10 additions & 0 deletions email_templates/submissionToReviewEmail/html.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html>
<head>
</head>
<body>
<div style="margin:0 auto;max-width:600px;">
<p>There is a new Scoreboard submission that needs to be reviewed.</p></br>
Thank you, <br>
<a href=" https://github.com/chanzuckerberg/scoreboard">The Scoreboard Team</a>
</div>
</body>
Loading

0 comments on commit 89fdfbf

Please sign in to comment.