[ARVADOS] created: 1.3.0-3225-g1fb68cf0a

Git user git at public.arvados.org
Fri Sep 25 21:19:48 UTC 2020


        at  1fb68cf0a5f6ad058a54d4f822385983b3504987 (commit)


commit 1fb68cf0a5f6ad058a54d4f822385983b3504987
Author: Peter Amstutz <peter.amstutz at curii.com>
Date:   Fri Sep 25 17:17:06 2020 -0400

    16874: Content of account_is_setup.text.erb uses Users.UserSetupMailText
    
    The most straightforward solution seems to be for UserSetupMailText to
    still be an erb template and is evaluated in the same environment as
    as before, but it gets the code from the config file.
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>

diff --git a/lib/config/config.default.yml b/lib/config/config.default.yml
index 15e7c7c06..d0338e8c8 100644
--- a/lib/config/config.default.yml
+++ b/lib/config/config.default.yml
@@ -287,6 +287,20 @@ Clusters:
       # address is used.
       PreferDomainForUsername: ""
 
+      UserSetupMailText: |
+        <% if not @user.full_name.empty? -%>
+        <%= @user.full_name %>,
+        <% else -%>
+        Hi there,
+        <% end -%>
+
+        Your Arvados account has been set up.  You can log in at
+
+        <%= Rails.configuration.Services.Workbench1.ExternalURL %>
+
+        Thanks,
+        Your Arvados administrator.
+
     AuditLogs:
       # Time to keep audit logs, in seconds. (An audit log is a row added
       # to the "logs" table in the PostgreSQL database each time an
diff --git a/lib/config/export.go b/lib/config/export.go
index 6ab69d21f..81c6767a1 100644
--- a/lib/config/export.go
+++ b/lib/config/export.go
@@ -214,6 +214,7 @@ var whitelist = map[string]bool{
 	"Users.PreferDomainForUsername":                false,
 	"Users.UserNotifierEmailFrom":                  false,
 	"Users.UserProfileNotificationAddress":         false,
+	"Users.UserSetupMailText":                      false,
 	"Volumes":                                      true,
 	"Volumes.*":                                    true,
 	"Volumes.*.*":                                  false,
diff --git a/lib/config/generated_config.go b/lib/config/generated_config.go
index 7ed332151..88d71eb0a 100644
--- a/lib/config/generated_config.go
+++ b/lib/config/generated_config.go
@@ -293,6 +293,20 @@ Clusters:
       # address is used.
       PreferDomainForUsername: ""
 
+      UserSetupMailText: |
+        <% if not @user.full_name.empty? -%>
+        <%= @user.full_name %>,
+        <% else -%>
+        Hi there,
+        <% end -%>
+
+        Your Arvados account has been set up.  You can log in at
+
+        <%= Rails.configuration.Services.Workbench1.ExternalURL %>
+
+        Thanks,
+        Your Arvados administrator.
+
     AuditLogs:
       # Time to keep audit logs, in seconds. (An audit log is a row added
       # to the "logs" table in the PostgreSQL database each time an
diff --git a/sdk/go/arvados/config.go b/sdk/go/arvados/config.go
index 394e30a73..00438bf34 100644
--- a/sdk/go/arvados/config.go
+++ b/sdk/go/arvados/config.go
@@ -219,6 +219,7 @@ type Cluster struct {
 		UserNotifierEmailFrom                 string
 		UserProfileNotificationAddress        string
 		PreferDomainForUsername               string
+		UserSetupMailText                     string
 	}
 	Volumes   map[string]Volume
 	Workbench struct {
diff --git a/services/api/app/controllers/arvados/v1/users_controller.rb b/services/api/app/controllers/arvados/v1/users_controller.rb
index cd23706d0..76e8da0c7 100644
--- a/services/api/app/controllers/arvados/v1/users_controller.rb
+++ b/services/api/app/controllers/arvados/v1/users_controller.rb
@@ -135,7 +135,7 @@ class Arvados::V1::UsersController < ApplicationController
                               vm_uuid: params[:vm_uuid])
 
     # setup succeeded. send email to user
-    if params[:send_notification_email]
+    if params[:send_notification_email] && !Rails.configuration.Users.UserSetupMailText.empty?
       begin
         UserNotifier.account_is_setup(@object).deliver_now
       rescue => e
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
index 50d164bfa..352ee7754 100644
--- a/services/api/app/views/user_notifier/account_is_setup.text.erb
+++ b/services/api/app/views/user_notifier/account_is_setup.text.erb
@@ -2,17 +2,4 @@
 
 SPDX-License-Identifier: AGPL-3.0 %>
 
-<% if not @user.full_name.empty? -%>
-<%= @user.full_name %>,
-<% else -%>
-Hi there,
-<% end -%>
-
-Your Arvados shell account has been set up. Please visit the virtual machines page <% if Rails.configuration.Services.Workbench1.ExternalURL %>at
-
-  <%= Rails.configuration.Services.Workbench1.ExternalURL %><%= "/" if !Rails.configuration.Services.Workbench1.ExternalURL.to_s.end_with?("/") %>users/<%= @user.uuid%>/virtual_machines <% else %><% end %>
-
-for connection instructions.
-
-Thanks,
-The Arvados team.
+<%= ERB.new(Rails.configuration.Users.UserSetupMailText, 0, "-").result(binding) %>
diff --git a/services/api/test/unit/user_notifier_test.rb b/services/api/test/unit/user_notifier_test.rb
index da6c7fdb8..c288786c1 100644
--- a/services/api/test/unit/user_notifier_test.rb
+++ b/services/api/test/unit/user_notifier_test.rb
@@ -9,6 +9,24 @@ class UserNotifierTest < ActionMailer::TestCase
   # Send the email, then test that it got queued
   test "account is setup" do
     user = users :active
+
+    Rails.configuration.Users.UserSetupMailText = %{
+<% if not @user.full_name.empty? -%>
+<%= @user.full_name %>,
+<% else -%>
+Hi there,
+<% end -%>
+
+Your Arvados shell account has been set up. Please visit the virtual machines page <% if Rails.configuration.Services.Workbench1.ExternalURL %>at
+
+<%= Rails.configuration.Services.Workbench1.ExternalURL %><%= "/" if !Rails.configuration.Services.Workbench1.ExternalURL.to_s.end_with?("/") %>users/<%= @user.uuid%>/virtual_machines <% else %><% end %>
+
+for connection instructions.
+
+Thanks,
+The Arvados team.
+}
+
     email = UserNotifier.account_is_setup user
 
     assert_not_nil email

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list