[ARVADOS] created: 1a0ba80d44b4be962f898ee1458faea9d4a59137
git at public.curoverse.com
git at public.curoverse.com
Fri May 22 16:41:07 EDT 2015
at 1a0ba80d44b4be962f898ee1458faea9d4a59137 (commit)
commit 1a0ba80d44b4be962f898ee1458faea9d4a59137
Merge: 71f1ccb 3bf22ae
Author: radhika <radhika at curoverse.com>
Date: Fri May 22 16:40:59 2015 -0400
Merge branch 'master' into 6057-public-projects-page
commit 71f1ccba7367ca9d000e53c0b86c0448600350f4
Author: radhika <radhika at curoverse.com>
Date: Fri May 22 16:39:57 2015 -0400
6057: add projects/public page, which lists publicly accessible projects.
diff --git a/apps/workbench/app/controllers/projects_controller.rb b/apps/workbench/app/controllers/projects_controller.rb
index b43ad65..dec26c3 100644
--- a/apps/workbench/app/controllers/projects_controller.rb
+++ b/apps/workbench/app/controllers/projects_controller.rb
@@ -1,8 +1,8 @@
class ProjectsController < ApplicationController
- before_filter :set_share_links, if: -> { defined? @object }
+ before_filter :set_share_links, if: -> { defined? @object and @object}
skip_around_filter :require_thread_api_token, if: proc { |ctrl|
Rails.configuration.anonymous_user_token and
- %w(show tab_counts).include? ctrl.action_name
+ %w(show tab_counts public).include? ctrl.action_name
}
def model_class
@@ -307,4 +307,15 @@ class ProjectsController < ApplicationController
end
objects_and_names
end
+
+ def public # Yes 'public' is the name of the action for public projects
+ if Rails.configuration.anonymous_user_token
+ @public_projects = using_specific_api_token Rails.configuration.anonymous_user_token do
+ Group.where(group_class: 'project').order("updated_at DESC")
+ end
+ render 'public_projects'
+ else
+ redirect_to '/projects'
+ end
+ end
end
diff --git a/apps/workbench/app/views/layouts/body.html.erb b/apps/workbench/app/views/layouts/body.html.erb
index 9f253a4..6c23035 100644
--- a/apps/workbench/app/views/layouts/body.html.erb
+++ b/apps/workbench/app/views/layouts/body.html.erb
@@ -116,6 +116,9 @@
</li>
<% end %>
<% else %>
+ <% if Rails.configuration.anonymous_user_token %>
+ <li><%= link_to raw('Browse public projects'), "/projects/public" %></li>
+ <% end %>
<li class="dropdown hover-dropdown login-menu">
<a href="<%= arvados_api_client.arvados_login_url(return_to: root_url) %>">Log in</a>
<ul class="dropdown-menu">
@@ -180,6 +183,9 @@
<span class="caret"></span>
</a>
<ul class="dropdown-menu" style="min-width: 20em" role="menu">
+ <% if Rails.configuration.anonymous_user_token %>
+ <li><%= link_to raw('Browse public projects'), "/projects/public", class: 'btn btn-xs btn-default pull-right' %></li>
+ <% end %>
<li>
<%= link_to projects_path(options: {ensure_unique_name: true}), method: :post, class: 'btn btn-xs btn-default pull-right' do %>
<i class="fa fa-plus"></i> Add a new project
diff --git a/apps/workbench/app/views/projects/public_projects.html.erb b/apps/workbench/app/views/projects/public_projects.html.erb
new file mode 100644
index 0000000..fdae70e
--- /dev/null
+++ b/apps/workbench/app/views/projects/public_projects.html.erb
@@ -0,0 +1,26 @@
+<table class="table arv-public-projects" style="width: 100%;">
+ <colgroup>
+ <col width="25%" />
+ <col width="75%" />
+ </colgroup>
+ <thead>
+ <tr class="contain-align-left">
+ <th>
+ Name
+ </th><th>
+ Description
+ </tr>
+ </thead>
+
+ <% @public_projects.each do |p| %>
+ <tr>
+ <td style="word-break:break-all;">
+ <%= link_to_if_arvados_object p, {friendly_name: true} %>
+ </div></td>
+ <td style="word-break:break-all;">
+ <%= render_attribute_as_textile(p, "description", p.description, true) %>
+ </div></td>
+ </tr>
+ <% end %>
+</table>
+
diff --git a/apps/workbench/config/routes.rb b/apps/workbench/config/routes.rb
index 44d7ded..b2d48ff 100644
--- a/apps/workbench/config/routes.rb
+++ b/apps/workbench/config/routes.rb
@@ -82,7 +82,9 @@ ArvadosWorkbench::Application.routes.draw do
get 'choose', on: :collection
post 'share_with', on: :member
get 'tab_counts', on: :member
+ get 'public', on: :collection
end
+
resources :search do
get 'choose', :on => :collection
end
diff --git a/apps/workbench/test/integration/anonymous_access_test.rb b/apps/workbench/test/integration/anonymous_access_test.rb
index 1e486d8..a4155fb 100644
--- a/apps/workbench/test/integration/anonymous_access_test.rb
+++ b/apps/workbench/test/integration/anonymous_access_test.rb
@@ -35,6 +35,7 @@ class AnonymousAccessTest < ActionDispatch::IntegrationTest
assert_text Rails.configuration.site_name.downcase
assert_no_selector 'a', text: Rails.configuration.site_name.downcase
assert_selector 'a', text: 'Log in'
+ assert_selector 'a', text: 'Browse public projects'
end
end
end
diff --git a/apps/workbench/test/integration/projects_test.rb b/apps/workbench/test/integration/projects_test.rb
index 9c2842f..84237ae 100644
--- a/apps/workbench/test/integration/projects_test.rb
+++ b/apps/workbench/test/integration/projects_test.rb
@@ -830,4 +830,42 @@ class ProjectsTest < ActionDispatch::IntegrationTest
assert_no_selector 'li.disabled', text: 'Copy selected'
end
end
+
+ [
+ [true, nil, true],
+ [true, 'active', true],
+ [false, nil, false],
+ [false, 'active', false],
+ ].each do |anon_config, user, expect_page|
+ test "visit public_projects page when anon config enabled #{anon_config}, as user #{user}, and expect page #{expect_page}" do
+ Rails.configuration.anonymous_user_token = api_fixture('api_client_authorizations')['anonymous']['api_token'] if anon_config
+
+ if user
+ visit page_with_token user, '/projects/public'
+ else
+ visit '/public_projects'
+ end
+
+ # verify public projects are listed
+ assert_selector 'a', 'Unrestricted public data'
+
+ if user
+ find("#projects-menu").click
+ if anon_config
+ assert_selector 'a', text: 'Browse public projects'
+ else
+ assert_no_selector 'a', text: 'Browse public projects'
+ end
+ else
+ within('.navbar-fixed-top') do
+ assert_selector 'a', text: 'Log in'
+ if anon_config
+ assert_selector 'a', text: 'Browse public projects'
+ else
+ assert_no_selector 'a', text: 'Browse public projects'
+ end
+ end
+ end
+ end
+ end
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list