diff --git a/app/models/invitation.rb b/app/models/invitation.rb index 4ee802817..c7f3fb8b8 100644 --- a/app/models/invitation.rb +++ b/app/models/invitation.rb @@ -36,7 +36,7 @@ class Invitation def self.create_invitee(opts = {}) invitee = User.find_or_initialize_with_error_by(:email, opts[:email]) - + invitee.invites = opts[:invites] if invitee.new_record? invitee.errors.clear if invitee.email.try(:match, Devise.email_regexp) else diff --git a/app/views/devise/mailer/_batch_invites.html.haml b/app/views/devise/mailer/_batch_invites.html.haml new file mode 100644 index 000000000..b6aca3426 --- /dev/null +++ b/app/views/devise/mailer/_batch_invites.html.haml @@ -0,0 +1,12 @@ +%p + Today is the day that alpha invites for Diaspora are handed out. + Chances are you were one of the first to support Diaspora. +%p + We are elated to offer you a first glimpse of our Alpha release. + We know there still are bugs and missing features, but we are excited by the progress we made in these short months. +%p + We would love your feedback, as it is the users of Diaspora which should drive what it becomes. +%p + For suggestions, feature requests, or bug reports, please use the "Feedback" link found on the left side of the page. +%p + Find more details on what what we have released on our blog, http://blog.joindiaspora.com diff --git a/app/views/devise/mailer/_batch_invites.html.yml b/app/views/devise/mailer/_batch_invites.html.yml new file mode 100644 index 000000000..6d05d5a7b --- /dev/null +++ b/app/views/devise/mailer/_batch_invites.html.yml @@ -0,0 +1,12 @@ +%p + Today is the day that alpha invites for Diaspora are handed out. + Chances are you were one of the first to support Diaspora. + + We are elated to offer you a first glimpse of our Alpha release. + We know there still are bugs and missing features, but we are excited by the progress we made in these short months. + + We would love your feedback, as it is the users of Diaspora which should drive what it becomes. + + For suggestions, feature requests, or bug reports, please use the "Feedback" link found on the left side of the page. + + Find more details on what what we have released diff --git a/app/views/devise/mailer/invitation.html.haml b/app/views/devise/mailer/invitation.html.haml index c4a9a184c..206714fa1 100644 --- a/app/views/devise/mailer/invitation.html.haml +++ b/app/views/devise/mailer/invitation.html.haml @@ -12,6 +12,9 @@ = t('devise.mailer.welcome', :email => @resource.email) -if @invs.count > 0 = render :partial => 'inviters' + + -else + = render :partial => 'batch_invites' %p= link_to t('.accept'), accept_invitation_url(@resource, :invitation_token => @resource.invitation_token), :class => "large_text" %p.small = t('.ignore') diff --git a/lib/rake_helpers.rb b/lib/rake_helpers.rb new file mode 100644 index 000000000..5198e4760 --- /dev/null +++ b/lib/rake_helpers.rb @@ -0,0 +1,21 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. +module RakeHelpers + def process_emails(csv, num_to_process, offset) + require 'fastercsv' + backers = FasterCSV.read(csv) + churn_through = 0 + num_to_process.times do |n| + if backers[n+offset] == nil + break + end + churn_through = n + backer_name = backers[n+offset][0].to_s.strip + backer_email = backers[n+offset][1].to_s.gsub('.ksr', '').strip + puts "sending email to: #{backer_name} #{backer_email}" + Invitation.create_invitee(:email => backer_email, :name => backer_name, :invites => 5) + end + churn_through + end +end diff --git a/lib/tasks/batch_inviter.rake b/lib/tasks/batch_inviter.rake index 49ba4a1dc..b2f09738c 100644 --- a/lib/tasks/batch_inviter.rake +++ b/lib/tasks/batch_inviter.rake @@ -1,31 +1,34 @@ # Copyright (c) 2010, Diaspora Inc. This file is # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. +require File.join(Rails.root, 'lib', 'rake_helpers') +include RakeHelpers namespace :invites do desc 'send a bunch of invites from a csv with rows of name, email' - task :send, :filename, :number, :start do - - unless args[:filename] && args[:number] && args[:start] - raise "please give me {filename} {number of people to churn}, {where to start in the file}" - end + + task :send, :filename, :number, :start do |t, args| + puts "this task assumes the first line of your csv is just titles(1 indexed)" + puts "MAKE SURE YOU HAVE RAN THIS ON THE RIGHT DB rake 'invites:send[filename, number, start] RAILS_ ENV=production'" + puts Rails.env + unless args[:filename] + raise "please give me {filename.csv} {number of people to churn}, {where to start in the file}" + end require File.dirname(__FILE__) + '/../../config/environment' - require 'fastercsv' filename = args[:filename] start = args[:start].to_i || 0 - number_of_backers = args[:number].to_i || 1000 + number_of_backers = args[:number] || 1000 offset = 1 + start - puts "emailing #{number_of_backers} listed in #{filename} starting at #{start}" - backers = FasterCSV.read("bkr.csv") + puts "emailing #{number_of_backers.to_i} people listed in #{filename} starting at #{offset}" - #number_of_backers.times do |n| - # backer_name = backers[n+offset][0] - # backer_email = backers[n+offset][1].gsub('.ksr', '') - # send_email(backer_name, backer_email) - #end + finish_num = process_emails(filename, number_of_backers.to_i, offset) + + puts "you ended on #{offset + finish_num}" + puts "all done" end + end