This repository has been archived by the owner on Mar 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* email_controller: Remove static mailer templates Abstract email count Professor dynamic email Dynamically build email Add email description for ASC Add description to emails Only create emails if they're not already in the database Database email seeds Cleanup scaffold Scaffold dynamic emails controller Email professors on email change
- Loading branch information
Showing
30 changed files
with
400 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Place all the behaviors and hooks related to the matching controller here. | ||
// All this logic will automatically be available in application.js. |
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,3 @@ | ||
// Place all the styles related to the emails controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
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,35 @@ | ||
class EmailsController < ApplicationController | ||
before_action :signed_in_admin | ||
before_action :set_email, only: [:show, :edit, :update, :destroy] | ||
|
||
# GET /emails | ||
def index | ||
@emails = Email.all | ||
end | ||
|
||
# GET /emails/1 | ||
def show | ||
end | ||
|
||
# GET /emails/1/edit | ||
def edit | ||
end | ||
|
||
# PATCH/PUT /emails/1 | ||
def update | ||
if @email.update(email_params) | ||
redirect_to @email, notice: 'Email was successfully updated.' | ||
else | ||
render action: 'edit' | ||
end | ||
end | ||
|
||
private | ||
def set_email | ||
@email = Email.find(params[:id]) | ||
end | ||
|
||
def email_params | ||
params.require(:email).permit(:body, :subject, :reply_to) | ||
end | ||
end |
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 |
---|---|---|
@@ -1,13 +1,25 @@ | ||
class ApplicantMailer < ActionMailer::Base | ||
# TODO: Fix these email from addresses | ||
default from: 'from@example.com', | ||
reply_to: 'foo@example.com' | ||
default from: 'from@example.com' | ||
# reply_to: 'foo@example.com' | ||
|
||
def account_email(user) | ||
@count = user.positions.count | ||
email_identifier = self.class.name + ':' + __method__.to_s | ||
email_template = Email.find_by_identifier(email_identifier) | ||
return unless email_template | ||
|
||
# @count = user.positions.count | ||
@name = user.name | ||
@link = applicant_url(user) | ||
@url = applicant_url(user) | ||
|
||
body = email_template.body.dup | ||
body.gsub!(/\[NAME\]/i, @name) | ||
body.gsub!(/\[URL\]/i, @url) | ||
email = user.email + EMAIL_SUFFIX | ||
mail to: email, subject: 'Your ASC tutoring application' | ||
mail(to: email, | ||
body: body, | ||
content_type: 'text/plain', | ||
subject: email_template.subject, | ||
reply_to: email_template.reply_to) | ||
end | ||
end |
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 |
---|---|---|
@@ -1,13 +1,25 @@ | ||
class ProfessorMailer < ActionMailer::Base | ||
# TODO: Fix these email from addresses | ||
default from: 'from@example.com', | ||
reply_to: 'foo@example.com' | ||
default from: 'from@example.com' | ||
# reply_to: 'foo@example.com' | ||
|
||
def pending_recommendation(professor) | ||
@count = professor.positions.count | ||
email_identifier = self.class.name + ':' + __method__.to_s | ||
email_template = Email.find_by_identifier(email_identifier) | ||
return unless email_template | ||
|
||
# @count = user.positions.count | ||
@name = professor.name | ||
@link = professor_url(professor) | ||
@url = professor_url(professor) | ||
|
||
body = email_template.body.dup | ||
body.gsub!(/\[NAME\]/i, @name) | ||
body.gsub!(/\[URL\]/i, @url) | ||
email = professor.email + EMAIL_SUFFIX | ||
mail to: email, subject: 'Pending ASC tutoring recommendation' | ||
mail(to: email, | ||
body: body, | ||
content_type: 'text/plain', | ||
subject: email_template.subject, | ||
reply_to: email_template.reply_to) | ||
end | ||
end |
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,2 @@ | ||
class Email < ActiveRecord::Base | ||
end |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,29 @@ | ||
<%= form_for(@email) do |f| %> | ||
<% if @email.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(@email.errors.count, "error") %> prohibited this email from being saved:</h2> | ||
|
||
<ul> | ||
<% @email.errors.full_messages.each do |msg| %> | ||
<li><%= msg %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= f.label :body %><br> | ||
<%= f.text_area :body %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :subject %><br> | ||
<%= f.text_field :subject %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :reply_to %><br> | ||
<%= f.text_field :reply_to %> | ||
</div> | ||
<div class="actions"> | ||
<%= f.submit %> | ||
</div> | ||
<% end %> |
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,6 @@ | ||
<h1>Editing email</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Show', @email %> | | ||
<%= link_to 'Back', emails_path %> |
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,28 @@ | ||
<h1>Listing emails</h1> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>Description</th> | ||
<th>Body</th> | ||
<th>Subject</th> | ||
<th>Reply to</th> | ||
<th></th> | ||
<th></th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<% @emails.each do |email| %> | ||
<tr> | ||
<td><%= email.description %></td> | ||
<td><%= email.body %></td> | ||
<td><%= email.subject %></td> | ||
<td><%= email.reply_to %></td> | ||
<td><%= link_to 'Show', email %></td> | ||
<td><%= link_to 'Edit', edit_email_path(email) %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> |
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,19 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<p> | ||
<strong>Body:</strong> | ||
<%= @email.body %> | ||
</p> | ||
|
||
<p> | ||
<strong>Subject:</strong> | ||
<%= @email.subject %> | ||
</p> | ||
|
||
<p> | ||
<strong>Reply to:</strong> | ||
<%= @email.reply_to %> | ||
</p> | ||
|
||
<%= link_to 'Edit', edit_email_path(@email) %> | | ||
<%= link_to 'Back', emails_path %> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,12 @@ | ||
class CreateEmails < ActiveRecord::Migration | ||
def change | ||
create_table :emails do |t| | ||
t.text :body | ||
t.string :subject | ||
t.string :reply_to | ||
t.string :identifier | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
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,5 @@ | ||
class AddDescriptionToEmails < ActiveRecord::Migration | ||
def change | ||
add_column :emails, :description, :string | ||
end | ||
end |
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,5 @@ | ||
require 'spec_helper' | ||
|
||
describe Email do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
end |
Oops, something went wrong.