Merge branch '2872-folder-nav' into 2872-folder-nav-tests
authorradhika <radhika@curoverse.com>
Fri, 6 Jun 2014 11:27:16 +0000 (07:27 -0400)
committerradhika <radhika@curoverse.com>
Fri, 6 Jun 2014 11:27:16 +0000 (07:27 -0400)
13 files changed:
apps/workbench/app/controllers/application_controller.rb
apps/workbench/app/controllers/collections_controller.rb
apps/workbench/app/controllers/users_controller.rb
apps/workbench/app/helpers/application_helper.rb
apps/workbench/app/views/application/show.html.erb
apps/workbench/app/views/collections/show.html.erb
apps/workbench/app/views/layouts/application.html.erb
apps/workbench/app/views/pipeline_instances/_show_inputs.html.erb
apps/workbench/app/views/users/inactive.html.erb [new file with mode: 0644]
apps/workbench/app/views/users/welcome.html.erb
apps/workbench/test/functional/collections_controller_test.rb
apps/workbench/test/functional/folders_controller_test.rb
apps/workbench/test/integration/logins_test.rb

index a5034fd895593a8c9e1573e41730bce1f015dc54..d410da9326bd38f1309b0246f5e5d619013bf4e0 100644 (file)
@@ -368,8 +368,18 @@ class ApplicationController < ActionController::Base
   end
 
   def thread_with_mandatory_api_token
-    thread_with_api_token do
-      yield
+    thread_with_api_token(true) do
+      if Thread.current[:arvados_api_token]
+        yield
+      elsif session[:arvados_api_token]
+        # Expired session. Clear it before refreshing login so that,
+        # if this login procedure fails, we end up showing the "please
+        # log in" page instead of getting stuck in a redirect loop.
+        session.delete :arvados_api_token
+        redirect_to_login
+      else
+        render 'users/welcome'
+      end
     end
   end
 
@@ -403,7 +413,10 @@ class ApplicationController < ActionController::Base
   end
 
   def check_user_agreements
-    if current_user && !current_user.is_active && current_user.is_invited
+    if current_user && !current_user.is_active
+      if not current_user.is_invited
+        return render 'users/inactive'
+      end
       signatures = UserAgreement.signatures
       @signed_ua_uuids = UserAgreement.signatures.map &:head_uuid
       @required_user_agreements = UserAgreement.all.map do |ua|
index 24b9b1f755780ee132119198267c9577e2180411..bf576258598ddf6904fac22c82dfdce313c6ec82 100644 (file)
@@ -3,6 +3,8 @@ class CollectionsController < ApplicationController
                      only: [:show_file, :show_file_links])
   skip_before_filter(:find_object_by_uuid,
                      only: [:provenance, :show_file, :show_file_links])
+  # We depend on show_file to display the user agreement:
+  skip_before_filter :check_user_agreements, only: [:show_file]
 
   RELATION_LIMIT = 5
 
index 3d8c8530add9aecd27898bc0325bfa44d8be165f..0313de5aa2e7b9559146b9cfca7a6f31b166862d 100644 (file)
@@ -1,6 +1,5 @@
 class UsersController < ApplicationController
   skip_before_filter :find_object_by_uuid, :only => [:welcome, :activity, :storage]
-  skip_around_filter :thread_with_mandatory_api_token, :only => :welcome
   before_filter :ensure_current_user_is_admin, only: [:sudo, :unsetup, :setup]
 
   def welcome
index e23376bcf7b4fd76ff22da11dbea9e9f97e7fe00..552e79e699739f4f1e6b02390304c6dcff55cf43 100644 (file)
@@ -326,8 +326,9 @@ module ApplicationHelper
       "data-title" => "Set value for #{subattr[-1].to_s}",
       "data-name" => dn,
       "data-pk" => "{id: \"#{object.uuid}\", key: \"#{object.class.to_s.underscore}\"}",
-      "data-showbuttons" => "false",
       "data-value" => attrvalue,
+      # "clear" button interferes with form-control's up/down arrows
+      "data-clear" => false,
       :class => "editable #{'required' if required} form-control",
       :id => id
     }.merge(htmloptions)
index 9da8ea1518d3ecf9e5bcf47446220659a6f90227..d6eca3a2155d2e7c50b58e030884fc5c8f323dcc 100644 (file)
@@ -1,6 +1,7 @@
 <% content_for :page_title do %>
   <%= (@object.respond_to?(:properties) ? @object.properties[:page_title] : nil) ||
-        @object.friendly_link_name %>
+      @name_link.andand.name ||
+      @object.friendly_link_name %>
 <% end %>
 
 <% content_for :content_top do %>
index 16497c777130d2181fd53eace1c76f198644ee7d..25cd845fe61f81769e6ebdfdf8024d453ece51e9 100644 (file)
        <input type="text" class="form-control" placeholder="Search"/>
         -->
        <div style="height:0.5em;"></div>
-        <% if not @logs.andand.any? %>
+        <% name_or_object = @name_link.andand.uuid ? @name_link : @object %>
+        <% if name_or_object.created_at and not @logs.andand.any? %>
           <p>
-            Created: <%= @object.created_at.to_s(:long) %>
+            Created: <%= name_or_object.created_at.to_s(:long) %>
           </p>
           <p>
-            Last modified: <%= @object.modified_at.to_s(:long) %> by <%= link_to_if_arvados_object @object.modified_by_user_uuid, friendly_name: true %>
+            Last modified: <%= name_or_object.modified_at.to_s(:long) %> by <%= link_to_if_arvados_object name_or_object.modified_by_user_uuid, friendly_name: true %>
           </p>
         <% else %>
           <%= render_arvados_object_list_start(@logs, 'Show all activity',
-                logs_path(filters: [['object_uuid','=',@object.uuid]].to_json)) do |log| %>
+                logs_path(filters: [['object_uuid','=',name_or_object.uuid]].to_json)) do |log| %>
           <p>
           <%= time_ago_in_words(log.event_at) rescue 'unknown time' %> ago: <%= log.summary %>
             <% if log.object_uuid %>
index 6359794312f2c3dc0713d1e00d579b524d2b0fb8..32a0f9194e7f8ada1590899353589d30abef060b 100644 (file)
@@ -82,7 +82,7 @@
                   <span class="glyphicon glyphicon-arrow-right"></span>
                 </li>
                 <li>
-                  <%= link_to_if_arvados_object @object, {friendly_name: true}, {data: {object_uuid: @object.andand.uuid, name: 'name'}} %>
+                  <%= link_to_if_arvados_object (@name_link || @object), {friendly_name: true}, {data: {object_uuid: (@name_link.andand.uuid || @object.andand.uuid), name: 'name'}} %>
                 </li>
               <% end %>
             <% end %>
index 354ebd2ec5d82c21f05cf402ff46ea5cfa8e06ca..5106710b0eb1c580ca5f393f265b806f64c914c6 100644 (file)
@@ -32,7 +32,7 @@
 <% end %>
 
 <% if n_inputs == 0 %>
-  <p>This pipeline does not need any further inputs specified. You can start it by clicking the "Run" button.</p>
+  <p>This pipeline does not need any further inputs specified. You can start it by clicking the "Run" button whenever you're ready. (It's not too late to change existing settings, though.)</p>
 <% else %>
   <p><i>Provide <%= n_inputs > 1 ? 'values' : 'a value' %> for the following <%= n_inputs > 1 ? 'parameters' : 'parameter' %>, then click the "Run" button to start the pipeline.</i></p>
   <%= content_for :pi_input_form %>
@@ -47,5 +47,5 @@
 <% end %>
 
 <div style="margin-top: 1em;">
-  <p>Click the "Components" tab above to see a full list of pipeline components and parameters.</p>
+  <p>Click the "Components" tab above to see a full list of pipeline settings.</p>
 </div>
diff --git a/apps/workbench/app/views/users/inactive.html.erb b/apps/workbench/app/views/users/inactive.html.erb
new file mode 100644 (file)
index 0000000..5f825e4
--- /dev/null
@@ -0,0 +1,22 @@
+<% content_for :breadcrumbs do raw '<!-- -->' end %>
+
+<div class="row">
+  <div class="col-sm-8 col-sm-push-4" style="margin-top: 1em">
+    <div class="well clearfix">
+      <%= image_tag "dax.png", style: "width: 147px; height: 197px; max-width: 25%; margin-right: 2em", class: 'pull-left' %>
+
+      <h3>Hi! You're logged in, but...</h3>
+
+      <p>
+
+        Your account is inactive.
+
+      </p><p>
+
+        An administrator must activate your account before you can get
+        any further.
+
+      </p>
+    </div>
+  </div>
+</div>
index 537041e8f8871c45749db7a3e04c2b5f4520f333..9cacebda02971ccdbff2d28569dd7a6d55e35cff 100644 (file)
@@ -1,23 +1,38 @@
 <% content_for :breadcrumbs do raw '<!-- -->' end %>
 
-<%= image_tag "dax.png", style: "float: left; max-width: 25%; margin-right: 2em" %>
-<h1>Hi there!  Please log in to use <%= Rails.configuration.site_name %>.</h1>
-<div class="row-fluid">
-  <div class="col span8" style="margin-top: 1em">
+<div class="row">
+  <div class="col-sm-8 col-sm-push-4" style="margin-top: 1em">
     <div class="well clearfix">
-      <p>When you click on the button below you will be taken to a Google sign-in page.
-       After entering your information, you will be redirected back to <%= Rails.configuration.site_name %>
-       If you have never used <%= Rails.configuration.site_name %> before, logging in for the first
-       time will also create a new user account. <%= Rails.configuration.site_name %> uses your name and
-       email address from Google services only for identification, and can not access any personal information
-  beyond that.
-  </p>
+      <%= image_tag "dax.png", style: "width: 147px; height: 197px; max-width: 25%; margin-right: 2em", class: 'pull-left' %>
+
+      <h3>Please log in.</h3>
+
+      <p>
+
+        The "Log in" button below will show you a Google sign-in page.
+       After you assure Google that you want to log in here with your
+       Google account, you will be redirected back here to
+       <%= Rails.configuration.site_name %>.
+
+      </p><p>
+
+       If you have never used <%= Rails.configuration.site_name %>
+       before, logging in for the first time will automatically
+       create a new account.
+
+      </p><p>
+
+        <i><%= Rails.configuration.site_name %> uses your name and
+       email address only for identification, and does not retrieve
+       any other personal information from Google.</i>
+
+      </p>
       <p>
-       <a  class="pull-right btn btn-primary" href="<%= arvados_api_client.arvados_login_url(return_to: request.url) %>">
-         Click here to log in to <%= Rails.configuration.site_name %> with a Google account</a>
+       <%= link_to arvados_api_client.arvados_login_url(return_to: request.url), class: "pull-right btn btn-primary" do %>
+          Log in to <%= Rails.configuration.site_name %>
+          <i class="fa fa-fw fa-arrow-circle-right"></i>
+        <% end %>
       </p>
     </div>
   </div>
 </div>
-
-
index 19d08d73b35896b8116eb42c7d8dfecf42294177..852772ae832aead966bcf2292cbf1a4301aa9459 100644 (file)
@@ -153,4 +153,16 @@ class CollectionsControllerTest < ActionController::TestCase
     assert_not_equal(read_token, session[:arvados_api_token],
                      "using a reader token set the session's API token")
   end
+
+  test "inactive user can retrieve user agreement" do
+    ua_collection = api_fixture('collections')['user_agreement']
+    get :show_file, {
+      uuid: ua_collection['uuid'],
+      file: ua_collection['manifest_text'].match(/ \d+:\d+:(\S+)/)[1]
+    }, session_for(:inactive)
+    assert_nil(assigns(:required_user_agreements),
+               "Did not skip check_user_agreements filter " +
+               "when showing the user agreement.")
+    assert_response :success
+  end
 end
index 2e06ccac31815a38d555a9848604ffcc6d394c10..8459278fafd5ef315829a258c6460250a959ca5f 100644 (file)
@@ -1,7 +1,12 @@
 require 'test_helper'
 
 class FoldersControllerTest < ActionController::TestCase
-  # test "the truth" do
-  #   assert true
-  # end
+  test "inactive user is asked to sign user agreements on front page" do
+    get :index, {}, session_for(:inactive)
+    assert_response :success
+    assert_not_empty assigns(:required_user_agreements),
+    "Inactive user did not have required_user_agreements"
+    assert_template 'user_agreements/index',
+    "Inactive user was not presented with a user agreement at the front page"
+  end
 end
index 6e5389e7cc11d0a4d6c7c4808023476346e9c978..19b6e4bf75d87e1dd2c0514034b6b452689ccd44 100644 (file)
@@ -13,10 +13,9 @@ class LoginsTest < ActionDispatch::IntegrationTest
   end
 
   test "expired token yields login page, not error page" do
-    skip
     visit page_with_token('expired_trustedclient')
     # Even the error page has a "Log in" link. We should look for
     # something that only appears the real login page.
-    assert page.has_text? 'Please log in'
+    assert page.has_text? 'log in here with your Google account'
   end
 end