[ARVADOS] updated: 51a0f4eb8bcd1467cea656d70a41a0901762e9be

git at public.curoverse.com git at public.curoverse.com
Fri Aug 8 18:01:48 EDT 2014


Summary of changes:
 .../app/controllers/application_controller.rb      |  13 +-
 .../workbench/app/controllers/groups_controller.rb |   4 +-
 apps/workbench/app/controllers/users_controller.rb |  31 ---
 apps/workbench/app/models/group.rb                 |   2 +-
 .../app/views/application/_content_layout.html.erb |   2 +-
 .../app/views/projects/_show_sharing.html.erb      |   5 +
 .../app/views/users/_choose_rows.html.erb          |   2 +-
 apps/workbench/app/views/users/profile.html.erb    |  26 +-
 apps/workbench/config/application.default.yml      |  43 ++-
 apps/workbench/config/routes.rb                    |   1 -
 .../test/integration/application_layout_test.rb    | 288 +++++++++++++++++++++
 apps/workbench/test/integration/projects_test.rb   |  12 +
 doc/api/schema/Group.html.textile.liquid           |   2 +-
 .../schema/PipelineTemplate.html.textile.liquid    |   6 +-
 sdk/python/arvados/commands/put.py                 |   1 -
 .../controllers/arvados/v1/groups_controller.rb    |   2 +-
 .../app/controllers/arvados/v1/users_controller.rb |  16 --
 services/api/app/models/link.rb                    |   2 +-
 .../profile_notifier/profile_created.text.erb      |   1 +
 services/api/config/routes.rb                      |   1 -
 services/api/db/structure.sql                      |   1 +
 .../test/fixtures/api_client_authorizations.yml    |   6 +
 services/api/test/fixtures/users.yml               |  49 +++-
 .../arvados/v1/groups_controller_test.rb           |   4 +-
 24 files changed, 429 insertions(+), 91 deletions(-)
 create mode 100644 apps/workbench/test/integration/application_layout_test.rb

       via  51a0f4eb8bcd1467cea656d70a41a0901762e9be (commit)
       via  addce205a8b7bca49038167c2066d31efccad870 (commit)
       via  b14aa29daff5264bd2352ec1a61b222c9e7812a2 (commit)
       via  f3e546e73898e9ff57fb45e53b9f009265cd7ddd (commit)
       via  d7e17c51907d658d2d4e2794044486ebe007126d (commit)
       via  fde712e92ad33e03dfd79f5fca99d2005cdd0795 (commit)
       via  b82d80addf80b9ead7c63f85f72613042b3b2c51 (commit)
       via  7962de491af28d00a9c88412ad4d1e42be83432a (commit)
       via  c29fc69a571bc2e4a4e450a09d94adbb305633bd (commit)
       via  3af6ef2d42e3e6efb3ea8e1f32d34293f9b1011e (commit)
       via  fca9bd08944a78cf0b6843e06598a5378cb31581 (commit)
       via  fc68033c06f6f4320a9f901d3e79cc57d8097a21 (commit)
       via  5ce1225be2b74fa8b2025b0f52e72b86629fecc1 (commit)
       via  2bf927358c5956c5296009948c45403c54787021 (commit)
       via  9ea365275a363d634908f2a1eb5926024e8e8803 (commit)
      from  c424885353afb06ac835e6d44be2d838d193d49f (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 51a0f4eb8bcd1467cea656d70a41a0901762e9be
Author: radhika <radhika at curoverse.com>
Date:   Fri Aug 8 18:01:11 2014 -0400

    3296: use update method and remove unnecessary update_profile method

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index c488023..ca35baf 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -525,6 +525,7 @@ class ApplicationController < ActionController::Base
       missing_required_profile = false
 
       user_prefs = User.limit(1).where(uuid: current_user.uuid).first.prefs
+      user_prefs = current_user.prefs if !user_prefs[:profile]
       current_user_profile = user_prefs[:profile] if user_prefs
 
       profile_config.kind_of?(Array) && profile_config.andand.each do |entry|
diff --git a/apps/workbench/app/controllers/users_controller.rb b/apps/workbench/app/controllers/users_controller.rb
index eb26d40..67b51a9 100644
--- a/apps/workbench/app/controllers/users_controller.rb
+++ b/apps/workbench/app/controllers/users_controller.rb
@@ -277,39 +277,6 @@ class UsersController < ApplicationController
     end
   end
 
-  def update_profile
-    profile_keys = []
-    profile_config = Rails.configuration.user_profile_form_fields
-    profile_config.andand.each do |entry|
-      profile_keys << entry['key']
-    end
-
-    updated_profile = {}
-    params.andand.each do |param|
-      if profile_keys.include? param[0]
-        if param[1].andand.size>0
-          updated_profile['profile_'+param[0]] = param[1]
-        end
-      end
-    end
-
-    if updated_profile.size > 0
-      # 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
-      user_prefs = User.limit(1).where(uuid: current_user.uuid).first.prefs
-      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
-    end
-
-    respond_to do |format|
-      format.js {render inline: "location.reload();"}
-    end
-  end
-
   protected
 
   def find_current_links user
diff --git a/apps/workbench/app/views/users/profile.html.erb b/apps/workbench/app/views/users/profile.html.erb
index 69c71dc..620b3ee 100644
--- a/apps/workbench/app/views/users/profile.html.erb
+++ b/apps/workbench/app/views/users/profile.html.erb
@@ -26,7 +26,8 @@
             <p> <%=profile_message%> </p><br/>
           </div>
           <div>
-            <%= form_tag update_profile_path, {method: 'put', id: 'save_profile_form', name: 'save_profile_form', class: 'form-horizontal', remote: true} do %>
+            <%= form_tag "/users/#{current_user.uuid}", {method: 'patch', id: 'save_profile_form', name: 'save_profile_form', class: 'form-horizontal'} do %>
+              <%= hidden_field_tag :return_to, request.url %>
               <div class="form-group">
                   <label for="email" class="col-sm-3 control-label"> Email </label>
                   <div class="col-sm-9">
@@ -67,7 +68,7 @@
                     </label>
                     <% if entry['type'] == 'select' %>
                       <div class="col-sm-9">
-                        <select class="form-control" id="<%=entry['key']%>" name="<%=entry['key']%>">
+                        <select class="form-control" id="user[prefs][:profile][:<%=entry['key']%>]" name="user[prefs][:profile][:<%=entry['key']%>]">
                           <% entry['options'].each do |option| %>
                             <option value="<%=option%>" <%='selected' if option==value%>><%=option%></option>
                           <% end %>
@@ -75,7 +76,7 @@
                       </div>
                     <% else %>
                       <div class="col-sm-9">
-                        <input type="text" class="form-control" id="<%=entry['key']%>" name="<%=entry['key']%>" placeholder="<%=entry['form_field_description']%>" value="<%=value%>" ></input>
+                        <input type="text" class="form-control" id="user[prefs][:profile][:<%=entry['key']%>]" name="user[prefs][:profile][:<%=entry['key']%>]" placeholder="<%=entry['form_field_description']%>" value="<%=value%>" ></input>
                       </div>
                     <% end %>
                   </div>
diff --git a/apps/workbench/config/routes.rb b/apps/workbench/config/routes.rb
index b63e8f6..4ef2661 100644
--- a/apps/workbench/config/routes.rb
+++ b/apps/workbench/config/routes.rb
@@ -10,7 +10,6 @@ ArvadosWorkbench::Application.routes.draw do
   get '/user_agreements/signatures' => 'user_agreements#signatures'
   get "users/setup_popup" => 'users#setup_popup', :as => :setup_user_popup
   get "users/setup" => 'users#setup', :as => :setup_user
-  put "users/update_profile" => 'users#update_profile', :as => :update_profile
   resources :nodes
   resources :humans
   resources :traits
diff --git a/services/api/app/controllers/arvados/v1/users_controller.rb b/services/api/app/controllers/arvados/v1/users_controller.rb
index 568dd97..a044fb7 100644
--- a/services/api/app/controllers/arvados/v1/users_controller.rb
+++ b/services/api/app/controllers/arvados/v1/users_controller.rb
@@ -114,22 +114,6 @@ class Arvados::V1::UsersController < ApplicationController
     show
   end
 
-  # 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
-
   protected
 
   def self._setup_requires_parameters
diff --git a/services/api/config/routes.rb b/services/api/config/routes.rb
index 85991f3..74d2aea 100644
--- a/services/api/config/routes.rb
+++ b/services/api/config/routes.rb
@@ -52,7 +52,6 @@ Server::Application.routes.draw do
         post 'activate', on: :member
         post 'setup', on: :collection
         post 'unsetup', on: :member
-        post 'profile', on: :member
       end
       resources :virtual_machines do
         get 'logins', on: :member

commit addce205a8b7bca49038167c2066d31efccad870
Author: radhika <radhika at curoverse.com>
Date:   Fri Aug 8 13:58:48 2014 -0400

    3296: add integration tests for topnav. also, enable profile as default test setting

diff --git a/apps/workbench/config/application.default.yml b/apps/workbench/config/application.default.yml
index 8ff1db7..e5c88b2 100644
--- a/apps/workbench/config/application.default.yml
+++ b/apps/workbench/config/application.default.yml
@@ -58,6 +58,26 @@ test:
 
   site_name: Workbench:test
 
+  # Enable user profile with one required field
+  user_profile_form_fields:
+    - message: Welcome to Curoverse.
+    - key: organization
+      type: text
+      form_field_title: Institution
+      form_field_description: Your organization
+      required: true
+    - key: role
+      type: select
+      form_field_title: Your role
+      form_field_description: Choose the category that best describes your role in your organization.
+      options:
+        - Bio-informatician
+        - Computational biologist
+        - Biologist or geneticist
+        - Software developer
+        - IT
+        - Other
+
 common:
   assets.js_compressor: false
   assets.css_compressor: false
@@ -76,7 +96,7 @@ common:
   send_user_setup_notification_email: true
 
   # Set user_profile_form_fields to enable and configure the user profile page.
-  # A commented setting with full description is provided below.
+  # Default is set to false. A commented setting with full description is provided below.
   user_profile_form_fields: false
 
   # Below is a sample setting of user_profile_form_fields.
@@ -91,7 +111,7 @@ common:
   # For each of these input fields:
   #   You can specify "type" as "text" or "select".
   #   List the "options" to be displayed for each of the "select" menu.
-  #   Set "required" as "true" for any of the fields to make them required.
+  #   Set "required" as "true" for any of these fields to make them required.
   # If any of the required fields are missing in the user's profile, the user will be
   # redirected to the profile page before they can access any Workbench features.
   #user_profile_form_fields:
@@ -104,7 +124,7 @@ common:
   #  - key: role
   #    type: select
   #    form_field_title: Your role
-  #    form_field_description: Choose the category that best describes your role in your lab.
+  #    form_field_description: Choose the category that best describes your role in your organization.
   #    options:
   #      - Bio-informatician
   #      - Computational biologist
diff --git a/apps/workbench/test/integration/application_layout_test.rb b/apps/workbench/test/integration/application_layout_test.rb
new file mode 100644
index 0000000..f4a56a2
--- /dev/null
+++ b/apps/workbench/test/integration/application_layout_test.rb
@@ -0,0 +1,288 @@
+require 'integration_helper'
+require 'selenium-webdriver'
+require 'headless'
+
+class ApplicationLayoutTest < ActionDispatch::IntegrationTest
+  setup do
+    headless = Headless.new
+    headless.start
+    Capybara.current_driver = :selenium
+
+    @user_profile_form_fields = Rails.configuration.user_profile_form_fields
+  end
+
+  teardown do
+    Rails.configuration.user_profile_form_fields = @user_profile_form_fields
+  end
+
+  def verify_homepage_with_profile user, invited, has_profile
+    profile_config = Rails.configuration.user_profile_form_fields
+
+    if !user
+      assert page.has_text? 'Please log in'
+      assert page.has_text? 'The "Log in" button below will show you a Google sign-in page'
+      assert page.has_no_text? 'My projects'
+      assert page.has_link? "Log in to #{Rails.configuration.site_name}"
+    elsif profile_config && !has_profile && user['is_active']
+      add_profile user
+    elsif user['is_active']
+      assert page.has_text? 'My projects'
+      assert page.has_text? 'Projects shared with me'
+      assert page.has_no_text? 'Save profile'
+    elsif invited
+      assert page.has_text? 'Please check the box below to indicate that you have read and accepted the user agreement'
+      assert page.has_no_text? 'Save profile'
+    else
+      assert page.has_text? 'Your account is inactive'
+      assert page.has_no_text? 'Save profile'
+    end
+
+    within('.navbar-fixed-top') do
+      if !user
+        assert page.has_link? 'Log in'
+      else
+        # my account menu
+        assert page.has_link? "#{user['email']}"
+        find('a', text: "#{user['email']}").click
+        within('.dropdown-menu') do
+          if !invited
+            page.has_no_link? ('Not active')
+          else
+            page.has_no_link? ('Sign agreements')
+            page.has_link? ('Manage account')
+
+            if profile_config
+              page.has_link? ('Manage profile')
+            else
+              page.has_no_link? ('Manage profile')
+            end
+          end
+          page.has_link? ('Log out')
+        end
+      end
+    end
+
+    # check help menu
+    check_help_menu
+
+    if user && user['is_active']
+      # check system menu
+      check_system_menu user
+
+      # test manage account page
+      check_manage_account_page user
+
+      # check search box
+      check_search_box user
+    end
+  end
+
+  # test the help menu
+  def check_help_menu
+    within('.navbar-fixed-top') do
+      page.find("#arv-help").click
+      within('.dropdown-menu') do
+        assert page.has_link? 'Tutorials and User guide'
+        assert page.has_link? 'API Reference'
+        assert page.has_link? 'SDK Reference'
+      end
+    end
+  end
+
+  # test the system menu
+  def check_system_menu user
+    if user && user['is_active']
+      look_for_add_new = nil
+      within('.navbar-fixed-top') do
+        page.find("#system-menu").click
+        if user['is_admin']
+          within('.dropdown-menu') do
+            assert page.has_text? 'Groups'
+            assert page.has_link? 'Repositories'
+            assert page.has_link? 'Virtual machines'
+            assert page.has_link? 'SSH keys'
+            assert page.has_link? 'API tokens'
+            find('a', text: 'Users').click
+            look_for_add_new = 'Add a new user'
+          end
+        else
+          within('.dropdown-menu') do
+            assert page.has_no_text? 'Users'
+            assert page.has_no_link? 'Repositories'
+            assert page.has_no_link? 'Virtual machines'
+            assert page.has_no_link? 'SSH keys'
+            assert page.has_no_link? 'API tokens'
+
+            find('a', text: 'Groups').click
+            look_for_add_new = 'Add a new group'
+          end
+        end
+      end
+      if look_for_add_new
+        assert page.has_text? look_for_add_new
+      end
+    else
+      assert page.has_no_link? '#system-menu'
+    end
+  end
+
+  # test manage_account page
+  def check_manage_account_page user
+    within('.navbar-fixed-top') do
+      find('a', text: "#{user['email']}").click
+      within('.dropdown-menu') do
+        find('a', text: 'Manage account').click
+      end
+    end
+
+    # now in manage account page
+    assert page.has_link? 'Virtual Machines'
+    assert page.has_link? 'Repositories'
+    assert page.has_link? 'SSH Keys'
+    assert page.has_link? 'Current Token'
+
+    assert page.has_text? 'The Arvados API token is a secret key that enables the Arvados SDKs to access Arvados'
+
+    click_link 'Add new SSH key'
+
+    within '.modal-content' do
+      assert page.has_text? 'Public Key'
+      assert page.has_button? 'Cancel'
+      assert page.has_button? 'Submit'
+
+      page.find_field('public_key').set 'first test with an incorrect ssh key value'
+      click_button 'Submit'
+      assert page.has_text? 'Public key does not appear to be a valid ssh-rsa or dsa public key'
+
+      public_key_str = api_fixture('authorized_keys')['active']['public_key']
+      page.find_field('public_key').set public_key_str
+      page.find_field('name').set 'added_in_test'
+      click_button 'Submit'
+      assert page.has_text? 'Public key already exists in the database, use a different key.'
+
+      new_key = SSHKey.generate
+      page.find_field('public_key').set new_key.ssh_public_key
+      page.find_field('name').set 'added_in_test'
+      click_button 'Submit'
+    end
+
+    # key must be added. look for it in the refreshed page
+    assert page.has_text? 'added_in_test'
+  end
+
+  # check manage profile page and add missing profile to the user
+  def add_profile user
+    assert page.has_no_text? 'My projects'
+    assert page.has_no_text? 'Projects shared with me'
+
+    assert page.has_text? 'Profile'
+    assert page.has_text? 'First name'
+    assert page.has_text? 'Last name'
+    assert page.has_text? 'Identity URL'
+    assert page.has_text? 'Email'
+    assert page.has_text? user['email']
+
+    # using the default profile which has message and one required field
+    profile_config = Rails.configuration.user_profile_form_fields
+    profile_message = ''
+    required_field_title = ''
+    required_field_key = ''
+    profile_config.andand.each do |entry| 
+      if entry['message']
+        profile_message = entry['message']
+      else
+        if entry['required']
+          required_field_key = entry['key']
+          required_field_title = entry['form_field_title']
+        end
+      end
+    end
+
+    assert page.has_text? profile_message
+    assert page.has_text? required_field_title
+
+    page.find_field(required_field_key).set 'value to fill required field'
+
+    click_button "Save profile"
+
+    # profile saved and in home page now
+    assert page.has_text? 'My projects'
+    assert page.has_text? 'Projects shared with me'
+  end
+
+  # test the search box
+  def check_search_box user
+    if user
+      # let's search for the anonymously accessible project
+      publicly_accessible_project = api_fixture('groups')['anonymously_accessible_project']
+
+      within('.navbar-fixed-top') do
+        page.find_field('search').set user['uuid']
+        page.find('.glyphicon-search').click
+        
+        # we should now be in the user's page as a result of search
+        assert page.has_text? user['email']
+
+        # search again for the anonymously accessible project
+        page.find_field('search').set publicly_accessible_project['name'][0,10]
+        page.find('.glyphicon-search').click
+      end
+
+      within '.modal-content' do
+        assert page.has_text? 'All projects'
+        assert page.has_text? 'Search'
+        assert page.has_text? 'Cancel'
+        assert_selector('div', text: publicly_accessible_project['name'])
+        find(:xpath, '//div[./span[contains(.,publicly_accessible_project["uuid"])]]').click
+
+        click_button 'Show'
+      end
+
+      # seeing "Unrestricted public data" now
+      assert page.has_text? publicly_accessible_project['name']
+      assert page.has_text? publicly_accessible_project['description']
+    end
+  end
+
+  [
+#    [nil, nil, false, false],
+#    ['inactive', api_fixture('users')['inactive'], true, false],
+#    ['inactive_uninvited', api_fixture('users')['inactive_uninvited'], false, false],
+#    ['active', api_fixture('users')['active'], true, true],
+#    ['admin', api_fixture('users')['admin'], true, true],
+    ['active_no_prefs', api_fixture('users')['active_no_prefs'], true, false],
+  ].each do |token, user, invited, has_profile|
+      test "visit home page when profile is configured for user #{token}" do
+      # Our test config enabled profile by default. So, no need to update config
+      if !token
+        visit ('/')
+      else
+        visit page_with_token(token)
+      end
+
+      verify_homepage_with_profile user, invited, has_profile
+    end
+  end
+=begin
+  [
+    [nil, nil, false, false],
+    ['inactive', api_fixture('users')['inactive'], true, false],
+    ['inactive_uninvited', api_fixture('users')['inactive_uninvited'], false, false],
+    ['active', api_fixture('users')['active'], true, true],
+    ['admin', api_fixture('users')['admin'], true, true],
+    ['active_no_prefs', api_fixture('users')['active_no_prefs'], true, false],
+  ].each do |token, user, invited, has_profile|
+    test "visit home page when profile not configured for user #{token}" do
+      Rails.configuration.user_profile_form_fields = false
+
+      if !token
+        visit ('/')
+      else
+        visit page_with_token(token)
+      end
+
+      verify_homepage_with_profile user, invited, has_profile
+    end
+  end
+=end
+end
diff --git a/services/api/test/fixtures/api_client_authorizations.yml b/services/api/test/fixtures/api_client_authorizations.yml
index 4fa4162..01667f7 100644
--- a/services/api/test/fixtures/api_client_authorizations.yml
+++ b/services/api/test/fixtures/api_client_authorizations.yml
@@ -162,3 +162,9 @@ job_reader:
   user: job_reader
   api_token: e99512cdc0f3415c2428b9758f33bdfb07bc3561b00e86e7e6
   expires_at: 2038-01-01 00:00:00
+
+active_no_prefs:
+  api_client: untrusted
+  user: active_no_prefs
+  api_token: 3kg612cdc0f3415c2428b9758f33bdfb07bc3561b00e86qdmi
+  expires_at: 2038-01-01 00:00:00
diff --git a/services/api/test/fixtures/users.yml b/services/api/test/fixtures/users.yml
index 0e02b7d..5ead254 100644
--- a/services/api/test/fixtures/users.yml
+++ b/services/api/test/fixtures/users.yml
@@ -9,7 +9,10 @@ admin:
   identity_url: https://admin.openid.local
   is_active: true
   is_admin: true
-  prefs: {}
+  prefs:
+    profile:
+      organization: Curoverse
+      role: IT
 
 miniadmin:
   owner_uuid: zzzzz-tpzed-000000000000000
@@ -20,7 +23,10 @@ miniadmin:
   identity_url: https://miniadmin.openid.local
   is_active: true
   is_admin: false
-  prefs: {}
+  prefs:
+    profile:
+      organization: Curoverse
+      role: IT
 
 rominiadmin:
   owner_uuid: zzzzz-tpzed-000000000000000
@@ -31,7 +37,10 @@ rominiadmin:
   identity_url: https://rominiadmin.openid.local
   is_active: true
   is_admin: false
-  prefs: {}
+  prefs:
+    profile:
+      organization: Curoverse
+      role: IT
 
 active:
   owner_uuid: zzzzz-tpzed-000000000000000
@@ -42,7 +51,10 @@ active:
   identity_url: https://active-user.openid.local
   is_active: true
   is_admin: false
-  prefs: {}
+  prefs:
+    profile:
+      organization: Curoverse
+      role: Computational biologist
 
 project_viewer:
   owner_uuid: zzzzz-tpzed-000000000000000
@@ -53,7 +65,10 @@ project_viewer:
   identity_url: https://project-viewer.openid.local
   is_active: true
   is_admin: false
-  prefs: {}
+  prefs:
+    profile:
+      organization: Curoverse
+      role: Computational biologist
 
 future_project_user:
   # Workbench tests give this user permission on aproject.
@@ -64,7 +79,10 @@ future_project_user:
   identity_url: https://future-project-user.openid.local
   is_active: true
   is_admin: false
-  prefs: {}
+  prefs:
+    profile:
+      organization: Curoverse
+      role: Computational biologist
 
 spectator:
   owner_uuid: zzzzz-tpzed-000000000000000
@@ -75,7 +93,10 @@ spectator:
   identity_url: https://spectator.openid.local
   is_active: true
   is_admin: false
-  prefs: {}
+  prefs:
+    profile:
+      organization: Curoverse
+      role: Computational biologist
 
 inactive_uninvited:
   owner_uuid: zzzzz-tpzed-000000000000000
@@ -129,4 +150,18 @@ job_reader:
   identity_url: https://spectator.openid.local
   is_active: true
   is_admin: false
+  prefs:
+    profile:
+      organization: Curoverse
+      role: Computational biologist
+
+active_no_prefs:
+  owner_uuid: zzzzz-tpzed-000000000000000
+  uuid: zzzzz-tpzed-a46c42d1td4aoj4
+  email: active_no_profile at arvados.local
+  first_name: NoPrefs
+  last_name: NoProfile
+  identity_url: https://active_no_prefs.openid.local
+  is_active: true
+  is_admin: false
   prefs: {}

commit b14aa29daff5264bd2352ec1a61b222c9e7812a2
Author: radhika <radhika at curoverse.com>
Date:   Thu Aug 7 09:17:42 2014 -0400

    3296: improve config parameter explanation

diff --git a/apps/workbench/config/application.default.yml b/apps/workbench/config/application.default.yml
index a19f707..8ff1db7 100644
--- a/apps/workbench/config/application.default.yml
+++ b/apps/workbench/config/application.default.yml
@@ -80,13 +80,20 @@ common:
   user_profile_form_fields: false
 
   # Below is a sample setting of user_profile_form_fields.
-  # Use "message" to configure a message you want to display at the top of the profile page.
-  # This sample configures two fields as represented by the attribute "key". For these fields,
+  # This configuration parameter should be set to either false (to disable) or
+  # to an array as shown below. This parameter supports two types of fields,
+  # an optional "message" and an optional list of input fields.
+  # Use "message" to configure the message you want to display at the top of the
+  # profile page. If this is not provided, a default message will be displayed.
+  # Configure the list of input fields to be displayed in the profile page
+  # using the attribute "key" for each of the input fields.
+  # This sample shows configuration with message and two input fields.
+  # For each of these input fields:
   #   You can specify "type" as "text" or "select".
-  #   Specify "options" when using the type "select".
+  #   List the "options" to be displayed for each of the "select" menu.
   #   Set "required" as "true" for any of the fields to make them required.
-  #   If any of the required fields are missing in the user's profile, the user will be
-  #   redirected to the profile page before they can access any Workbench features.
+  # If any of the required fields are missing in the user's profile, the user will be
+  # redirected to the profile page before they can access any Workbench features.
   #user_profile_form_fields:
   #  - message: Welcome to Curoverse. Any fields in red are required and missing. Please fill in those fields before you can access Arvados Workbench.
   #  - key: organization

commit f3e546e73898e9ff57fb45e53b9f009265cd7ddd
Author: radhika <radhika at curoverse.com>
Date:   Wed Aug 6 23:52:10 2014 -0400

    3296: profile config edge cases

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index fd3a000..c488023 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -515,7 +515,9 @@ class ApplicationController < ActionController::Base
   def check_user_profile
     profile_config = Rails.configuration.user_profile_form_fields
 
-    if request.method.downcase != 'get' || params[:partials]
+    if request.method.downcase != 'get' || params[:partial] ||
+       params[:tab_pane] || params[:action_method] ||
+       params[:action] == 'setup_popup'
       return true
     end
 
@@ -525,7 +527,7 @@ class ApplicationController < ActionController::Base
       user_prefs = User.limit(1).where(uuid: current_user.uuid).first.prefs
       current_user_profile = user_prefs[:profile] if user_prefs
 
-      profile_config.andand.each do |entry|
+      profile_config.kind_of?(Array) && profile_config.andand.each do |entry|
         if entry['required']
           if !current_user_profile || !current_user_profile[entry['key'].to_sym]
             missing_required_profile = true
diff --git a/apps/workbench/app/controllers/users_controller.rb b/apps/workbench/app/controllers/users_controller.rb
index d4b917b..eb26d40 100644
--- a/apps/workbench/app/controllers/users_controller.rb
+++ b/apps/workbench/app/controllers/users_controller.rb
@@ -278,8 +278,6 @@ class UsersController < ApplicationController
   end
 
   def update_profile
-    user_prefs = User.limit(1).where(uuid: current_user.uuid).first.prefs
-
     profile_keys = []
     profile_config = Rails.configuration.user_profile_form_fields
     profile_config.andand.each do |entry|
@@ -295,14 +293,18 @@ 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
+    if updated_profile.size > 0
+      # 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
+      user_prefs = User.limit(1).where(uuid: current_user.uuid).first.prefs
+      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
     end
 
-    current_user.update_profile updated_profile
     respond_to do |format|
       format.js {render inline: "location.reload();"}
     end
diff --git a/apps/workbench/app/views/users/profile.html.erb b/apps/workbench/app/views/users/profile.html.erb
index 6af3662..69c71dc 100644
--- a/apps/workbench/app/views/users/profile.html.erb
+++ b/apps/workbench/app/views/users/profile.html.erb
@@ -1,9 +1,11 @@
-<% 
+<%
     profile_config = Rails.configuration.user_profile_form_fields
     this_user = User.limit(1).where(uuid: current_user.uuid).first
     user_prefs = User.limit(1).where(uuid: current_user.uuid).first.prefs
     current_user_profile = user_prefs[:profile] if user_prefs
+    show_save_button = false
 %>
+
 <div>
     <div class="panel panel-default">
         <div class="panel-heading">
@@ -15,7 +17,7 @@
           <div>
             <% profile_message = 'You can manage your profile using this page. Any feilds in red are required and missing.
                   Please fill in those fields before you can accesse Arvados Workbench.'
-                profile_config.andand.each do |entry| 
+                  profile_config.kind_of?(Array) && profile_config.andand.each do |entry| 
                   if entry['message']
                     profile_message = entry['message']
                     break
@@ -50,9 +52,10 @@
                   </div>
               </div>
 
-              <% profile_config.andand.each do |entry| %>
+              <% profile_config.kind_of?(Array) && profile_config.andand.each do |entry| %>
                 <% if entry['key'] %>
                   <%
+                      show_save_button = true
                       label = entry['required'] ? '* ' : ''
                       label += entry['form_field_title']
                       value = current_user_profile[entry['key'].to_sym] if current_user_profile
@@ -79,11 +82,13 @@
                 <% end %>
               <% end %>
 
-              <div class="form-group">
-                <div class="col-sm-offset-3 col-sm-9">
-                  <button type="submit" class="btn btn-primary">Save profile</button>
+              <% if show_save_button %>
+                <div class="form-group">
+                  <div class="col-sm-offset-3 col-sm-9">
+                    <button type="submit" class="btn btn-primary">Save profile</button>
+                  </div>
                 </div>
-              </div>
+              <% end %>
             <% end %>
           </div>
         </div>

commit d7e17c51907d658d2d4e2794044486ebe007126d
Author: radhika <radhika at curoverse.com>
Date:   Wed Aug 6 21:23:40 2014 -0400

    3296: add profile also in the notification email

diff --git a/services/api/app/views/profile_notifier/profile_created.text.erb b/services/api/app/views/profile_notifier/profile_created.text.erb
index d84b05a..73adf28 100644
--- a/services/api/app/views/profile_notifier/profile_created.text.erb
+++ b/services/api/app/views/profile_notifier/profile_created.text.erb
@@ -1 +1,2 @@
 Profile created by user <%=@user.full_name%> <%=@user.email%>
+User's profile: <%=@user.prefs['profile']%>

commit fde712e92ad33e03dfd79f5fca99d2005cdd0795
Merge: c424885 b82d80a
Author: radhika <radhika at curoverse.com>
Date:   Wed Aug 6 21:11:30 2014 -0400

    Merge branch 'master' into 3296-user-profile


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


hooks/post-receive
-- 




More information about the arvados-commits mailing list