[ARVADOS] updated: 85ee7f10d6aa8084da51a388011395c080842c70

git at public.curoverse.com git at public.curoverse.com
Tue Aug 5 13:27:11 EDT 2014


Summary of changes:
 apps/workbench/app/controllers/users_controller.rb               | 9 +++++++--
 apps/workbench/config/application.default.yml                    | 3 +++
 services/api/app/controllers/arvados/v1/users_controller.rb      | 9 +++++++++
 services/api/app/mailers/profile_notifier.rb                     | 8 ++++++++
 services/api/app/views/profile_notifier/profile_created.text.erb | 1 +
 5 files changed, 28 insertions(+), 2 deletions(-)
 create mode 100644 services/api/app/mailers/profile_notifier.rb
 create mode 100644 services/api/app/views/profile_notifier/profile_created.text.erb

       via  85ee7f10d6aa8084da51a388011395c080842c70 (commit)
      from  692f03def1a915a8e76dc44c480be9d6716887fb (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 85ee7f10d6aa8084da51a388011395c080842c70
Author: radhika <radhika at curoverse.com>
Date:   Tue Aug 5 13:25:40 2014 -0400

    3296: send notification email when the user first creates profile, provided an address is configured

diff --git a/apps/workbench/app/controllers/users_controller.rb b/apps/workbench/app/controllers/users_controller.rb
index ffa6fe3..441c99a 100644
--- a/apps/workbench/app/controllers/users_controller.rb
+++ b/apps/workbench/app/controllers/users_controller.rb
@@ -289,8 +289,6 @@ class UsersController < ApplicationController
 
   def update_profile
     user_prefs = User.limit(1).where(uuid: current_user.uuid).first.prefs
-    @current_user_profile = user_prefs[:profile] if user_prefs
-    @current_user_profile ||= {}
 
     profile_keys = []
     @profile_config = Rails.configuration.user_profile_form_fields
@@ -307,6 +305,13 @@ class UsersController < ApplicationController
       end
     end
 
+    # Inform server to send mail if this is the first time profile is being created and notification is configured
+    profile_notification_address = Rails.configuration.user_profile_notification_address
+    @current_user_profile = user_prefs[:profile] if user_prefs
+    if !@current_user_profile && profile_notification_address
+      updated_profile[:send_profile_notification_email] = profile_notification_address
+    end
+
     current_user.update_profile updated_profile
     respond_to do |format|
       format.js {render inline: "location.reload();"}
diff --git a/apps/workbench/config/application.default.yml b/apps/workbench/config/application.default.yml
index c4de7dd..0dae0bb 100644
--- a/apps/workbench/config/application.default.yml
+++ b/apps/workbench/config/application.default.yml
@@ -103,3 +103,6 @@ common:
   #      - Software developer
   #      - IT
   #      - Other
+
+  # email address to which mail should be sent when the user creates profile for the first time
+  user_profile_notification_address: false
diff --git a/services/api/app/controllers/arvados/v1/users_controller.rb b/services/api/app/controllers/arvados/v1/users_controller.rb
index c32ad0b..568dd97 100644
--- a/services/api/app/controllers/arvados/v1/users_controller.rb
+++ b/services/api/app/controllers/arvados/v1/users_controller.rb
@@ -117,7 +117,16 @@ class Arvados::V1::UsersController < ApplicationController
   # update profile for the user
   def profile
     reload_object_before_update
+
+    # update profile
     @object.profile params
+
+    # profile update succeeded. send email if requested by the client
+    profile_notification_address = params[:send_profile_notification_email]
+    if profile_notification_address
+      ProfileNotifier.profile_created(@object, profile_notification_address).deliver
+    end
+
     show
   end
 
diff --git a/services/api/app/mailers/profile_notifier.rb b/services/api/app/mailers/profile_notifier.rb
new file mode 100644
index 0000000..3863e8a
--- /dev/null
+++ b/services/api/app/mailers/profile_notifier.rb
@@ -0,0 +1,8 @@
+class ProfileNotifier < ActionMailer::Base
+  default from: Rails.configuration.admin_notifier_email_from
+
+  def profile_created(user, address)
+    @user = user
+    mail(to: address, subject: 'Profile created')
+  end
+end
diff --git a/services/api/app/views/profile_notifier/profile_created.text.erb b/services/api/app/views/profile_notifier/profile_created.text.erb
new file mode 100644
index 0000000..d84b05a
--- /dev/null
+++ b/services/api/app/views/profile_notifier/profile_created.text.erb
@@ -0,0 +1 @@
+Profile created by user <%=@user.full_name%> <%=@user.email%>

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list