[ARVADOS] updated: b78fae0b4f9633b59ce2f0bea9d75ce5ec96065f

git at public.curoverse.com git at public.curoverse.com
Sun Jun 22 11:43:03 EDT 2014


Summary of changes:
 .../app/controllers/application_controller.rb       | 19 +++++++++++++------
 .../app/views/layouts/application.html.erb          | 11 +++++++++--
 .../app/views/user_agreements/index.html.erb        |  7 +------
 .../test/integration/anonymous_user_test.rb         | 21 +++++++++++++++++----
 4 files changed, 40 insertions(+), 18 deletions(-)

       via  b78fae0b4f9633b59ce2f0bea9d75ce5ec96065f (commit)
      from  1621df028129634f1ad057ee9aad3179fd9afa95 (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 b78fae0b4f9633b59ce2f0bea9d75ce5ec96065f
Author: radhika <radhika at curoverse.com>
Date:   Sun Jun 22 11:42:39 2014 -0400

    2659: user agreements

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index 43d0d0d..82191ec 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -541,6 +541,17 @@ class ApplicationController < ActionController::Base
       if not current_user.is_invited
         return render 'users/inactive'
       end
+
+      check_user_agreements_signatures true
+      if !current_user.is_active
+        render 'user_agreements/index'
+      end
+    end
+    true
+  end
+
+  helper_method :check_user_agreements_signatures
+  def check_user_agreements_signatures try_to_activate
       signatures = UserAgreement.signatures
       @signed_ua_uuids = UserAgreement.signatures.map &:head_uuid
       @required_user_agreements = UserAgreement.all.map do |ua|
@@ -548,7 +559,7 @@ class ApplicationController < ActionController::Base
           Collection.find(ua.uuid)
         end
       end.compact
-      if @required_user_agreements.empty?
+      if @required_user_agreements.empty? && try_to_activate
         # No agreements to sign. Perhaps we just need to ask?
         current_user.activate
         if !current_user.is_active
@@ -556,11 +567,7 @@ class ApplicationController < ActionController::Base
             "No user agreements to sign, but activate failed!"
         end
       end
-      if !current_user.is_active
-        render 'user_agreements/index'
-      end
-    end
-    true
+      @required_user_agreements
   end
 
   def select_theme
diff --git a/apps/workbench/app/views/layouts/application.html.erb b/apps/workbench/app/views/layouts/application.html.erb
index 6dbc2c2..d925025 100644
--- a/apps/workbench/app/views/layouts/application.html.erb
+++ b/apps/workbench/app/views/layouts/application.html.erb
@@ -92,9 +92,16 @@
 
               <% if anonymous_login_enabled && !current_user.is_active %> 
                 <% if !current_user.is_invited %>
-                  <li role="presentation"><a href="/users/welcome" role="menuitem"><i class="fa fa-sign-out fa-fw"></i> Inactive </a></li>
+                  <li role="presentation"><a href="/users/welcome" role="menuitem"><i class="fa fa-sign-out fa-fw"></i> Not active </a></li>
                 <% else %>
-                  <li role="presentation"><a href="/user_agreements" role="menuitem"><i class="fa fa-sign-out fa-fw"></i> Inactive </a></li>
+                  <% required_user_agreements = check_user_agreements_signatures true %>
+                  <% if !current_user.is_active %>
+                    <% if required_user_agreements.empty? %>
+                      <li role="presentation"><a href="/users/welcome" role="menuitem"><i class="fa fa-sign-out fa-fw"></i> Not active </a></li>
+                    <% else %>
+                      <li role="presentation"><a href="/user_agreements" role="menuitem"><i class="fa fa-sign-out fa-fw"></i> Sign agreements </a></li>
+                    <% end %>
+                  <% end %>
                 <% end %>
               <% end %>
 
diff --git a/apps/workbench/app/views/user_agreements/index.html.erb b/apps/workbench/app/views/user_agreements/index.html.erb
index c432b39..aec5d66 100644
--- a/apps/workbench/app/views/user_agreements/index.html.erb
+++ b/apps/workbench/app/views/user_agreements/index.html.erb
@@ -2,12 +2,7 @@
 
 <%
   if !@required_user_agreements
-    @signed_ua_uuids = UserAgreement.signatures.map &:head_uuid
-    @required_user_agreements = UserAgreement.all.map do |ua|
-      if not @signed_ua_uuids.index ua.uuid
-        Collection.find(ua.uuid)
-      end
-    end.compact
+    @required_user_agreements = check_user_agreements_signatures false
   end
 %>
 
diff --git a/apps/workbench/test/integration/anonymous_user_test.rb b/apps/workbench/test/integration/anonymous_user_test.rb
index 2a5da9b..8c16073 100644
--- a/apps/workbench/test/integration/anonymous_user_test.rb
+++ b/apps/workbench/test/integration/anonymous_user_test.rb
@@ -24,7 +24,8 @@ class AnonymousUserTest < ActionDispatch::IntegrationTest
         find('a', text: "#{user['email']}").click
         within('.dropdown-menu') do
           page.has_link? ('Logout')
-          page.has_no_link? ('Inactive')
+          page.has_no_link? ('Not active')
+          page.has_no_link? ('Sign agreements')
           page.has_link? ('Manage ssh keys')
           page.has_link? ('Manage API tokens')
         end
@@ -38,7 +39,11 @@ class AnonymousUserTest < ActionDispatch::IntegrationTest
           find('a', text: "#{user['email']}").click
           within('.dropdown-menu') do
             page.has_link? ('Logout')
-            page.has_link? ('Inactive')
+            if !invited
+              page.has_link? ('Not active')
+            else
+              page.has_link? ('Sign agreements')
+            end
             page.has_no_link? ('Manage ssh keys')
             page.has_no_link? ('Manage API tokens')
           end
@@ -94,7 +99,11 @@ class AnonymousUserTest < ActionDispatch::IntegrationTest
       within('.navbar-fixed-top') do
         find('a', text: "#{user['email']}").click
         within('.dropdown-menu') do
-          find('a', text: 'Inactive').click
+          if !invited
+            find('a', text: 'Not active').click
+          else
+            find('a', text: 'Sign agreements').click
+          end
         end
       end
           
@@ -116,7 +125,11 @@ class AnonymousUserTest < ActionDispatch::IntegrationTest
         find('a', text: "#{user['email']}").click
         within('.dropdown-menu') do
           page.has_link? ('Logout')
-          page.has_no_link? ('Inactive')
+          if !invited
+            page.has_no_link? ('Not active')
+          else
+            page.has_no_link? ('Sign agreements')
+          end
         end
       end
     end

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list