-
Notifications
You must be signed in to change notification settings - Fork 3
Mailer #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
THEJRRR
wants to merge
9
commits into
psytau:master
Choose a base branch
from
THEJRRR:76281698
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Mailer #19
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5868590
#76281698 created skeleton for mailers. Added DB to track mail messag…
THEJRRR f1d1be0
#76281698 Added to User model for mailer prefereces. Added logic to t…
THEJRRR eb486e9
#76281698 Added sumary incriment to user model. Completed the mailer …
THEJRRR 08b0592
#76281698 Added summary emailer. Will need the cron job added to heroku.
THEJRRR 2e1bd58
#76281698 Added usere mailer prefeces and added the invite form for u…
THEJRRR d15733a
pulled upstream master
THEJRRR d453857
Stashing chnages to solr to merge
THEJRRR a68435d
#76281698 Added seed information and image upload/display for books
THEJRRR f84a156
#76281698 added cucumber mailer tests
THEJRRR File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,11 @@ | ||
require 'transactional_mailer' | ||
|
||
class InviteController < ApplicationController | ||
|
||
def create | ||
tm = TransactionalMailer.new | ||
tm.send_mail(params[:email], 1) | ||
redirect_to "/" | ||
end | ||
|
||
end |
This file contains hidden or 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,7 @@ | ||
class RegistrationsController < Devise::RegistrationsController | ||
|
||
def account_update_params | ||
params.require(:user).permit(:email, :password, :password_confirmation, :current_password, | ||
:rate_email, :review_email, :daily_summary) | ||
end | ||
end |
This file contains hidden or 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,30 @@ | ||
require 'mandrill' | ||
|
||
def summary_mailer | ||
users = User.where(daily_summary: true) | ||
users.each do |variable| | ||
# cycle through rate & review summaries to see if either is > 0 | ||
if user.rate_email_summary > 0 || user.review_email_summary > 0 | ||
# create string email | ||
|
||
email_text = "You have had " + user.rate_email_summary + " books rated and " + user.review_email_summary + | ||
" books reviewed today. Please, login to see what people have to say!" | ||
# place values in email | ||
m = Mandrill::API.new ENV['MANDRILL_APIKEY'] | ||
|
||
message = { | ||
:subject=> "Rated and Reviewed Books on RailsBookCheckout", | ||
:from_name=> "RailsBookCheckout", | ||
:from_email=>"[email protected]", | ||
:to=>[ | ||
{:email => user.email} | ||
], | ||
:text=> email_text | ||
} | ||
sending = m.messages.send message | ||
|
||
user.rate_email_summary = 0 | ||
user.review_email_summary = 0 | ||
user.save | ||
end | ||
end |
This file contains hidden or 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,44 @@ | ||
require 'mandrill' | ||
|
||
class TransactionalMailer | ||
|
||
def send_mail ( recipient_email, trigger_id ) | ||
|
||
trigger_event = TriggerEvent.find_by(id: trigger_id) | ||
|
||
m = Mandrill::API.new ENV['MANDRILL_APIKEY'] | ||
|
||
message = { | ||
:subject=> trigger_event.subject, | ||
:from_name=> "Ruby Book Checkout", | ||
:from_email=>"[email protected]", | ||
:to=>[ | ||
{:email => recipient_email } | ||
], | ||
:text=> trigger_event.text | ||
} | ||
|
||
sending = m.messages.send message | ||
end | ||
|
||
|
||
def user_mailer ( user_email, trigger_id ) | ||
puts user_email | ||
user = User.find_by(id: user_email) | ||
if trigger_id == 2 | ||
if user.review_email && user.daily_summary == false | ||
self.send_mail(user.email, trigger_id) | ||
elsif user.review_email && user.daily_summary | ||
@user.incriment!(:review_email_summary) | ||
end | ||
elsif trigger_id == 3 | ||
if user.rate_email && user.daily_summary == false | ||
self.send_mail(user.email, trigger_id) | ||
elsif user.rate_email && user.daily_summary | ||
@user.increment!(:rate_email_summary) | ||
end | ||
else | ||
self.send_mail(user.email, trigger_id) | ||
end | ||
end | ||
end |
Empty file.
This file contains hidden or 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 TriggerEvent < ActiveRecord::Base | ||
end |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,9 @@ | ||
<%= form_tag do %> | ||
<div class="field"> | ||
<%= label_tag "Email" %> | ||
<%= email_field_tag(:email, "Email") %> | ||
</div> | ||
<div class="actions"> | ||
<%= submit_tag("Invite") %> | ||
</div> | ||
<% end %> |
This file contains hidden or 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,7 @@ | ||
<div class="container"> | ||
|
||
<h1>Invite your friends!</h1> | ||
|
||
<%= render 'form' %> | ||
|
||
</div> |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 @@ | ||
MandrillMailer.configure do |config| | ||
config.api_key = ENV['MANDRILL_APIKEY'] | ||
end |
This file contains hidden or 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,28 +1,15 @@ | ||
Rails.application.routes.draw do | ||
get 'admin/users' | ||
get 'admin/make_admin' | ||
get 'admin/user_can_review' | ||
get 'admin/books' | ||
get 'admin/can_do' | ||
get 'admin/users_report' | ||
get 'admin/view_as_user/:view_as_user', to: 'admin#view_as_user' | ||
get 'admin/view_as_self', to: 'admin#view_as_self' | ||
|
||
resources :book_reviews | ||
|
||
devise_for :users | ||
|
||
devise_for :users, :controllers => { registrations: 'registrations' } | ||
root to: 'home#index' | ||
|
||
get 'books/search', to: 'books#index' | ||
|
||
match 'books/deactivate/:id', to: 'books#toggle_activation', via: :get | ||
|
||
resources :books | ||
|
||
resources :ratings | ||
|
||
resources :followers | ||
resources :invite | ||
|
||
mount Attachinary::Engine => "/attachinary" | ||
end |
This file contains hidden or 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,10 @@ | ||
class CreateTriggerEvents < ActiveRecord::Migration | ||
def change | ||
create_table :trigger_events do |t| | ||
t.string :subject | ||
t.text :text | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains hidden or 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,7 @@ | ||
class AddReviewEmailToUsers < ActiveRecord::Migration | ||
def change | ||
add_column :users, :rate_email, :boolean | ||
add_column :users, :review_email, :boolean | ||
add_column :users, :daily_summary, :boolean | ||
end | ||
end |
This file contains hidden or 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,13 @@ | ||
class SetDefault < ActiveRecord::Migration | ||
def up | ||
change_column :users, :rate_email, :boolean, :default => 1 | ||
change_column :users, :review_email, :boolean, :default => 1 | ||
change_column :users, :daily_summary, :boolean, :default => 0 | ||
end | ||
|
||
def down | ||
change_column :users, :rate_email, :boolean | ||
change_column :users, :review_email, :boolean | ||
change_column :users, :daily_summary, :boolean | ||
end | ||
end |
This file contains hidden or 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,7 @@ | ||
class AddSummaryEmailToUser < ActiveRecord::Migration | ||
def change | ||
add_column :users, :rate_email_summary, :integer, :default => 0 | ||
add_column :users, :review_email_summary, :integer, :default => 0 | ||
end | ||
end | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
puts !