Skip to content

Commit 3a5410e

Browse files
authored
Merge pull request #707 from code-corps/add-project-acceptance-email
WIP Add project acceptance email
2 parents ee13cfd + 2682063 commit 3a5410e

File tree

19 files changed

+292
-31
lines changed

19 files changed

+292
-31
lines changed

.github/CONTRIBUTING.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,3 @@ We've written some convenience helper modules and functions to help with API tes
193193
- `CodeCorps.ApiCase` - used to simplify testing JSON API endpoints
194194
- `CodeCorps.AuthenticationTestHelpers` - provides authentication helpers for authenticating a `conn`
195195
- `CodeCorps.Factories` - provides factories using [`ex_machina`](https://github.com/thoughtbot/ex_machina), which makes it easy to create test data and associations with Ecto
196-
197-
### Tagged tests
198-
199-
Some tests are tagged like so:
200-
201-
```elixir
202-
@tag :requires_env
203-
```
204-
205-
These tests do not run by default when running `mix test` because you do not have access to the environment variables listed in `.env.example` by default.
206-
207-
To read more about the environment variables, see the "Environment" section of our [usage docs](USAGE.md#environment).

circle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test:
1717
if [ ${CIRCLE_PR_USERNAME} ]; then
1818
MIX_ENV=test mix test;
1919
else
20-
MIX_ENV=test mix coveralls.circle --include requires_env;
20+
MIX_ENV=test mix coveralls.circle;
2121
fi
2222
post:
2323
- mix inch.report

config/dev.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ config :code_corps, CodeCorps.Mailer,
6060
adapter: Bamboo.LocalAdapter
6161

6262
config :code_corps,
63+
postmark_project_acceptance_template: "123",
6364
postmark_receipt_template: "123"
6465

6566
# If the dev environment has no CLOUDEX_API_KEY set, we want the app

config/prod.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ config :code_corps, CodeCorps.Mailer,
6161
api_key: System.get_env("POSTMARK_API_KEY")
6262

6363
config :code_corps,
64+
postmark_project_acceptance_template: "1447041",
6465
postmark_receipt_template: "1255222"
6566

6667
# ## SSL Support

config/remote-development.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ config :code_corps, CodeCorps.Mailer,
4343
adapter: Bamboo.LocalAdapter
4444

4545
config :code_corps,
46+
postmark_project_acceptance_template: "123",
4647
postmark_receipt_template: "123"
4748

4849
# ## SSL Support

config/staging.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ config :code_corps, CodeCorps.Mailer,
5959
api_key: System.get_env("POSTMARK_API_KEY")
6060

6161
config :code_corps,
62+
postmark_project_acceptance_template: "1447022",
6263
postmark_receipt_template: "1252361"
6364

6465
# ## SSL Support

config/test.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ config :code_corps, CodeCorps.Mailer,
4848
adapter: Bamboo.TestAdapter
4949

5050
config :code_corps,
51+
postmark_project_acceptance_template: "123",
5152
postmark_receipt_template: "123"
5253

5354
config :code_corps, :cloudex, CloudexTest
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
<head>
4+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
5+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6+
<title>{{project_title}} just added you as a contributor</title>
7+
<!--
8+
Make sure you copy the styles from styles.css into the email template in Postmark before saving there.
9+
10+
<style type="text/css" rel="stylesheet" media="all">
11+
</style>
12+
-->
13+
<link rel="stylesheet" type="text/css" href="styles.css" media="screen" />
14+
</head>
15+
<body>
16+
<span class="preheader">See what you can do to help on {{project_title}}.</span>
17+
<table class="email-wrapper" width="100%" cellpadding="0" cellspacing="0">
18+
<tr>
19+
<td align="center">
20+
<table class="email-content" width="100%" cellpadding="0" cellspacing="0">
21+
<tr>
22+
<td class="email-masthead" width="100%" cellpadding="0" cellspacing="0">
23+
<table class="email-masthead_inner" align="center" width="570" cellpadding="0" cellspacing="0">
24+
<tr>
25+
<td>
26+
<a href="https://www.codecorps.org">
27+
<img src="https://d3pgew4wbk2vb1.cloudfront.net/emails/images/logo-small@2x.png" class="email-masthead_logo" />
28+
</a>
29+
</td>
30+
</tr>
31+
</table>
32+
</td>
33+
</tr>
34+
<!-- Email Body -->
35+
<tr>
36+
<td class="email-body" width="100%" cellpadding="0" cellspacing="0">
37+
<table class="email-body_inner" align="center" width="570" cellpadding="0" cellspacing="0">
38+
<!-- Body content -->
39+
<tr>
40+
<td class="content-cell">
41+
<table class="donation" width="100%" cellpadding="0" cellspacing="0">
42+
<tr>
43+
<td>
44+
<ul class="joined_images center">
45+
<li class="photo">
46+
<img src="{{user_image_url}}" width="70" height="70" />
47+
</li>
48+
<li class="icon">
49+
<img src="https://d3pgew4wbk2vb1.cloudfront.net/emails/images/joined-email@2x.png" width="25" height="70" />
50+
</li>
51+
<li class="photo">
52+
<img src="{{project_logo_url}}" width="70" height="70" />
53+
</li>
54+
</ul>
55+
<p class="project-membership--accepted">
56+
<strong>{{user_first_name}}</strong>, you're in!
57+
</p>
58+
<p>
59+
<a href="{{project_url}}">{{project_title}}</a> just accepted your request to start contributing.
60+
</p>
61+
<p>Go check out the project and see what you can do to get started.
62+
</p>
63+
</tr>
64+
</td>
65+
</table>
66+
<table class="body-signature">
67+
<tr>
68+
<td>
69+
<p>
70+
Happy helping!
71+
<br><strong>The Code Corps Team</strong>
72+
</p>
73+
<p class="center small">
74+
Questions? Feedback?
75+
<br>Visit our <strong><a href="https://help.codecorps.org">Help Center</a></strong> or just reply to this email.</p>
76+
</td>
77+
</tr>
78+
</table>
79+
</td>
80+
</tr>
81+
</table>
82+
</td>
83+
</tr>
84+
<tr>
85+
<td>
86+
<table class="email-footer" align="center" width="570" cellpadding="0" cellspacing="0">
87+
<tr>
88+
<td class="content-cell" align="center">
89+
<p class="sub align-center">
90+
Code Corps PBC
91+
<br>4166 Wilson Ave #1
92+
<br>San Diego, CA 92104
93+
</p>
94+
</td>
95+
</tr>
96+
</table>
97+
</td>
98+
</tr>
99+
</table>
100+
</td>
101+
</tr>
102+
</table>
103+
</body>
104+
</html>

emails/styles.css

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,37 @@ td {
230230
text-align: center;
231231
}
232232

233+
/* Project joining -------------------------------- */
234+
235+
.joined_images {
236+
height: 70px;
237+
margin: 0 0 30px 0;
238+
padding: 0;
239+
text-align: center;
240+
width: 100%;
241+
}
242+
243+
.joined_images li {
244+
display: inline-block;
245+
}
246+
247+
.joined_images li.icon {
248+
margin: 0 5px;
249+
width: 25px;
250+
}
251+
252+
.joined_images li.photo {
253+
width: 70px;
254+
}
255+
256+
.joined_images li.photo img {
257+
border-radius: 4px;
258+
}
259+
260+
.joined_images li:first-child {
261+
/*margin-left: 300px;*/
262+
}
263+
233264
/* Data table ------------------------------ */
234265

235266
.purchase {
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
defmodule CodeCorps.Emails.ProjectUserAcceptanceEmail do
2+
import Bamboo.Email
3+
import Bamboo.PostmarkHelper
4+
5+
alias CodeCorps.{Project, ProjectUser, Repo, User}
6+
alias CodeCorps.Emails.BaseEmail
7+
alias CodeCorps.Presenters.ImagePresenter
8+
9+
def create(%ProjectUser{project: project, user: user}) do
10+
BaseEmail.create
11+
|> to(user.email)
12+
|> template(template_id(), build_model(project, user))
13+
end
14+
15+
defp build_model(%Project{} = project, %User{} = user) do
16+
%{
17+
project_logo_url: ImagePresenter.large(project),
18+
project_title: project.title,
19+
project_url: project |> preload() |> url(),
20+
subject: "#{project.title} just added you as a contributor",
21+
user_first_name: user.first_name,
22+
user_image_url: ImagePresenter.large(user)
23+
}
24+
end
25+
26+
defp preload(%Project{} = project), do: project |> Repo.preload(:organization)
27+
28+
defp url(project) do
29+
Application.get_env(:code_corps, :site_url)
30+
|> URI.merge(project.organization.slug <> "/" <> project.slug)
31+
|> URI.to_string
32+
end
33+
34+
defp template_id, do: Application.get_env(:code_corps, :postmark_project_acceptance_template)
35+
end

0 commit comments

Comments
 (0)