From afad554f0193a4940884ea16e0c3644e401a0a28 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Mon, 11 Oct 2010 13:42:05 -0700 Subject: [PATCH] DG MS; added link to send invitation, consolidated locale file for devise invitable, upgraded devise to 1.1.3 in the gemfile --- Gemfile | 2 +- Gemfile.lock | 48 +++++++++++---------- app/controllers/invitations_controller.rb | 5 --- app/controllers/users_controller.rb | 4 ++ app/views/aspects/manage.html.haml | 2 +- app/views/invitations/new.html.haml | 10 +++++ app/views/users/mailer/invitation.html.haml | 9 ++++ config/locales/devise.en.yml | 7 +++ config/locales/devise_invitable.en.yml | 8 ---- config/routes.rb | 4 +- 10 files changed, 60 insertions(+), 39 deletions(-) create mode 100644 app/views/invitations/new.html.haml create mode 100644 app/views/users/mailer/invitation.html.haml delete mode 100644 config/locales/devise_invitable.en.yml diff --git a/Gemfile b/Gemfile index 4d85b1531..0e74b4f45 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ gem 'rails', '3.0.0' gem 'bundler', '>= 1.0.0' #Security -gem 'devise', '1.1.2' +gem 'devise', '1.1.3' gem 'devise-mongo_mapper', :git => 'git://github.com/collectiveidea/devise-mongo_mapper' gem 'devise_invitable', '~> 0.3.4' #Mongo diff --git a/Gemfile.lock b/Gemfile.lock index 4b7f686b0..a2a905cc5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -49,21 +49,22 @@ GIT GIT remote: http://github.com/dcu/magent.git - revision: 06513f3dac812469a55f2e365c349af4d2abc92a + revision: 5d664351b305141158fc69fc495456414821adb3 specs: - magent (0.4.2) - mongo (>= 0.1.0) - uuidtools (>= 2.0.0) + magent (1.0.0) + em-websocket + mongo + uuidtools GIT remote: http://github.com/jnunemaker/mongomapper.git - revision: 5a3328244b641fa4f6a3743e9e0b4dd6a1ac2700 + revision: fd59b0ab068be7321f8e84b9dc12fb4fa6b8535d branch: rails3 specs: mongo_mapper (0.8.4) activemodel (~> 3.0.0) activesupport (~> 3.0.0) - plucky (~> 0.3.5) + plucky (~> 0.3.6) GEM remote: http://rubygems.org/ @@ -119,6 +120,8 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) selenium-webdriver (>= 0.0.3) + childprocess (0.0.7) + ffi (~> 0.6.3) columnize (0.3.1) crack (0.1.8) cucumber (0.9.2) @@ -132,7 +135,7 @@ GEM culerity (0.2.12) daemons (1.1.0) database_cleaner (0.5.2) - devise (1.1.2) + devise (1.1.3) bcrypt-ruby (~> 2.1.2) warden (~> 0.10.7) devise_invitable (0.3.4) @@ -173,7 +176,7 @@ GEM subexec (~> 0.0.4) mocha (0.9.8) rake - mongo (1.0.9) + mongo (1.1) bson (>= 1.0.5) net-scp (1.0.4) net-ssh (>= 1.99.1) @@ -183,8 +186,8 @@ GEM net-ssh-gateway (1.0.1) net-ssh (>= 1.99.1) nokogiri (1.4.3.1) - plucky (0.3.5) - mongo (~> 1.0.8) + plucky (0.3.6) + mongo (~> 1.1) polyglot (0.3.1) pubsubhubbub (0.1.1) em-http-request (>= 0.1.5) @@ -210,16 +213,16 @@ GEM rake (0.8.7) rest-client (1.6.1) mime-types (>= 1.16) - rspec (2.0.0.rc) - rspec-core (= 2.0.0.rc) - rspec-expectations (= 2.0.0.rc) - rspec-mocks (= 2.0.0.rc) - rspec-core (2.0.0.rc) - rspec-expectations (2.0.0.rc) + rspec (2.0.0) + rspec-core (= 2.0.0) + rspec-expectations (= 2.0.0) + rspec-mocks (= 2.0.0) + rspec-core (2.0.0) + rspec-expectations (2.0.0) diff-lcs (>= 1.1.2) - rspec-mocks (2.0.0.rc) - rspec-core (= 2.0.0.rc) - rspec-expectations (= 2.0.0.rc) + rspec-mocks (2.0.0) + rspec-core (= 2.0.0) + rspec-expectations (= 2.0.0) rspec-rails (2.0.0.beta.17) rspec (>= 2.0.0.beta.14) webrat (>= 0.7.0) @@ -229,8 +232,9 @@ GEM ruby-debug-base (0.10.3) linecache (>= 0.3) rubyzip (0.9.4) - selenium-webdriver (0.0.28) - ffi (>= 0.6.1) + selenium-webdriver (0.0.29) + childprocess (>= 0.0.7) + ffi (~> 0.6.3) json_pure rubyzip subexec (0.0.4) @@ -269,7 +273,7 @@ DEPENDENCIES carrierwave! cucumber-rails (= 0.3.2) database_cleaner - devise (= 1.1.2) + devise (= 1.1.3) devise-mongo_mapper! devise_invitable (~> 0.3.4) em-http-request! diff --git a/app/controllers/invitations_controller.rb b/app/controllers/invitations_controller.rb index d4f68c197..852904458 100644 --- a/app/controllers/invitations_controller.rb +++ b/app/controllers/invitations_controller.rb @@ -4,15 +4,10 @@ class InvitationsController < Devise::InvitationsController def update - puts params.inspect begin - puts params["user"]["invitation_token"] user = User.find_by_invitation_token(params["user"]["invitation_token"]) - - puts user.inspect user.accept_invitation!(params["user"]) rescue MongoMapper::DocumentNotValid => e - puts "Doc Not VALID" user = nil flash[:error] = e.message end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9ef461b20..d78025a47 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -71,6 +71,10 @@ class UsersController < ApplicationController send_data( File.open(tar_path).read, :filename => "#{current_user.id}.tar" ) end + def invite + User.invite!(:email => params[:email]) + end + private def prep_image_url(params) url = APP_CONFIG[:pod_url].chop if APP_CONFIG[:pod_url][-1,1] == '/' diff --git a/app/views/aspects/manage.html.haml b/app/views/aspects/manage.html.haml index 5573fe020..c03b332d3 100644 --- a/app/views/aspects/manage.html.haml +++ b/app/views/aspects/manage.html.haml @@ -27,7 +27,7 @@ - content_for :publish do = link_to(t('.add_a_new_aspect'), "#add_aspect_pane", :id => "add_aspect_button", :class => "new_aspect button", :title => t('.add_a_new_aspect')) - + = link_to "invite a friend!", new_user_invitation_path %ul#aspect_list - for aspect in @aspects %li.aspect diff --git a/app/views/invitations/new.html.haml b/app/views/invitations/new.html.haml new file mode 100644 index 000000000..4b41f06c6 --- /dev/null +++ b/app/views/invitations/new.html.haml @@ -0,0 +1,10 @@ +%h2 Send invitation += form_for resource, :as => resource_name, :url => invitation_path(resource_name) do |f| + = devise_error_messages! + %p + = f.label :email + %br/ + = f.text_field :email + %p= f.submit "Send an invitation" += link_to "Home", after_sign_in_path_for(resource_name) +%br/ diff --git a/app/views/users/mailer/invitation.html.haml b/app/views/users/mailer/invitation.html.haml new file mode 100644 index 000000000..884a8fc27 --- /dev/null +++ b/app/views/users/mailer/invitation.html.haml @@ -0,0 +1,9 @@ +%p + Hello #{@resource.email}! +%p + Someone has invited you to #{root_url}, you can accept it through the link below. +%p= link_to 'Accept invitation', accept_invitation_url(@resource, :invitation_token => @resource.invitation_token) +%p + If you don't want to accept the invitation, please ignore this email. + %br/ + Your account won't be created until you access the link above and set your password. diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml index 5e4e43321..07a2611d0 100644 --- a/config/locales/devise.en.yml +++ b/config/locales/devise.en.yml @@ -30,6 +30,10 @@ en: unlocks: send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.' unlocked: 'Your account was successfully unlocked. You are now signed in.' + invitations: + send_instructions: 'Your invitation has been sent.' + invitation_token_invalid: 'The invitation token provided is not valid!' + updated: 'Your password was set successfully. You are now signed in.' mailer: confirmation_instructions: subject: 'Confirmation instructions' @@ -37,3 +41,6 @@ en: subject: 'Reset password instructions' unlock_instructions: subject: 'Unlock Instructions' + invitation: + subject: 'A friend wants you to join Diaspora!' + diff --git a/config/locales/devise_invitable.en.yml b/config/locales/devise_invitable.en.yml deleted file mode 100644 index cc1a14842..000000000 --- a/config/locales/devise_invitable.en.yml +++ /dev/null @@ -1,8 +0,0 @@ -en: - devise: - invitations: - send_instructions: 'An email with instructions about how to set the password has been sent.' - updated: 'Your password was set successfully. You are now signed in.' - mailer: - invitiation: - subject: 'Invitation' diff --git a/config/routes.rb b/config/routes.rb index 641c6306f..8fbd132a8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -14,8 +14,8 @@ Diaspora::Application.routes.draw do :password => "devise/passwords", :invitations => "invitations"} # added public route to user - match 'public/:username', :to => 'users#public' - match 'users/export', :to => 'users#export' + match 'public/:username', :to => 'users#public' + match 'users/export', :to => 'users#export' match 'users/export_photos', :to => 'users#export_photos' resources :users, :except => [:create, :new, :show]