[ARVADOS] updated: b288ebe08b16204d97c4911106bd5ca57fb2b36b

git at public.curoverse.com git at public.curoverse.com
Tue Apr 8 17:30:12 EDT 2014


Summary of changes:
 apps/workbench/app/controllers/users_controller.rb |    1 +
 apps/workbench/config/application.default.yml      |    1 +
 .../app/controllers/arvados/v1/users_controller.rb |   13 +++++++++++++
 services/api/app/mailers/user_notifier.rb          |    8 ++++++++
 .../views/user_notifier/account_is_setup.text.erb  |    6 ++++++
 services/api/config/application.default.yml        |    1 +
 services/api/script/setup-new-user.rb              |    9 +++++++--
 .../api/test/functional/user_notifier_test.rb      |    2 +-
 8 files changed, 38 insertions(+), 3 deletions(-)
 create mode 100644 services/api/app/mailers/user_notifier.rb
 create mode 100644 services/api/app/views/user_notifier/account_is_setup.text.erb
 copy apps/workbench/test/unit/job_task_test.rb => services/api/test/functional/user_notifier_test.rb (61%)

       via  b288ebe08b16204d97c4911106bd5ca57fb2b36b (commit)
      from  0f92cdd76a8ecc456e0ab068abce468e3a169bc0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit b288ebe08b16204d97c4911106bd5ca57fb2b36b
Author: radhika chippada <radhika at curoverse.com>
Date:   Tue Apr 8 17:29:03 2014 -0400

    Story #1776: Add mailer and update users_controller. Also, update workbench and setup script to pass the additional send notification parameter.

diff --git a/apps/workbench/app/controllers/users_controller.rb b/apps/workbench/app/controllers/users_controller.rb
index 5ace8d6..ed5edb1 100644
--- a/apps/workbench/app/controllers/users_controller.rb
+++ b/apps/workbench/app/controllers/users_controller.rb
@@ -149,6 +149,7 @@ class UsersController < ApplicationController
     respond_to do |format|
       if current_user.andand.is_admin
         setup_params = {}
+        setup_params[:send_notification_email] = "#{Rails.configuration.send_user_setup_notification_email}"
         if params['user_uuid'] && params['user_uuid'].size>0
           setup_params[:uuid] = params['user_uuid']
         end
diff --git a/apps/workbench/config/application.default.yml b/apps/workbench/config/application.default.yml
index dfc4f03..c80b7f9 100644
--- a/apps/workbench/config/application.default.yml
+++ b/apps/workbench/config/application.default.yml
@@ -73,3 +73,4 @@ common:
   show_user_agreement_inline: false
   secret_token: ~
   default_openid_prefix: https://www.google.com/accounts/o8/id
+  send_user_setup_notification_email: true
diff --git a/services/api/app/controllers/arvados/v1/users_controller.rb b/services/api/app/controllers/arvados/v1/users_controller.rb
index 58661a0..f39a883 100644
--- a/services/api/app/controllers/arvados/v1/users_controller.rb
+++ b/services/api/app/controllers/arvados/v1/users_controller.rb
@@ -131,6 +131,11 @@ class Arvados::V1::UsersController < ApplicationController
                     params[:repo_name], params[:vm_uuid]
     end
 
+    # setup succeeded. send email to user
+    if params[:send_notification_email] == true || params[:send_notification_email] == 'true'
+      UserNotifier.account_is_setup(@object).deliver
+    end
+
     render json: { kind: "arvados#HashList", items: @response }
   end
 
@@ -141,4 +146,12 @@ class Arvados::V1::UsersController < ApplicationController
     show
   end
 
+  protected
+
+  def self._setup_requires_parameters 
+    {
+      send_notification_email: { type: 'boolean', required: true },
+    }  
+  end
+
 end
diff --git a/services/api/app/mailers/user_notifier.rb b/services/api/app/mailers/user_notifier.rb
new file mode 100644
index 0000000..759325a
--- /dev/null
+++ b/services/api/app/mailers/user_notifier.rb
@@ -0,0 +1,8 @@
+class UserNotifier < ActionMailer::Base
+  default from: Rails.configuration.user_notifier_email_from
+
+  def account_is_setup(user)
+    @user = user
+    mail(to: user.email, subject: 'Welcome to Curoverse')
+  end
+end
diff --git a/services/api/app/views/user_notifier/account_is_setup.text.erb b/services/api/app/views/user_notifier/account_is_setup.text.erb
new file mode 100644
index 0000000..0f584c7
--- /dev/null
+++ b/services/api/app/views/user_notifier/account_is_setup.text.erb
@@ -0,0 +1,6 @@
+<%= @user.full_name %>,
+
+Your Arvados account has been set up. You can log in here using your
+Google account (<%= @user.email %>):
+
+<%= Rails.configuration.workbench_address %>
diff --git a/services/api/config/application.default.yml b/services/api/config/application.default.yml
index 298b001..1de4db1 100644
--- a/services/api/config/application.default.yml
+++ b/services/api/config/application.default.yml
@@ -85,6 +85,7 @@ common:
   new_users_are_active: false
   admin_notifier_email_from: arvados at example.com
   email_subject_prefix: "[ARVADOS] "
+  user_notifier_email_from: arvados at example.com
 
   # Visitors to the API server will be redirected to the workbench
   workbench_address: https://workbench.local:3001/
diff --git a/services/api/script/setup-new-user.rb b/services/api/script/setup-new-user.rb
index ebff192..af0de13 100755
--- a/services/api/script/setup-new-user.rb
+++ b/services/api/script/setup-new-user.rb
@@ -21,6 +21,9 @@ If creating a new user record, require authentication from an OpenID \
 with this OpenID prefix *and* a matching email address in order to \
 claim the account.
   eos
+  opt :send_notification_email, <<-eos, default: 'true'
+Send notification email after successfully setting up the user.
+  eos
 end
 
 log.level = (ENV['DEBUG'] || opts.debug) ? Logger::DEBUG : Logger::WARN
@@ -55,10 +58,12 @@ end
 # Invoke user setup method
 if (found_user)
   user = arv.user.setup uuid: found_user[:uuid], repo_name: user_repo_name,
-        vm_uuid: vm_uuid, openid_prefix: opts.openid_prefix
+          vm_uuid: vm_uuid, openid_prefix: opts.openid_prefix,
+          send_notification_email: opts.send_notification_email
 else
   user = arv.user.setup user: {email: user_arg}, repo_name: user_repo_name,
-        vm_uuid: vm_uuid, openid_prefix: opts.openid_prefix
+          vm_uuid: vm_uuid, openid_prefix: opts.openid_prefix,
+          send_notification_email: opts.send_notification_email
 end
 
 log.info {"user uuid: " + user[:uuid]}
diff --git a/services/api/test/functional/user_notifier_test.rb b/services/api/test/functional/user_notifier_test.rb
new file mode 100644
index 0000000..c06f62e
--- /dev/null
+++ b/services/api/test/functional/user_notifier_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class UserNotifierTest < ActionMailer::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list