Skip to content

Commit

Permalink
say what you wont
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgronlund committed Nov 19, 2015
1 parent b370677 commit 1804abd
Show file tree
Hide file tree
Showing 14 changed files with 150 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 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: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/admin/nudge_user_confirgurations.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the admin/nudge_user_confirgurations controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
20 changes: 20 additions & 0 deletions app/controllers/admin/nudge_user_confirgurations_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class Admin::NudgeUserConfirgurationsController < ApplicationController
def new

UserConfiguration.where( configured: [nil, false]).each do |user_configuration|
if user = user_configuration.user

if ( user_configuration.created_at < Time.now - 24.hours) &&
( user_configuration.say_what_you_want_email_count < 3 )

user_configuration.update_columns(
say_what_you_want_email_count: user_configuration.say_what_you_want_email_count += 1
)
UserMailer.delay.say_what_you_want user.id
end
end
end
redirect_to admin_email_groups_path

end
end
1 change: 1 addition & 0 deletions app/controllers/user/user_configurations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def index

# GET /user_configurations/1/edit
def edit
forbidden unless @user.user_configuration.id == @user_configuration.id
@body_color = "#FFFFFF"
end

Expand Down
2 changes: 2 additions & 0 deletions app/helpers/admin/nudge_user_confirgurations_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module Admin::NudgeUserConfirgurationsHelper
end
28 changes: 28 additions & 0 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,33 @@ def confirm_signup user_id



end

def say_what_you_want user_id
user = User.cached_find(user_id)

confirmation_link = url_for( controller: "/user/user_configurations", action: 'edit', user_id: user.slug, id: user.user_configuration.id)


merge_vars = [ { rcpt: user.email,
vars: [ {name: "LINK", content: confirmation_link} ]
}
]

if Rails.env.production?
send_with_mandrill( [{email: user.email }],
"say-what-you-want",
'Opporunities on DigiRAMP',
["nudging"],
merge_vars,
true,
true,
'11-digiramp-nudging',
"mailchimp"
)
else
ap confirmation_link
end

end
end
90 changes: 49 additions & 41 deletions app/views/admin/email_groups/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -20,50 +20,58 @@
= link_to 'New Email group', new_admin_email_group_path, class: 'btn btn-info'

.pull-down-10
.users
.table-responsive
table class="table table-hover"
thead
tr
th Title
th Users can subscripe
th Receipients
th Edit Recipients
th Emails
.table-responsive
table class="table table-hover"
thead
tr
th Title
th Users can subscripe
th Receipients
th Edit Recipients
th Emails

tbody
- @email_groups.each do |email_group|
tr
td
- if email_group.identifier == 'opportunities'
.btn.btn-danger.btn-xs disabled='disabled'
i.fa.fa-times
=>
-else
=> link_to admin_email_group_path(email_group), data: {:confirm => 'Are you sure?'},turboboost: true, :method => :delete do
.btn.btn-danger.btn-xs
i.fa.fa-times

=> link_to edit_admin_email_group_path(email_group) do
.btn.btn-default.btn-xs
i.fa.fa-pencil


= link_to admin_email_group_path(email_group) do
.btn.btn-default.btn-xs
'&nbsp;
= email_group.title
tbody
- @email_groups.each do |email_group|
tr
td
- if email_group.identifier == 'opportunities'
.btn.btn-danger.btn-xs disabled='disabled'
i.fa.fa-times
=>
-else
=> link_to admin_email_group_path(email_group), data: {:confirm => 'Are you sure?'},turboboost: true, :method => :delete do
.btn.btn-danger.btn-xs
i.fa.fa-times

=> link_to edit_admin_email_group_path(email_group) do
.btn.btn-default.btn-xs
i.fa.fa-pencil


td
- if email_group.subscripeable
i.fa.fa-check
td = email_group.mail_list_subscribers.count
td
= link_to 'Recipients', admin_email_group_email_recipients_path(email_group), class: 'btn btn-default btn-xs'

td = email_group.digiramp_emails.count
= link_to admin_email_group_path(email_group) do
.btn.btn-default.btn-xs
'&nbsp;
= email_group.title

td
- if email_group.subscripeable
i.fa.fa-check
td = email_group.mail_list_subscribers.count
td
= link_to 'Recipients', admin_email_group_email_recipients_path(email_group), class: 'btn btn-default btn-xs'


td = email_group.digiramp_emails.count

.pull-down-10
.digi-box
.row
.col-sm-6
'Send email with link ot users whoom has been signed up for more than 24 hours without filling in what they want
.pull-down-8
.row
.col-sm-12
.pull-right
= link_to 'Nudge users to fill in what they want', new_admin_nudge_user_confirguration_path, class: 'btn btn-default'
/.sexy_line
/== paginate(@users)
== render 'shared/site_footer'
Expand Down
2 changes: 2 additions & 0 deletions app/views/admin/nudge_user_confirgurations/new.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
h1 Admin::NudgeUserConfirgurations#new
p Find me in app/views/admin/nudge_user_confirgurations/new.html.slim
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Digiramp::Application.routes.draw do



get 'facebook_import/index'

get "/invites/:provider/contact_callback" => "invites#index"
Expand Down Expand Up @@ -145,7 +146,7 @@
resources :issue_events
resources :legal_templates
resources :page_styles

resources :nudge_user_confirgurations, only: [:new]
get 'paper_trails/index'
get 'paper_trails/orders'
get 'paper_trails/stakes'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddSayWhatYouWantEmailCountToUserConfigurations < ActiveRecord::Migration
def change
add_column :user_configurations, :say_what_you_want_email_count, :integer, default: 0
UserConfiguration.update_all(say_what_you_want_email_count: 0)
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20151119153115) do
ActiveRecord::Schema.define(version: 20151119163018) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -3425,6 +3425,7 @@
t.boolean "add_recording_to_a_playlist_later"
t.boolean "add_legal_informations_later"
t.boolean "add_digital_signature_later"
t.integer "say_what_you_want_email_count", default: 0
end

add_index "user_configurations", ["user_id"], name: "index_user_configurations_on_user_id", using: :btree
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'rails_helper'

RSpec.describe Admin::NudgeUserConfirgurationsController, type: :controller do

describe "GET #new" do
it "returns http success" do
get :new
expect(response).to have_http_status(:success)
end
end

end
15 changes: 15 additions & 0 deletions spec/helpers/admin/nudge_user_confirgurations_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'rails_helper'

# Specs in this file have access to a helper object that includes
# the Admin::NudgeUserConfirgurationsHelper. For example:
#
# describe Admin::NudgeUserConfirgurationsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe Admin::NudgeUserConfirgurationsHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'rails_helper'

RSpec.describe "nudge_user_confirgurations/new.html.slim", type: :view do
pending "add some examples to (or delete) #{__FILE__}"
end

0 comments on commit 1804abd

Please sign in to comment.