This repository has been archived by the owner on Nov 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mandril integrated and working. templates are still an issue.
- Loading branch information
Showing
31 changed files
with
15,868 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
web: puma -C config/puma.rb | grep -v --line-buffered ' 304 -' | ||
worker: sidekiq -C config/sidekiq.yml | ||
worker: bundle exec sidekiq -C config/sidekiq.yml | ||
log: tail -f log/development.log | grep -xv --line-buffered '^[[:space:]]*' | grep -v --line-buffered '/assets/' |
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,6 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: https://coffeescript.org/ | ||
$(document).ready -> | ||
$("#leads").DataTable() | ||
return |
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,3 @@ | ||
// Place all the styles related to the leads controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: https://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,69 @@ | ||
body { | ||
background-color: #fff; | ||
color: #333; | ||
font-family: verdana, arial, helvetica, sans-serif; | ||
font-size: 13px; | ||
line-height: 18px; | ||
} | ||
|
||
p, ol, ul, td { | ||
font-family: verdana, arial, helvetica, sans-serif; | ||
font-size: 13px; | ||
line-height: 18px; | ||
} | ||
|
||
pre { | ||
background-color: #eee; | ||
padding: 10px; | ||
font-size: 11px; | ||
} | ||
|
||
a { | ||
color: #000; | ||
&:visited { | ||
color: #666; | ||
} | ||
&:hover { | ||
color: #fff; | ||
background-color: #000; | ||
} | ||
} | ||
|
||
div { | ||
&.field, &.actions { | ||
margin-bottom: 10px; | ||
} | ||
} | ||
|
||
#notice { | ||
color: green; | ||
} | ||
|
||
.field_with_errors { | ||
padding: 2px; | ||
background-color: red; | ||
display: table; | ||
} | ||
|
||
#error_explanation { | ||
width: 450px; | ||
border: 2px solid red; | ||
padding: 7px; | ||
padding-bottom: 0; | ||
margin-bottom: 20px; | ||
background-color: #f0f0f0; | ||
h2 { | ||
text-align: left; | ||
font-weight: bold; | ||
padding: 5px 5px 5px 15px; | ||
font-size: 12px; | ||
margin: -7px; | ||
margin-bottom: 0px; | ||
background-color: #c00; | ||
color: #fff; | ||
} | ||
ul li { | ||
font-size: 12px; | ||
list-style: square; | ||
} | ||
} |
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,70 @@ | ||
class LeadsController < ApplicationController | ||
before_action :set_lead, only: [:show, :edit, :update, :destroy] | ||
|
||
# GET /leads | ||
def index | ||
@leads = Lead.all | ||
end | ||
|
||
def import | ||
Lead.import(params[:file]) | ||
redirect_to leads_path, notice: "Leads imported." | ||
end | ||
|
||
def email | ||
leads_array = Lead.where(phase: params[:phase]) | ||
leads_array = leads_array.pluck(:id) | ||
CampaignWorker.perform_async(leads_array) | ||
redirect_to leads_path, notice: "Leads scheduled for email." | ||
end | ||
|
||
# GET /leads/1 | ||
def show | ||
end | ||
|
||
# GET /leads/new | ||
def new | ||
@lead = Lead.new | ||
end | ||
|
||
# GET /leads/1/edit | ||
def edit | ||
end | ||
|
||
# POST /leads | ||
def create | ||
@lead = Lead.new(lead_params) | ||
|
||
if @lead.save | ||
redirect_to @lead, notice: 'Lead was successfully created.' | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
# PATCH/PUT /leads/1 | ||
def update | ||
if @lead.update(lead_params) | ||
redirect_to @lead, notice: 'Lead was successfully updated.' | ||
else | ||
render :edit | ||
end | ||
end | ||
|
||
# DELETE /leads/1 | ||
def destroy | ||
@lead.destroy | ||
redirect_to leads_url, notice: 'Lead was successfully destroyed.' | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_lead | ||
@lead = Lead.find(params[:id]) | ||
end | ||
|
||
# Only allow a trusted parameter "white list" through. | ||
def lead_params | ||
params[:lead] | ||
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 @@ | ||
module LeadsHelper | ||
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,8 @@ | ||
class Lead < ActiveRecord::Base | ||
|
||
def self.import(file) | ||
CSV.foreach(file.path, headers: true) do |row| | ||
Lead.create! row.to_hash | ||
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,17 @@ | ||
<%= form_for(@lead) do |f| %> | ||
<% if @lead.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(@lead.errors.count, "error") %> prohibited this lead from being saved:</h2> | ||
|
||
<ul> | ||
<% @lead.errors.full_messages.each do |message| %> | ||
<li><%= message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<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 lead</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Show', @lead %> | | ||
<%= link_to 'Back', leads_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,55 @@ | ||
<h1>Leads</h1> | ||
|
||
<div class=""> | ||
<%= form_tag import_leads_path, class: "form-inline", multipart: true do %> | ||
<div class="input-group"> | ||
<span class="input-group-addon">File:</span> | ||
<%= file_field_tag :file, class: "form-control" %> | ||
</div> | ||
<button type="submit" class="btn btn-default">Submit</button> | ||
<% end %> | ||
<br> | ||
<%= form_tag email_leads_path, class: "form-inline", multipart: true do %> | ||
<div class="input-group"> | ||
<span class="input-group-addon">Phase:</span> | ||
<input type="text" class="form-control" id="phase" name="phase" placeholder="Phase"> | ||
</div> | ||
<button type="submit" class="btn btn-default">Email</button> | ||
<% end %> | ||
</div> | ||
<br> | ||
<br> | ||
<div class=""> | ||
<table id="leads" class="table table-condensed table-hover"> | ||
<thead> | ||
<tr> | ||
<th>Phase</th> | ||
<th>First</th> | ||
<th>Last</th> | ||
<th>Email</th> | ||
<th></th> | ||
<th></th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<% @leads.each do |lead| %> | ||
<tr> | ||
<td><%= lead.phase %></td> | ||
<td><%= lead.first_name %></td> | ||
<td><%= lead.last_name %></td> | ||
<td><%= lead.email %></td> | ||
<td><%= link_to 'Show', lead %></td> | ||
<td><%= link_to 'Edit', edit_lead_path(lead) %></td> | ||
<td><%= link_to 'Destroy', lead, method: :delete, data: { confirm: 'Are you sure?' } %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
</div> | ||
|
||
<br> | ||
|
||
<%= link_to 'New Lead', new_lead_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,5 @@ | ||
<h1>New lead</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Back', leads_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,4 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<%= link_to 'Edit', edit_lead_path(@lead) %> | | ||
<%= link_to 'Back', leads_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,26 @@ | ||
class CampaignWorker | ||
include Sidekiq::Worker | ||
|
||
def perform(leads_array) | ||
require 'mandrill' | ||
@m = Mandrill::API.new(ENV["MANDRILL_API_KEY"]) | ||
leads_array.each do |lead| | ||
@user = Lead.find(lead) | ||
email_lead | ||
sleep(30) | ||
end | ||
end | ||
|
||
def email_lead | ||
template_name = "Beta Announcement" | ||
template_content = [{"name"=>"example name", "content"=>"example content"}] | ||
message = { | ||
:subject=> "Production's About to Change", | ||
:from_name=> "Jeb Coleman", | ||
:from_email=> "[email protected]", | ||
:to=>[{:email=> @user.email}] | ||
} | ||
sending = @m.send_template template_name, template_content, message | ||
puts sending | ||
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
Oops, something went wrong.