Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

send ical when accepted

  • Loading branch information...
commit a7c5facc657b6ac1e2c8f9cb72fac390645139bf 1 parent 1ab1828
@sachinr authored
View
2  Gemfile
@@ -24,6 +24,7 @@ gem 'devise-twitter'
gem 'pg'
gem 'thin'
gem 'heroku'
+gem 'icalendar'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
@@ -38,6 +39,7 @@ group :development do
# To use debugger
gem 'ruby-debug19', :require => 'ruby-debug'
gem "awesome_print", "~> 0.4.0"
+ gem "letter_opener"
end
group :test do
View
5 Gemfile.lock
@@ -64,6 +64,7 @@ GEM
term-ansicolor (~> 1.0.5)
hike (1.2.1)
i18n (0.6.0)
+ icalendar (1.1.6)
jquery-rails (1.0.17)
railties (~> 3.0)
thor (~> 0.14)
@@ -75,6 +76,8 @@ GEM
less-rails (2.0.3)
actionpack (~> 3.1.1)
less (~> 2.0.7)
+ letter_opener (0.0.2)
+ launchy
libv8 (3.3.10.4)
linecache19 (0.5.12)
ruby_core_source (>= 0.1.4)
@@ -179,7 +182,9 @@ DEPENDENCIES
devise-twitter
haml
heroku
+ icalendar
jquery-rails
+ letter_opener
pg
rails (= 3.1.1)
ruby-debug19
View
1  app/controllers/organization/projects_controller.rb
@@ -69,6 +69,7 @@ def accept_attendee
find_by_project_id_and_user_id(params[:id], params[:user])
@attendee.accepted = true
if @attendee.save
+ AttendeeMailer.accepted_email(@attendee.user, @attendee.project).deliver
respond_to do |format|
format.html { redirect_to request.referer }
end
View
27 app/mailers/attendee_mailer.rb
@@ -0,0 +1,27 @@
+require 'icalendar'
+include Icalendar
+
+class AttendeeMailer < ActionMailer::Base
+ default from: "helpa@sachinr.com"
+
+ def accepted_email(user, project)
+ @user = user
+ @url = project_url(project)
+ @project = project
+
+ cal = Calendar.new
+ cal.event do
+ dtstart project.start_date
+ dtend project.end_date
+ summary project.name
+ description project.description
+ organizer project.organization.name
+ klass "PRIVATE"
+ end
+ attachments['event.ics'] = cal.to_ical
+ mail(:to => user.email,
+ :subject => "You have been accepted for #{project.name}")
+ end
+
+
+end
View
2  app/models/user.rb
@@ -10,7 +10,7 @@ class User < ActiveRecord::Base
has_many :project_user_scores, :dependent => :destroy
# Setup accessible (or protected) attributes for your model
- attr_accessible :email, :password, :password_confirmation, :remember_me, :region, :admin
+ attr_accessible :email, :password, :password_confirmation, :remember_me, :region, :admin, :name
def update_profile_answers(scores)
ProfileQuestion.all.each do |question|
View
8 app/views/attendee_mailer/accepted_email.text.erb
@@ -0,0 +1,8 @@
+Hi <%= @user.name %>
+
+Congratulations! <%= @project.organization.name %> has accepted your request to volunteer for their project - <%= @project.name %>
+
+For your conveniance, we have attached a calendar invite to the email.
+
+Regards,
+The Helpa Team
View
5 app/views/organization/projects/_form.html.haml
@@ -49,9 +49,8 @@
%p
Email:
= attendee.user.email
- = link_to "[approve]", :action => :accept_attendee, :user => attendee.user.id
- = link_to "[x]", :action => :destroy_attendee
-
+ - unless attendee.accepted
+ = link_to "[approve]", :action => :accept_attendee, :user => attendee.user.id
.actions
= f.submit :class => 'btn primary'
View
1  config/environments/development.rb
@@ -2,6 +2,7 @@
# Settings specified here will take precedence over those in config/application.rb
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
+ #config.action_mailer.delivery_method = :letter_opener
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
View
12 config/initializers/setup_mail.rb
@@ -0,0 +1,12 @@
+ActionMailer::Base.smtp_settings = {
+ :address => "smtp.gmail.com",
+ :port => 587,
+ :domain => "sachinr.com",
+ :user_name => "helpa@sachinr.com",
+ :password => "helpa123",
+ :authentication => "plain",
+ :enable_starttls_auto => true
+}
+
+ActionMailer::Base.default_url_options[:host] = "localhost:3000"
+
View
7 test/functional/attendee_mailer_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class AttendeeMailerTest < ActionMailer::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.