-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add Projects context module - Add tracking for created, requested approval, approved - Add boolean on model for indicating if a project has requested approval - Add project approval request email - Add project approved email - Clarify the template config vars
- Loading branch information
Showing
27 changed files
with
659 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | ||
<title>{{project_title}} is asking to be approved</title> | ||
<!-- | ||
Make sure you copy the styles from styles.css into the email template in Postmark before saving there. | ||
<style type="text/css" rel="stylesheet" media="all"> | ||
</style> | ||
--> | ||
<link rel="stylesheet" type="text/css" href="styles.css" media="screen" /> | ||
</head> | ||
<body> | ||
<span class="preheader">Head over to the app to process their request.</span> | ||
<table class="email-wrapper" width="100%" cellpadding="0" cellspacing="0"> | ||
<tr> | ||
<td align="center"> | ||
<table class="email-content" width="100%" cellpadding="0" cellspacing="0"> | ||
<tr> | ||
<td class="email-masthead" width="100%" cellpadding="0" cellspacing="0"> | ||
<table class="email-masthead_inner" align="center" width="570" cellpadding="0" cellspacing="0"> | ||
<tr> | ||
<td> | ||
<a href="https://www.codecorps.org"> | ||
<img src="https://d3pgew4wbk2vb1.cloudfront.net/emails/images/logo-small@2x.png" class="email-masthead_logo" /> | ||
</a> | ||
</td> | ||
</tr> | ||
</table> | ||
</td> | ||
</tr> | ||
<!-- Email Body --> | ||
<tr> | ||
<td class="email-body" width="100%" cellpadding="0" cellspacing="0"> | ||
<table class="email-body_inner" align="center" width="570" cellpadding="0" cellspacing="0"> | ||
<!-- Body content --> | ||
<tr> | ||
<td class="content-cell"> | ||
<table class="donation" width="100%" cellpadding="0" cellspacing="0"> | ||
<tr> | ||
<td> | ||
<p> | ||
Hi Code Corps team, | ||
</p> | ||
<p> | ||
<strong>{{project_title}}</strong> is asking to have their project approved. | ||
</p> | ||
</td> | ||
</tr> | ||
</table> | ||
<table class="donation" width="100%" cellpadding="0" cellspacing="0"> | ||
<tr> | ||
<td> | ||
<tr> | ||
<td> | ||
<p> | ||
<p class="center"> | ||
<img src="{{project_logo_url}}" width="70" height="70" /> | ||
</p> | ||
<p class="center"> | ||
<strong>{{project_title}}</strong> | ||
</p> | ||
</p> | ||
<p class="center"> | ||
{{project_description}} | ||
</p> | ||
<td> | ||
</tr> | ||
</tr> | ||
</td> | ||
</table> | ||
<table class="donation" width="100%" cellpadding="0" cellspacing="0"> | ||
<tr> | ||
<td> | ||
<p> | ||
You can head over to <a href="{{admin_project_show_url}}">the admin page for the project</a> to process their request. | ||
</p> | ||
<p> | ||
You can also take a look at <a href="{{project_url}}">their project on Code Corps</a> to see it how users will see it. | ||
</p> | ||
</td> | ||
</tr> | ||
</table> | ||
<table class="body-signature"> | ||
<tr> | ||
<td> | ||
<p> | ||
Cheers, | ||
<br><strong>🤖 The Code Corps Robots</strong> | ||
</p> | ||
</td> | ||
</tr> | ||
</table> | ||
</td> | ||
</tr> | ||
</table> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
<table class="email-footer" align="center" width="570" cellpadding="0" cellspacing="0"> | ||
<tr> | ||
<td class="content-cell" align="center"> | ||
<p class="sub align-center"> | ||
Code Corps PBC | ||
<br>4166 Wilson Ave #1 | ||
<br>San Diego, CA 92104 | ||
</p> | ||
</td> | ||
</tr> | ||
</table> | ||
</td> | ||
</tr> | ||
</table> | ||
</td> | ||
</tr> | ||
</table> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | ||
<title>{{project_title}} is approved!</title> | ||
<!-- | ||
Make sure you copy the styles from styles.css into the email template in Postmark before saving there. | ||
<style type="text/css" rel="stylesheet" media="all"> | ||
</style> | ||
--> | ||
<link rel="stylesheet" type="text/css" href="styles.css" media="screen" /> | ||
</head> | ||
<body> | ||
<span class="preheader">Head over to the app to get started.</span> | ||
<table class="email-wrapper" width="100%" cellpadding="0" cellspacing="0"> | ||
<tr> | ||
<td align="center"> | ||
<table class="email-content" width="100%" cellpadding="0" cellspacing="0"> | ||
<tr> | ||
<td class="email-masthead" width="100%" cellpadding="0" cellspacing="0"> | ||
<table class="email-masthead_inner" align="center" width="570" cellpadding="0" cellspacing="0"> | ||
<tr> | ||
<td> | ||
<a href="https://www.codecorps.org"> | ||
<img src="https://d3pgew4wbk2vb1.cloudfront.net/emails/images/logo-small@2x.png" class="email-masthead_logo" /> | ||
</a> | ||
</td> | ||
</tr> | ||
</table> | ||
</td> | ||
</tr> | ||
<!-- Email Body --> | ||
<tr> | ||
<td class="email-body" width="100%" cellpadding="0" cellspacing="0"> | ||
<table class="email-body_inner" align="center" width="570" cellpadding="0" cellspacing="0"> | ||
<!-- Body content --> | ||
<tr> | ||
<td class="content-cell"> | ||
<table width="100%" cellpadding="0" cellspacing="0"> | ||
<tr> | ||
<td> | ||
<p class="center"> | ||
<img src="https://d3pgew4wbk2vb1.cloudfront.net/emails/images/party@2x.png" width="100" height="100" /> | ||
</p> | ||
<p> | ||
Hi {{project_title}} team, | ||
</p> | ||
<p> | ||
Congratulations, your project was just approved! | ||
</p> | ||
<p> | ||
You can head over to <a href="{{project_url}}">your project</a> now to see it live and are free to share your project link: | ||
</p> | ||
<p> | ||
<a href="{{project_url}}">{{project_url}}</a> | ||
</p> | ||
</td> | ||
</tr> | ||
</table> | ||
<table class="body-signature"> | ||
<tr> | ||
<td> | ||
<p> | ||
Cheers, | ||
<br><strong>The Code Corps Team</strong> | ||
</p> | ||
<p class="center small"> | ||
Questions? Feedback? | ||
<br>Visit our <strong><a href="https://help.codecorps.org">Help Center</a></strong> or just reply to this email.</p> | ||
</td> | ||
</tr> | ||
</table> | ||
</td> | ||
</tr> | ||
</table> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
<table class="email-footer" align="center" width="570" cellpadding="0" cellspacing="0"> | ||
<tr> | ||
<td class="content-cell" align="center"> | ||
<p class="sub align-center"> | ||
Code Corps PBC | ||
<br>4166 Wilson Ave #1 | ||
<br>San Diego, CA 92104 | ||
</p> | ||
</td> | ||
</tr> | ||
</table> | ||
</td> | ||
</tr> | ||
</table> | ||
</td> | ||
</tr> | ||
</table> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,7 @@ td { | |
|
||
.email-masthead_inner { | ||
padding: 10px 0; | ||
text-align: center; | ||
} | ||
|
||
.email-masthead_logo { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
defmodule CodeCorps.Emails.ProjectApprovalRequestEmail do | ||
import Bamboo.Email, only: [to: 2] | ||
import Bamboo.PostmarkHelper | ||
import Ecto.Query, only: [where: 3] | ||
|
||
alias CodeCorps.{Project, Repo, User, WebClient} | ||
alias CodeCorps.Emails.BaseEmail | ||
alias CodeCorps.Presenters.ImagePresenter | ||
|
||
@spec create(Project.t) :: Bamboo.Email.t | ||
def create(%Project{} = project) do | ||
BaseEmail.create | ||
|> to(get_site_admins_emails()) | ||
|> template(template_id(), build_model(project)) | ||
end | ||
|
||
@spec build_model(Project.t) :: map | ||
defp build_model(%Project{} = project) do | ||
%{ | ||
admin_project_show_url: project |> admin_url(), | ||
project_description: project.description, | ||
project_logo_url: ImagePresenter.large(project), | ||
project_title: project.title, | ||
project_url: project |> preload() |> project_url(), | ||
subject: "#{project.title} is asking to be approved" | ||
} | ||
end | ||
|
||
@spec preload(Project.t) :: Project.t | ||
defp preload(%Project{} = project), do: project |> Repo.preload(:organization) | ||
|
||
@spec admin_url(Project.t) :: String.t | ||
defp admin_url(project) do | ||
WebClient.url() | ||
|> URI.merge("/admin/projects/" <> Integer.to_string(project.id)) | ||
|> URI.to_string() | ||
end | ||
|
||
@spec project_url(Project.t) :: String.t | ||
defp project_url(project) do | ||
WebClient.url() | ||
|> URI.merge(project.organization.slug <> "/" <> project.slug) | ||
|> URI.to_string() | ||
end | ||
|
||
@spec template_id :: String.t | ||
defp template_id, do: Application.get_env(:code_corps, :postmark_project_approval_request_template) | ||
|
||
@spec get_site_admins_emails() :: list(String.t) | ||
defp get_site_admins_emails() do | ||
get_site_admins() |> Enum.map(&extract_email/1) | ||
end | ||
|
||
@spec extract_email(User.t) :: String.t | ||
defp extract_email(%User{email: email}), do: email | ||
|
||
@spec get_site_admins() :: list(User.t) | ||
defp get_site_admins() do | ||
User | ||
|> where([object], object.admin == true) | ||
|> Repo.all() | ||
end | ||
end |
Oops, something went wrong.