[ARVADOS] updated: 0f92cdd76a8ecc456e0ab068abce468e3a169bc0
git at public.curoverse.com
git at public.curoverse.com
Tue Apr 8 13:13:21 EDT 2014
Summary of changes:
apps/workbench/Gemfile | 3 +-
apps/workbench/Gemfile.lock | 4 +
apps/workbench/README.textile | 14 ++
.../app/assets/javascripts/application.js | 1 +
apps/workbench/app/controllers/users_controller.rb | 92 +++++++++-
apps/workbench/app/models/user.rb | 4 +
.../workbench/app/views/application/index.html.erb | 19 ++-
.../app/views/layouts/application.html.erb | 1 +
.../app/views/users/_setup_popup.html.erb | 69 +++++++
.../workbench/app/views/users/_show_admin.html.erb | 10 +
apps/workbench/app/views/users/setup.js.erb | 2 +
apps/workbench/app/views/users/setup_popup.js.erb | 44 +++++
apps/workbench/config/application.default.yml | 1 +
apps/workbench/config/routes.rb | 3 +
apps/workbench/test/integration/users_test.rb | 193 ++++++++++++++++++++
.../app/controllers/arvados/v1/users_controller.rb | 3 +-
services/api/app/models/user.rb | 81 ++++++---
.../functional/arvados/v1/users_controller_test.rb | 26 ++-
18 files changed, 530 insertions(+), 40 deletions(-)
create mode 100644 apps/workbench/app/views/users/_setup_popup.html.erb
create mode 100644 apps/workbench/app/views/users/setup.js.erb
create mode 100644 apps/workbench/app/views/users/setup_popup.js.erb
create mode 100644 apps/workbench/test/integration/users_test.rb
via 0f92cdd76a8ecc456e0ab068abce468e3a169bc0 (commit)
via fdbdc0cdecb027265dccef0810b189e578cb8c60 (commit)
via 0b76b475d2e1dc33bd80de9923d99009231e6671 (commit)
via 4d918da1c7f7499d19491d44ecead48008d2fe1e (commit)
via 38f8414fb8357b57ab3b859b7721676d62dfe984 (commit)
via eba6e6988be540b8d6015903e58d8acf71476149 (commit)
via 7043cad00647bc44f83586d895b70f950d5a26c2 (commit)
via 043a17b21c0f18eaaddcdd5d1144989c1d48e3e2 (commit)
via 2c5412052d38751d538696c9d5cbb0b8adbfd1a6 (commit)
via 4e3dca8c84d77baaa1a58c195204f91da5f4176d (commit)
via 2c292c1942746dfa7b93411d76a8374e1b0aff16 (commit)
via c267f657aae5d43389a41861c2b9649c30482468 (commit)
via b8ee1ea826cd2f02233893e8e06bac5fc44bb473 (commit)
via 55684214f941cf73ce1eb542943dea24a17d48e5 (commit)
via cb2c6a830abda3390146a4933b8cd8ce6ed55d31 (commit)
via 8f8feb2866fd36bbc44188116d3bed6e4a4109a4 (commit)
via 190fe9cdc4ea41267a89f8c0e54dbc179cd1e4b8 (commit)
via 9d9b194941e7d3c9b459d27657e3c3c67bf388b8 (commit)
via 835332abdd0fb8d0046529ff4d2f026f67736418 (commit)
via e8dea4fda0347c612ba6b0d4a8045916febeb680 (commit)
via a2164fe94a9909e5b38856b881a1d856f822747d (commit)
via 47d130ae61a2aa0c637060d4a5be9f3728af30b7 (commit)
via 4efa06e83f82096b70c03192bce74df96ed230c5 (commit)
via e6e7736641231fe43b5f68bf4d0653d4321bbc36 (commit)
via 33d7da6903a0fc2c9570a11c939dce6a4894f66e (commit)
via 20e876e9d9809d6097da440453c20f737229ee28 (commit)
via 5a7b7aa6a6a11b5e0a397d01a6fe527169ed5f15 (commit)
via 9f87668ecf0768f83b95253d8888481b1d8ff95e (commit)
via 4882cd9ebd6311c4f84d8efff21561b1a229e244 (commit)
via a992c11d76c013d42470a5142714d68e918bccfa (commit)
via 1697fcdd746eb5a30127275e533c3d799aa9f681 (commit)
via 921ec0ddab4c949659d54490204acdd431986450 (commit)
via c6cb3423e9ca2b421bda3bb97c1448dcde19df97 (commit)
via 3ca0861ae65a9c61f0db226bbe9f70cfc0a4ec7b (commit)
via fe0d9b8e3a46c610deb95b9a8b501e8c2aad9f54 (commit)
via cb19d007add188f2c83a082c419ee0b523fb664b (commit)
via a15ff495c8c576378f55f58fe22ce9f3c49121e8 (commit)
from 5dd1c07e56d32ae4c569ceffdbd4549bceb92de4 (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 0f92cdd76a8ecc456e0ab068abce468e3a169bc0
Author: radhika chippada <radhika at curoverse.com>
Date: Tue Apr 8 12:00:32 2014 -0400
Move the javascript into a js file instead of using <script> tag in html file.
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index ac2fd99..f7f7914 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -67,45 +67,3 @@
<% end #form %>
</div>
</div>
-
-<script>
- var $input = $('input:text'),
- $register = $('#register');
-
- var email_disabled = document.forms["setup_form"]["email"].disabled;
- var email_value = document.forms["setup_form"]["email"].value;
- var prefix_value = document.forms["setup_form"]["openid_prefix"].value;
- if ((email_disabled == false) && (email_value == null || email_value == "" ||
- prefix_value == null || prefix_value == "")) {
- $register.attr('disabled', true);
- }
-
- $input.on('keyup paste mouseleave', function() {
- var trigger = false;
-
- var email_disabled = document.forms["setup_form"]["email"].disabled;
- var email_value = document.forms["setup_form"]["email"].value;
- var prefix_value = document.forms["setup_form"]["openid_prefix"].value;
-
- var emailRegExp = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
- var validEmail = false;
- if (emailRegExp.test(email_value )) {
- validEmail = true;
- }
-
- if ((email_disabled == false) && (!validEmail || email_value == null ||
- email_value == "" || prefix_value == null || prefix_value == "")){
- trigger = true;
- }
-
- trigger ? $register.attr('disabled', true) : $register.removeAttr('disabled');
- });
-
- function reset_form() {
- $('#email').val("");
- $('#openid_prefix').val("");
- $('#repo_name').val("");
- $('select').val('')
- }
-
-</script>
diff --git a/apps/workbench/app/views/users/setup_popup.js.erb b/apps/workbench/app/views/users/setup_popup.js.erb
index 77213d4..5671cc2 100644
--- a/apps/workbench/app/views/users/setup_popup.js.erb
+++ b/apps/workbench/app/views/users/setup_popup.js.erb
@@ -1 +1,44 @@
$("#user-setup-modal-window").html("<%= escape_javascript(render partial: 'setup_popup') %>");
+
+// disable the submit button on load
+var $input = $('input:text'),
+$register = $('#register');
+
+var email_disabled = document.forms["setup_form"]["email"].disabled;
+var email_value = document.forms["setup_form"]["email"].value;
+var prefix_value = document.forms["setup_form"]["openid_prefix"].value;
+if ((email_disabled == false) && (email_value == null || email_value == "" ||
+ prefix_value == null || prefix_value == "")) {
+ $register.attr('disabled', true);
+}
+
+// capture events to enable submit button when applicable
+$input.on('keyup paste mouseleave', function() {
+ var trigger = false;
+
+ var email_disabled = document.forms["setup_form"]["email"].disabled;
+ var email_value = document.forms["setup_form"]["email"].value;
+ var prefix_value = document.forms["setup_form"]["openid_prefix"].value;
+
+ var emailRegExp = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
+ var validEmail = false;
+
+ if (emailRegExp.test(email_value )) {
+ validEmail = true;
+ }
+
+ if ((email_disabled == false) && (!validEmail || email_value == null ||
+ email_value == "" || prefix_value == null || prefix_value == "")){
+ trigger = true;
+ }
+
+ trigger ? $register.attr('disabled', true) : $register.removeAttr('disabled');
+});
+
+// reset form input fields, for the next time around
+function reset_form() {
+ $('#email').val("");
+ $('#openid_prefix').val("");
+ $('#repo_name').val("");
+ $('select').val('')
+}
commit fdbdc0cdecb027265dccef0810b189e578cb8c60
Author: radhika chippada <radhika at curoverse.com>
Date: Tue Apr 8 10:40:31 2014 -0400
Remove trailing white spaces.
diff --git a/apps/workbench/test/integration/users_test.rb b/apps/workbench/test/integration/users_test.rb
index 2472ec8..9ee12d8 100644
--- a/apps/workbench/test/integration/users_test.rb
+++ b/apps/workbench/test/integration/users_test.rb
@@ -46,7 +46,7 @@ class UsersTest < ActionDispatch::IntegrationTest
assert page.has_text? 'zzzzz-tpzed-d9tiejq69daie8f'
click_link 'Add a new user'
-
+
sleep(0.1)
popup = page.driver.browser.window_handles.last
page.within_window popup do
@@ -57,7 +57,7 @@ class UsersTest < ActionDispatch::IntegrationTest
end
sleep(0.1)
-
+
# verify that the new user showed up in the users page
assert page.has_text? 'foo at example.com'
commit 0b76b475d2e1dc33bd80de9923d99009231e6671
Author: radhika chippada <radhika at curoverse.com>
Date: Tue Apr 8 10:29:40 2014 -0400
Add paste event check for submit button validation
diff --git a/apps/workbench/app/views/application/index.html.erb b/apps/workbench/app/views/application/index.html.erb
index 96dc348..3f31240 100644
--- a/apps/workbench/app/views/application/index.html.erb
+++ b/apps/workbench/app/views/application/index.html.erb
@@ -8,12 +8,12 @@
<% if controller.model_class.name == 'User' %>
<%= link_to "Add a new #{controller.model_class.to_s.underscore.gsub '_', ' '}", setup_user_popup_path,
- {class: 'btn btn-primary pull-right', :remote => true, 'data-toggle' => "modal",
+ {class: 'btn btn-primary pull-right', :remote => true, 'data-toggle' => "modal",
'data-target' => '#user-setup-modal-window', return_to: request.url} %>
<div id="user-setup-modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
<% else %>
- <%= button_to "Add a new #{controller.model_class.to_s.underscore.gsub '_', ' '}",
- { action: 'create', return_to: request.url },
+ <%= button_to "Add a new #{controller.model_class.to_s.underscore.gsub '_', ' '}",
+ { action: 'create', return_to: request.url },
{ class: 'btn btn-primary pull-right' } %>
<% end %>
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index c075ab5..ac2fd99 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -75,12 +75,12 @@
var email_disabled = document.forms["setup_form"]["email"].disabled;
var email_value = document.forms["setup_form"]["email"].value;
var prefix_value = document.forms["setup_form"]["openid_prefix"].value;
- if ((email_disabled == false) && (email_value == null || email_value == "" ||
+ if ((email_disabled == false) && (email_value == null || email_value == "" ||
prefix_value == null || prefix_value == "")) {
$register.attr('disabled', true);
}
- $input.keyup(function() {
+ $input.on('keyup paste mouseleave', function() {
var trigger = false;
var email_disabled = document.forms["setup_form"]["email"].disabled;
@@ -93,7 +93,7 @@
validEmail = true;
}
- if ((email_disabled == false) && (!validEmail || email_value == null ||
+ if ((email_disabled == false) && (!validEmail || email_value == null ||
email_value == "" || prefix_value == null || prefix_value == "")){
trigger = true;
}
commit 4d918da1c7f7499d19491d44ecead48008d2fe1e
Author: Tom Clegg <tom at curoverse.com>
Date: Tue Apr 8 01:55:17 2014 -0400
Use bootstrap/theme style defaults for user setup modal and form.
diff --git a/apps/workbench/app/assets/stylesheets/bootstrap-modal.css.scss b/apps/workbench/app/assets/stylesheets/bootstrap-modal.css.scss
deleted file mode 100644
index 6eeb0c9..0000000
--- a/apps/workbench/app/assets/stylesheets/bootstrap-modal.css.scss
+++ /dev/null
@@ -1,29 +0,0 @@
-// Place all the styles related to the bootstrap modal here.
-
-.modal {
- left: 50%;
- bottom: auto;
- right: auto;
- padding: 0;
- width: 400px;
- margin-left: -250px;
- background-color: #ffffff;
- border: 2px solid #999999;
- border-radius: 6px;
- box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
- background-clip: padding-box;
-}
-
-.modal.fade.in {
- top: 10%;
-}
-
-.modal-backdrop,
-.modal-backdrop.fade.in{
- opacity: 0.7;
- background: #fff;
-}
-
-#user-setup-modal-window{
- overflow: hidden;
-}
diff --git a/apps/workbench/app/views/layouts/application.html.erb b/apps/workbench/app/views/layouts/application.html.erb
index 63cf67c..724fa9b 100644
--- a/apps/workbench/app/views/layouts/application.html.erb
+++ b/apps/workbench/app/views/layouts/application.html.erb
@@ -230,6 +230,7 @@
</div>
</div>
+ <%= yield :footer_html %>
<%= piwik_tracking_tag %>
<%= javascript_tag do %>
<%= yield :footer_js %>
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index 784ab6e..c075ab5 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -1,79 +1,72 @@
-<%= form_tag setup_user_path, {id: 'setup_form', name: 'setup_form', method: 'get',
- class: 'form-search', remote: true} do %>
+<div class="modal-dialog">
+ <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" onClick="reset_form()" data-dismiss="modal" aria-hidden="true">×</button>
- <h3 class="modal-title">Setup User</h4>
- </div
+ <%= form_tag setup_user_path, {id: 'setup_form', name: 'setup_form', method: 'get',
+ class: 'form-search', remote: true} do %>
- <div class="modal-body">
- <% if @object%>
- <% uuid = @object.uuid %>
- <% email = @object.email %>
- <% end %>
- <% disable_email = uuid != nil %>
- <% identity_url_prefix = @current_selections[:identity_url_prefix] %>
- <% disable_url_prefix = identity_url_prefix != nil %>
- <% selected_repo = @current_selections[:repo_name] %>
- <% selected_vm = @current_selections[:vm_uuid] %>
+ <div class="modal-header">
+ <button type="button" class="close" onClick="reset_form()" data-dismiss="modal" aria-hidden="true">×</button>
+ <h4 class="modal-title">Setup User</h4>
+ </div>
+
+ <div class="modal-body">
+ <% if @object%>
+ <% uuid = @object.uuid %>
+ <% email = @object.email %>
+ <% end %>
+ <% disable_email = uuid != nil %>
+ <% identity_url_prefix = @current_selections[:identity_url_prefix] %>
+ <% disable_url_prefix = identity_url_prefix != nil %>
+ <% selected_repo = @current_selections[:repo_name] %>
+ <% selected_vm = @current_selections[:vm_uuid] %>
<input id="user_uuid" maxlength="250" name="user_uuid" type="hidden" value="<%=uuid%>">
- <div>
- <table><tbody><div class="form-group">
- <tr>
- <% if disable_email %>
- <td> Email </td>
- <td> <input id="email" maxlength="250" name="email" type="text" value="<%=email%>"
- disabled=true > </td>
- <% else %>
- <td> Email </td>
- <td> <input id="email" maxlength="250" name="email" type="text" > </td>
- <% end %>
- </tr>
- <tr>
- <% if disable_url_prefix %>
- <td> Identity URL Prefix   </td>
- <td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text"
- value="<%=identity_url_prefix%>" disabled=true > </td>
- <% else %>
- <td> Openid Prefix </td>
- <td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text"
- value="<%= Rails.configuration.default_openid_prefix %>"> </td>
- <% end %>
- </tr>
- <tr>
- <td> Repository Name </td>
- <td> <input id="repo_name" maxlength="250" name="repo_name" type="text" value="<%=selected_repo%>">
- </tr>
- <tr>
- <td> Virtual Machine </td>
- <td>
- <select name="vm_uuid">
- <% if selected_vm %>
- <option value=""> Choose One: </option>
- <% else %>
- <option value="" selected> Choose One: </option>
- <% end %>
- <% @vms.each do |vm| %>
- <% if selected_vm == vm.uuid %>
- <option value=<%=vm.uuid%> selected> <%=vm.hostname%> </option>
- <% else %>
- <option value=<%=vm.uuid%> > <%=vm.hostname%> </option>
- <% end %>
- <% end %>
- </select>
- </td>
- </tr>
- </div></tbody></table>
+ <div class="form-group">
+ <label for="email">Email</label>
+ <% if disable_email %>
+ <input class="form-control" id="email" maxlength="250" name="email" type="text" value="<%=email%>" disabled>
+ <% else %>
+ <input class="form-control" id="email" maxlength="250" name="email" type="text">
+ <% end %>
</div>
- </div>
+ <div class="form-group">
+ <label for="openid_prefix">Identity URL Prefix</label>
+ <% if disable_url_prefix %>
+ <input class="form-control" id="openid_prefix" maxlength="250" name="openid_prefix" type="text"
+ value="<%=identity_url_prefix%>" disabled=true>
+ <% else %>
+ <input class="form-control" id="openid_prefix" maxlength="250" name="openid_prefix" type="text"
+ value="<%= Rails.configuration.default_openid_prefix %>">
+ <% end %>
+ </div>
+ <div class="form-group">
+ <label for="repo_name">Repository Name</label>
+ <input class="form-control" id="repo_name" maxlength="250" name="repo_name" type="text" value="<%=selected_repo%>">
+ </div>
+ <div class="form-group">
+ <label for="vm_uuid">Virtual Machine</label>
+ <select class="form-control" name="vm_uuid">
+ <option value="" <%= 'selected' unless selected_vm %>>
+ Choose One:
+ </option>
+ <% @vms.each do |vm| %>
+ <option value="<%=vm.uuid%>"
+ <%= 'selected' if selected_vm == vm.uuid %>>
+ <%= vm.hostname %>
+ </option>
+ <% end %>
+ </select>
+ </div>
+ </div>
- <div class="modal-footer">
- <button type="submit" id="register" class="btn btn-primary" autofocus>Submit</button>
- <button class="btn btn-default" onClick="reset_form()" data-dismiss="modal" aria-hidden="true">Cancel</button>
- </div>
+ <div class="modal-footer">
+ <button type="submit" id="register" class="btn btn-primary" autofocus>Submit</button>
+ <button class="btn btn-default" onClick="reset_form()" data-dismiss="modal" aria-hidden="true">Cancel</button>
+ </div>
-<% end %>
+ <% end #form %>
+ </div>
+</div>
<script>
var $input = $('input:text'),
diff --git a/apps/workbench/app/views/users/_show_admin.html.erb b/apps/workbench/app/views/users/_show_admin.html.erb
index 9c803c9..e2f5fdf 100644
--- a/apps/workbench/app/views/users/_show_admin.html.erb
+++ b/apps/workbench/app/views/users/_show_admin.html.erb
@@ -10,7 +10,6 @@ account.</p>
<blockquote>
<%= link_to "Setup #{@object.full_name}", setup_popup_user_url(id: @object.uuid), {class: 'btn btn-primary', :remote => true, 'data-toggle' => "modal", 'data-target' => '#user-setup-modal-window'} %>
-<div id="user-setup-modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
</blockquote>
<p>As an admin, you can deactivate and reset this user. This will remove all repository/VM permissions for the user. If you "setup" the user again, the user will have to sign the user agreement again.</p>
@@ -19,3 +18,6 @@ account.</p>
<%= button_to "Deactivate #{@object.full_name}", unsetup_user_url(id: @object.uuid), class: 'btn btn-primary', confirm: "Are you sure you want to deactivate #{@object.full_name}?"%>
</blockquote>
+<% content_for :footer_html do %>
+<div id="user-setup-modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
+<% end %>
commit 38f8414fb8357b57ab3b859b7721676d62dfe984
Author: radhika chippada <radhika at radhika.curoverse>
Date: Mon Apr 7 15:04:06 2014 -0400
Reset form fields on cancel.
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index e8a8043..784ab6e 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -2,7 +2,7 @@
class: 'form-search', remote: true} do %>
<div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
+ <button type="button" class="close" onClick="reset_form()" data-dismiss="modal" aria-hidden="true">×</button>
<h3 class="modal-title">Setup User</h4>
</div
@@ -70,7 +70,7 @@
<div class="modal-footer">
<button type="submit" id="register" class="btn btn-primary" autofocus>Submit</button>
- <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Cancel</button>
+ <button class="btn btn-default" onClick="reset_form()" data-dismiss="modal" aria-hidden="true">Cancel</button>
</div>
<% end %>
@@ -107,4 +107,12 @@
trigger ? $register.attr('disabled', true) : $register.removeAttr('disabled');
});
+
+ function reset_form() {
+ $('#email').val("");
+ $('#openid_prefix').val("");
+ $('#repo_name').val("");
+ $('select').val('')
+ }
+
</script>
commit eba6e6988be540b8d6015903e58d8acf71476149
Author: radhika chippada <radhika at radhika.curoverse>
Date: Mon Apr 7 14:44:49 2014 -0400
Submit
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index a1c3f8a..e8a8043 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -1,3 +1,6 @@
+<%= form_tag setup_user_path, {id: 'setup_form', name: 'setup_form', method: 'get',
+ class: 'form-search', remote: true} do %>
+
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 class="modal-title">Setup User</h4>
@@ -13,12 +16,10 @@
<% disable_url_prefix = identity_url_prefix != nil %>
<% selected_repo = @current_selections[:repo_name] %>
<% selected_vm = @current_selections[:vm_uuid] %>
-
- <%= form_tag setup_user_path, {id: 'setup_form', name: 'setup_form', method: 'get',
- class: 'form-search', remote: true} do %>
+
<input id="user_uuid" maxlength="250" name="user_uuid" type="hidden" value="<%=uuid%>">
<div>
- <table><tbody>
+ <table><tbody><div class="form-group">
<tr>
<% if disable_email %>
<td> Email </td>
@@ -63,9 +64,8 @@
</select>
</td>
</tr>
- </tbody></table>
+ </div></tbody></table>
</div>
- <% end %>
</div>
<div class="modal-footer">
@@ -73,6 +73,8 @@
<button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Cancel</button>
</div>
+<% end %>
+
<script>
var $input = $('input:text'),
$register = $('#register');
commit 7043cad00647bc44f83586d895b70f950d5a26c2
Author: radhika chippada <radhika at radhika.curoverse>
Date: Mon Apr 7 14:03:01 2014 -0400
Bootstrap modal css updated to include only what is needed.
diff --git a/apps/workbench/app/assets/stylesheets/bootstrap-modal.css.scss b/apps/workbench/app/assets/stylesheets/bootstrap-modal.css.scss
index 41f21c7..6eeb0c9 100644
--- a/apps/workbench/app/assets/stylesheets/bootstrap-modal.css.scss
+++ b/apps/workbench/app/assets/stylesheets/bootstrap-modal.css.scss
@@ -1,233 +1,29 @@
-/*!
-* Bootstrap Modal
-*
-* Copyright Jordan Schroter
-* Licensed under the Apache License v2.0
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*/
-
-body.modal-open,
-.modal-open .navbar-fixed-top,
-.modal-open .navbar-fixed-bottom {
- margin-right: 0;
-}
+// Place all the styles related to the bootstrap modal here.
.modal {
left: 50%;
bottom: auto;
right: auto;
padding: 0;
- width: 500px;
+ width: 400px;
margin-left: -250px;
background-color: #ffffff;
- border: 1px solid #999999;
- border: 1px solid rgba(0, 0, 0, 0.2);
+ border: 2px solid #999999;
border-radius: 6px;
- -webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
background-clip: padding-box;
}
-.modal.container {
- max-width: none;
-}
-
-
-.modal-open {
-overflow: hidden;
-}
-
-
-/* add a scroll bar to stop page from jerking around */
-.modal-open.page-overflow .page-container,
-.modal-open.page-overflow .page-container .navbar-fixed-top,
-.modal-open.page-overflow .page-container .navbar-fixed-bottom,
-.modal-open.page-overflow .modal-scrollable {
-overflow-y: scroll;
-}
-
-#user-setup-modal-window{
- overflow: hidden;
-}
-
-
- at media (max-width: 979px) {
-.modal-open.page-overflow .page-container .navbar-fixed-top,
-.modal-open.page-overflow .page-container .navbar-fixed-bottom {
-overflow-y: visible;
-}
-}
-
-
-.modal-scrollable {
-position: fixed;
-top: 0;
-bottom: 0;
-left: 0;
-right: 0;
-overflow: auto;
-}
-
-.modal.fade {
-top: -100%;
--webkit-transition: opacity 0.3s linear, top 0.3s ease-out, bottom 0.3s ease-out, margin-top 0.3s ease-out;
--moz-transition: opacity 0.3s linear, top 0.3s ease-out, bottom 0.3s ease-out, margin-top 0.3s ease-out;
--o-transition: opacity 0.3s linear, top 0.3s ease-out, bottom 0.3s ease-out, margin-top 0.3s ease-out;
-transition: opacity 0.3s linear, top 0.3s ease-out, bottom 0.3s ease-out, margin-top 0.3s ease-out;
-}
-
.modal.fade.in {
-top: 50%;
-}
-
-.modal-body {
-max-height: none;
-overflow: visible;
-}
-
-.modal.modal-absolute {
-position: absolute;
-z-index: 950;
-}
-
-.modal .loading-mask {
-position: absolute;
-top: 0;
-bottom: 0;
-left: 0;
-right: 0;
-background: #fff;
-border-radius: 6px;
-}
-
-.modal-backdrop.modal-absolute{
-position: absolute;
-z-index: 940;
+ top: 10%;
}
.modal-backdrop,
.modal-backdrop.fade.in{
-opacity: 0.7;
-filter: alpha(opacity=70);
-background: #fff;
+ opacity: 0.7;
+ background: #fff;
}
-/* Modal Overflow */
-
-.modal-overflow.modal {
-top: 1%;
-}
-
-.modal-overflow.modal.fade {
-top: -100%;
-}
-
-.modal-overflow.modal.fade.in {
-top: 1%;
-}
-
-.modal-overflow .modal-body {
-overflow: auto;
--webkit-overflow-scrolling: touch;
-}
-
-/* Responsive */
-
- at media (min-width: 1200px) {
-.modal.container {
-width: 1170px;
-margin-left: -585px;
-}
-}
-
- at media (max-width: 979px) {
-.modal,
-.modal.container,
-.modal.modal-overflow {
-top: 1%;
-right: 1%;
-left: 1%;
-bottom: auto;
-width: auto !important;
-height: auto !important;
-margin: 0 !important;
-padding: 0 !important;
-}
-
-.modal.fade.in,
-.modal.container.fade.in,
-.modal.modal-overflow.fade.in {
-top: 1%;
-bottom: auto;
-}
-
-.modal-body,
-.modal-overflow .modal-body {
-position: static;
-margin: 0;
-height: auto !important;
-max-height: none !important;
-overflow: visible !important;
-}
-
-.modal-footer,
-.modal-overflow .modal-footer {
-position: static;
-}
-}
-
-.loading-spinner {
-position: absolute;
-top: 50%;
-left: 50%;
-margin: -12px 0 0 -12px;
-}
-
-/*
-Animate.css - http://daneden.me/animate
-Licensed under the ☺ license (http://licence.visualidiot.com/)
-
-Copyright (c) 2012 Dan Eden*/
-
-.animated {
--webkit-animation-duration: 1s;
--moz-animation-duration: 1s;
--o-animation-duration: 1s;
-animation-duration: 1s;
--webkit-animation-fill-mode: both;
--moz-animation-fill-mode: both;
--o-animation-fill-mode: both;
-animation-fill-mode: both;
-}
-
- at -webkit-keyframes shake {
-0%, 100% {-webkit-transform: translateX(0);}
-10%, 30%, 50%, 70%, 90% {-webkit-transform: translateX(-10px);}
-20%, 40%, 60%, 80% {-webkit-transform: translateX(10px);}
-}
-
- at -moz-keyframes shake {
-0%, 100% {-moz-transform: translateX(0);}
-10%, 30%, 50%, 70%, 90% {-moz-transform: translateX(-10px);}
-20%, 40%, 60%, 80% {-moz-transform: translateX(10px);}
-}
-
- at -o-keyframes shake {
-0%, 100% {-o-transform: translateX(0);}
-10%, 30%, 50%, 70%, 90% {-o-transform: translateX(-10px);}
-20%, 40%, 60%, 80% {-o-transform: translateX(10px);}
-}
-
- at keyframes shake {
-0%, 100% {transform: translateX(0);}
-10%, 30%, 50%, 70%, 90% {transform: translateX(-10px);}
-20%, 40%, 60%, 80% {transform: translateX(10px);}
-}
-
-.shake {
--webkit-animation-name: shake;
--moz-animation-name: shake;
--o-animation-name: shake;
-animation-name: shake;
+#user-setup-modal-window{
+ overflow: hidden;
}
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index 412d211..a1c3f8a 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -3,7 +3,7 @@
<h3 class="modal-title">Setup User</h4>
</div
- <div class="modal-body" style="max-height:800px;">
+ <div class="modal-body">
<% if @object%>
<% uuid = @object.uuid %>
<% email = @object.email %>
commit 043a17b21c0f18eaaddcdd5d1144989c1d48e3e2
Author: radhika chippada <radhika at radhika.curoverse>
Date: Mon Apr 7 11:58:08 2014 -0400
Add header and footer to the setup user modal
diff --git a/apps/workbench/app/assets/stylesheets/bootstrap-modal.css.scss b/apps/workbench/app/assets/stylesheets/bootstrap-modal.css.scss
index 417ca74..41f21c7 100644
--- a/apps/workbench/app/assets/stylesheets/bootstrap-modal.css.scss
+++ b/apps/workbench/app/assets/stylesheets/bootstrap-modal.css.scss
@@ -47,6 +47,11 @@ overflow: hidden;
overflow-y: scroll;
}
+#user-setup-modal-window{
+ overflow: hidden;
+}
+
+
@media (max-width: 979px) {
.modal-open.page-overflow .page-container .navbar-fixed-top,
.modal-open.page-overflow .page-container .navbar-fixed-bottom {
diff --git a/apps/workbench/app/views/application/index.html.erb b/apps/workbench/app/views/application/index.html.erb
index 7108c70..96dc348 100644
--- a/apps/workbench/app/views/application/index.html.erb
+++ b/apps/workbench/app/views/application/index.html.erb
@@ -9,8 +9,8 @@
<% if controller.model_class.name == 'User' %>
<%= link_to "Add a new #{controller.model_class.to_s.underscore.gsub '_', ' '}", setup_user_popup_path,
{class: 'btn btn-primary pull-right', :remote => true, 'data-toggle' => "modal",
- 'data-target' => '#modal-window', return_to: request.url} %>
- <div id="modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
+ 'data-target' => '#user-setup-modal-window', return_to: request.url} %>
+ <div id="user-setup-modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
<% else %>
<%= button_to "Add a new #{controller.model_class.to_s.underscore.gsub '_', ' '}",
{ action: 'create', return_to: request.url },
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index 90cab2c..412d211 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -1,4 +1,9 @@
- <div class="modal-body">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
+ <h3 class="modal-title">Setup User</h4>
+ </div
+
+ <div class="modal-body" style="max-height:800px;">
<% if @object%>
<% uuid = @object.uuid %>
<% email = @object.email %>
@@ -60,14 +65,14 @@
</tr>
</tbody></table>
</div>
- <div align="center">
- <br/>
- <button type="submit" id="register" class="btn btn-primary" autofocus>Submit</button>
- <button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Cancel</button>
- </div>
<% end %>
</div>
+ <div class="modal-footer">
+ <button type="submit" id="register" class="btn btn-primary" autofocus>Submit</button>
+ <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Cancel</button>
+ </div>
+
<script>
var $input = $('input:text'),
$register = $('#register');
diff --git a/apps/workbench/app/views/users/_show_admin.html.erb b/apps/workbench/app/views/users/_show_admin.html.erb
index 072d7ee..9c803c9 100644
--- a/apps/workbench/app/views/users/_show_admin.html.erb
+++ b/apps/workbench/app/views/users/_show_admin.html.erb
@@ -9,8 +9,8 @@ account.</p>
<p>As an admin, you can setup this user. Please input a VM and repository for the user. If you had previously provided any of these items, they are pre-filled for you and you can leave them as is if you would like to reuse them.</p>
<blockquote>
-<%= link_to "Setup #{@object.full_name}", setup_popup_user_url(id: @object.uuid), {class: 'btn btn-primary', :remote => true, 'data-toggle' => "modal", 'data-target' => '#modal-window'} %>
-<div id="modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
+<%= link_to "Setup #{@object.full_name}", setup_popup_user_url(id: @object.uuid), {class: 'btn btn-primary', :remote => true, 'data-toggle' => "modal", 'data-target' => '#user-setup-modal-window'} %>
+<div id="user-setup-modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
</blockquote>
<p>As an admin, you can deactivate and reset this user. This will remove all repository/VM permissions for the user. If you "setup" the user again, the user will have to sign the user agreement again.</p>
diff --git a/apps/workbench/app/views/users/setup.js.erb b/apps/workbench/app/views/users/setup.js.erb
index 9134623..bce71b4 100644
--- a/apps/workbench/app/views/users/setup.js.erb
+++ b/apps/workbench/app/views/users/setup.js.erb
@@ -1,2 +1,2 @@
-$("#modal-window").modal("hide");
+$("#user-setup-modal-window").modal("hide");
document.location.reload();
diff --git a/apps/workbench/app/views/users/setup_popup.js.erb b/apps/workbench/app/views/users/setup_popup.js.erb
index e725a92..77213d4 100644
--- a/apps/workbench/app/views/users/setup_popup.js.erb
+++ b/apps/workbench/app/views/users/setup_popup.js.erb
@@ -1 +1 @@
-$("#modal-window").html("<%= escape_javascript(render partial: 'setup_popup') %>");
+$("#user-setup-modal-window").html("<%= escape_javascript(render partial: 'setup_popup') %>");
commit 2c5412052d38751d538696c9d5cbb0b8adbfd1a6
Author: Tom Clegg <tom at curoverse.com>
Date: Fri Apr 4 17:21:45 2014 -0400
Document capybara-webkit qt dependencies, and add phantomjs recipe.
diff --git a/apps/workbench/README.textile b/apps/workbench/README.textile
index ea01724..00588e8 100644
--- a/apps/workbench/README.textile
+++ b/apps/workbench/README.textile
@@ -6,8 +6,22 @@ h2. Running tests
The Workbench application includes a series of integration tests. When you run these, it starts the API server in a test environment, with all of its fixtures loaded, then tests Workbench by starting that server and making requests against it.
+Before running @bundle install@, make sure you install QT development dependencies (otherwise, capybara-webkit installation will fail). For example, on a Debian or Ubuntu system:
+
+<pre>
+arvados/apps/workbench$ sudo apt-get install qt4-qmake libqt4-dev
+arvados/apps/workbench$ RAILS_ENV=test bundle install
+</pre>
+
In addition to bundled gems, running the integration tests requires "PhantomJS":http://phantomjs.org/download.html to test JavaScript elements. The simplest way to get started is to download one of the binary builds provided, and install the executable into one of the directories in your @$PATH at .
+<pre>
+$ cd /tmp
+/tmp$ wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2
+/tmp$ tar xjf phantomjs-1.9.7-linux-x86_64.tar.bz2
+/tmp$ sudo cp -ip phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/local/bin/
+</pre>
+
If you install the Workbench Bundle in deployment mode, you must also install the API server Bundle in deployment mode, and vice versa. If your Bundle installs have mismatched modes, the integration tests will fail with "Gem not found" errors.
h2. Writing tests
commit 4e3dca8c84d77baaa1a58c195204f91da5f4176d
Author: radhika chippada <radhika at radhika.curoverse>
Date: Fri Apr 4 15:45:53 2014 -0400
Add email format validation to the input text field in the setup modal.
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index aed57da..90cab2c 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -75,7 +75,8 @@
var email_disabled = document.forms["setup_form"]["email"].disabled;
var email_value = document.forms["setup_form"]["email"].value;
var prefix_value = document.forms["setup_form"]["openid_prefix"].value;
- if ((email_disabled == false) && (email_value == null || email_value == "" || prefix_value == null || prefix_value == "")) {
+ if ((email_disabled == false) && (email_value == null || email_value == "" ||
+ prefix_value == null || prefix_value == "")) {
$register.attr('disabled', true);
}
@@ -85,7 +86,15 @@
var email_disabled = document.forms["setup_form"]["email"].disabled;
var email_value = document.forms["setup_form"]["email"].value;
var prefix_value = document.forms["setup_form"]["openid_prefix"].value;
- if ((email_disabled == false) && (email_value == null || email_value == "" || prefix_value == null || prefix_value == "")) {
+
+ var emailRegExp = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
+ var validEmail = false;
+ if (emailRegExp.test(email_value )) {
+ validEmail = true;
+ }
+
+ if ((email_disabled == false) && (!validEmail || email_value == null ||
+ email_value == "" || prefix_value == null || prefix_value == "")){
trigger = true;
}
commit 2c292c1942746dfa7b93411d76a8374e1b0aff16
Author: radhika chippada <radhika at radhika.curoverse>
Date: Fri Apr 4 14:53:42 2014 -0400
During setup of an existing user, create oid login permission, if it does not already exist.
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index 475b696..aed57da 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -5,6 +5,7 @@
<% end %>
<% disable_email = uuid != nil %>
<% identity_url_prefix = @current_selections[:identity_url_prefix] %>
+ <% disable_url_prefix = identity_url_prefix != nil %>
<% selected_repo = @current_selections[:repo_name] %>
<% selected_vm = @current_selections[:vm_uuid] %>
@@ -24,7 +25,7 @@
<% end %>
</tr>
<tr>
- <% if disable_email %>
+ <% if disable_url_prefix %>
<td> Identity URL Prefix   </td>
<td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text"
value="<%=identity_url_prefix%>" disabled=true > </td>
diff --git a/services/api/app/controllers/arvados/v1/users_controller.rb b/services/api/app/controllers/arvados/v1/users_controller.rb
index fe2d0da..58661a0 100644
--- a/services/api/app/controllers/arvados/v1/users_controller.rb
+++ b/services/api/app/controllers/arvados/v1/users_controller.rb
@@ -124,7 +124,8 @@ class Arvados::V1::UsersController < ApplicationController
end
if object_found
- @response = @object.setup_repo_vm_links params[:repo_name], params[:vm_uuid]
+ @response = @object.setup_repo_vm_links params[:repo_name],
+ params[:vm_uuid], params[:openid_prefix]
else
@response = User.setup @object, params[:openid_prefix],
params[:repo_name], params[:vm_uuid]
diff --git a/services/api/app/models/user.rb b/services/api/app/models/user.rb
index 77e9778..e4881ed 100644
--- a/services/api/app/models/user.rb
+++ b/services/api/app/models/user.rb
@@ -111,39 +111,17 @@ class User < ArvadosModel
end
def self.setup(user, openid_prefix, repo_name=nil, vm_uuid=nil)
- login_perm_props = {identity_url_prefix: openid_prefix}
-
- # Check oid_login_perm
- oid_login_perms = Link.where(tail_uuid: user.email,
- head_kind: 'arvados#user',
- link_class: 'permission',
- name: 'can_login')
-
- if !oid_login_perms.any?
- # create openid login permission
- oid_login_perm = Link.create(link_class: 'permission',
- name: 'can_login',
- tail_kind: 'email',
- tail_uuid: user.email,
- head_kind: 'arvados#user',
- head_uuid: user.uuid,
- properties: login_perm_props
- )
- logger.info { "openid login permission: " + oid_login_perm[:uuid] }
- else
- oid_login_perm = oid_login_perms.first
- end
-
- return [oid_login_perm] + user.setup_repo_vm_links(repo_name, vm_uuid)
+ return user.setup_repo_vm_links(repo_name, vm_uuid, openid_prefix)
end
# create links
- def setup_repo_vm_links(repo_name, vm_uuid)
+ def setup_repo_vm_links(repo_name, vm_uuid, openid_prefix)
+ oid_login_perm = create_oid_login_perm openid_prefix
repo_perm = create_user_repo_link repo_name
vm_login_perm = create_vm_login_permission_link vm_uuid, repo_name
group_perm = create_user_group_link
- return [repo_perm, vm_login_perm, group_perm, self].compact
+ return [oid_login_perm, repo_perm, vm_login_perm, group_perm, self].compact
end
# delete user signatures, login, repo, and vm perms, and mark as inactive
@@ -270,6 +248,33 @@ class User < ArvadosModel
merged
end
+ def create_oid_login_perm (openid_prefix)
+ login_perm_props = {identity_url_prefix: openid_prefix}
+
+ # Check oid_login_perm
+ oid_login_perms = Link.where(tail_uuid: self.email,
+ head_kind: 'arvados#user',
+ link_class: 'permission',
+ name: 'can_login')
+
+ if !oid_login_perms.any?
+ # create openid login permission
+ oid_login_perm = Link.create(link_class: 'permission',
+ name: 'can_login',
+ tail_kind: 'email',
+ tail_uuid: self.email,
+ head_kind: 'arvados#user',
+ head_uuid: self.uuid,
+ properties: login_perm_props
+ )
+ logger.info { "openid login permission: " + oid_login_perm[:uuid] }
+ else
+ oid_login_perm = oid_login_perms.first
+ end
+
+ return oid_login_perm
+ end
+
def create_user_repo_link(repo_name)
# repo_name is optional
if not repo_name
commit c267f657aae5d43389a41861c2b9649c30482468
Author: radhika chippada <radhika at radhika.curoverse>
Date: Fri Apr 4 13:36:01 2014 -0400
Need to remove the user's "all users" group read permission during unsetup.
This shortcoming became apparent during testing when "is_invited" flag is checked.
diff --git a/services/api/app/models/user.rb b/services/api/app/models/user.rb
index 6db1d3e..77e9778 100644
--- a/services/api/app/models/user.rb
+++ b/services/api/app/models/user.rb
@@ -175,6 +175,19 @@ class User < ArvadosModel
Link.delete perm
end
+ # delete "All users' group read permissions for this user
+ group = Group.where(name: 'All users').select do |g|
+ g[:uuid].match /-f+$/
+ end.first
+ group_perms = Link.where(tail_uuid: self.uuid,
+ head_uuid: group[:uuid],
+ head_kind: 'arvados#group',
+ link_class: 'permission',
+ name: 'can_read')
+ group_perms.each do |perm|
+ Link.delete perm
+ end
+
# delete any signatures by this user
signed_uuids = Link.where(link_class: 'signature',
tail_kind: 'arvados#user',
diff --git a/services/api/test/functional/arvados/v1/users_controller_test.rb b/services/api/test/functional/arvados/v1/users_controller_test.rb
index 2a7f686..e62eff8 100644
--- a/services/api/test/functional/arvados/v1/users_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/users_controller_test.rb
@@ -659,7 +659,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
verify_link response_items, 'arvados#virtualMachine', true, 'permission', 'can_login',
@vm_uuid, created['uuid'], 'arvados#virtualMachine', false, 'VirtualMachine'
- verify_link_existence created['uuid'], created['email'], true, true, true, false
+ verify_link_existence created['uuid'], created['email'], true, true, true, true, false
# now unsetup this user
post :unsetup, uuid: created['uuid']
@@ -669,7 +669,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
assert_not_nil created2['uuid'], 'expected uuid for the newly created user'
assert_equal created['uuid'], created2['uuid'], 'expected uuid not found'
- verify_link_existence created['uuid'], created['email'], false, false, false, false
+ verify_link_existence created['uuid'], created['email'], false, false, false, false, false
end
test "unsetup active user" do
@@ -679,9 +679,10 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
active_user = JSON.parse(@response.body)
assert_not_nil active_user['uuid'], 'expected uuid for the active user'
assert active_user['is_active'], 'expected is_active for active user'
+ assert active_user['is_invited'], 'expected is_invited for active user'
verify_link_existence active_user['uuid'], active_user['email'],
- false, false, false, true
+ false, false, false, true, true
authorize_with :admin
@@ -693,9 +694,10 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
assert_not_nil response_user['uuid'], 'expected uuid for the upsetup user'
assert_equal active_user['uuid'], response_user['uuid'], 'expected uuid not found'
assert !response_user['is_active'], 'expected user to be inactive'
+ assert !response_user['is_invited'], 'expected user to be uninvited'
verify_link_existence response_user['uuid'], response_user['email'],
- false, false, false, false
+ false, false, false, false, false
end
def verify_num_links (original_links, expected_additional_links)
@@ -760,7 +762,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
end
def verify_link_existence uuid, email, expect_oid_login_perms,
- expect_repo_perms, expect_vm_perms, expect_signatures
+ expect_repo_perms, expect_vm_perms, expect_group_perms, expect_signatures
# verify that all links are deleted for the user
oid_login_perms = Link.where(tail_uuid: email,
head_kind: 'arvados#user',
@@ -792,6 +794,20 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
assert !vm_login_perms.any?, "expected all vm_login_perms deleted"
end
+ group = Group.where(name: 'All users').select do |g|
+ g[:uuid].match /-f+$/
+ end.first
+ group_read_perms = Link.where(tail_uuid: uuid,
+ head_uuid: group[:uuid],
+ head_kind: 'arvados#group',
+ link_class: 'permission',
+ name: 'can_read')
+ if expect_group_perms
+ assert group_read_perms.any?, "expected all users group read perms"
+ else
+ assert !group_read_perms.any?, "expected all users group perm deleted"
+ end
+
signed_uuids = Link.where(link_class: 'signature',
tail_kind: 'arvados#user',
tail_uuid: uuid)
commit b8ee1ea826cd2f02233893e8e06bac5fc44bb473
Author: radhika chippada <radhika at radhika.curoverse>
Date: Fri Apr 4 10:45:14 2014 -0400
Use webkit driver for Capybara instead of selenium for tests that need dialog handling.
diff --git a/apps/workbench/Gemfile b/apps/workbench/Gemfile
index b273d91..1e43d1c 100644
--- a/apps/workbench/Gemfile
+++ b/apps/workbench/Gemfile
@@ -28,6 +28,7 @@ group :test do
gem 'selenium-webdriver'
gem 'capybara'
gem 'poltergeist'
+ gem 'capybara-webkit'
end
gem 'jquery-rails'
@@ -59,4 +60,4 @@ gem 'RedCloth'
gem 'piwik_analytics'
gem 'httpclient'
gem 'themes_for_rails'
-gem "deep_merge", :require => 'deep_merge/rails_compat'
\ No newline at end of file
+gem "deep_merge", :require => 'deep_merge/rails_compat'
diff --git a/apps/workbench/Gemfile.lock b/apps/workbench/Gemfile.lock
index 0c65ca8..0795f75 100644
--- a/apps/workbench/Gemfile.lock
+++ b/apps/workbench/Gemfile.lock
@@ -48,6 +48,9 @@ GEM
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
+ capybara-webkit (1.1.0)
+ capybara (~> 2.0, >= 2.0.2)
+ json
childprocess (0.5.1)
ffi (~> 1.0, >= 1.0.11)
cliver (0.3.2)
@@ -182,6 +185,7 @@ DEPENDENCIES
bootstrap-sass (~> 3.1.0)
bootstrap-x-editable-rails
capybara
+ capybara-webkit
coffee-rails (~> 3.2.0)
deep_merge
httpclient
diff --git a/apps/workbench/test/integration/users_test.rb b/apps/workbench/test/integration/users_test.rb
index 7555e3a..2472ec8 100644
--- a/apps/workbench/test/integration/users_test.rb
+++ b/apps/workbench/test/integration/users_test.rb
@@ -1,5 +1,4 @@
require 'integration_helper'
-require "selenium-webdriver"
class UsersTest < ActionDispatch::IntegrationTest
test "login as active user but not admin" do
@@ -39,7 +38,7 @@ class UsersTest < ActionDispatch::IntegrationTest
end
test "create a new user" do
- Capybara.current_driver = :selenium
+ Capybara.current_driver = :webkit
visit page_with_token('admin_trustedclient')
click_link 'Users'
@@ -81,7 +80,7 @@ class UsersTest < ActionDispatch::IntegrationTest
end
test "setup the active user" do
- Capybara.current_driver = :selenium
+ Capybara.current_driver = :webkit
visit page_with_token('admin_trustedclient')
click_link 'Users'
@@ -133,7 +132,7 @@ class UsersTest < ActionDispatch::IntegrationTest
end
test "unsetup active user" do
- Capybara.current_driver = :selenium
+ Capybara.current_driver = :webkit
visit page_with_token('admin_trustedclient')
@@ -158,7 +157,6 @@ class UsersTest < ActionDispatch::IntegrationTest
# unsetup user and verify all the above links are deleted
click_link 'Admin'
click_button 'Deactivate Active User'
- page.driver.browser.switch_to.alert.accept
sleep(0.1)
# Should now be back in the Attributes tab for the user
commit 55684214f941cf73ce1eb542943dea24a17d48e5
Author: radhika chippada <radhika at radhika.curoverse>
Date: Thu Apr 3 22:41:42 2014 -0400
Added integration tests for create new user, setup and unsetup existing user. The tests use selenium driver without headless. Hence, we see the browser while these tests are running.
Next step is to use headless to hide the browser during test execution.
diff --git a/apps/workbench/test/integration/users_test.rb b/apps/workbench/test/integration/users_test.rb
index 1576c04..7555e3a 100644
--- a/apps/workbench/test/integration/users_test.rb
+++ b/apps/workbench/test/integration/users_test.rb
@@ -1,9 +1,7 @@
require 'integration_helper'
require "selenium-webdriver"
-#require 'headless'
class UsersTest < ActionDispatch::IntegrationTest
-
test "login as active user but not admin" do
Capybara.current_driver = Capybara.javascript_driver
visit page_with_token('active_trustedclient')
@@ -41,7 +39,7 @@ class UsersTest < ActionDispatch::IntegrationTest
end
test "create a new user" do
- Capybara.current_driver = Capybara.javascript_driver
+ Capybara.current_driver = :selenium
visit page_with_token('admin_trustedclient')
click_link 'Users'
@@ -50,64 +48,36 @@ class UsersTest < ActionDispatch::IntegrationTest
click_link 'Add a new user'
- # for now just check that we are back in Users -> List page
- assert page.has_text? 'zzzzz-tpzed-d9tiejq69daie8f'
- end
-
- #@headless
- test "unsetup active user" do
- Capybara.current_driver = Capybara.javascript_driver
- #Capybara.current_driver = :selenium
-
- visit page_with_token('admin_trustedclient')
-
- click_link 'Users'
-
- assert page.has_link? 'zzzzz-tpzed-xurymjxw79nv3jz'
-
- # click on active user
- click_link 'zzzzz-tpzed-xurymjxw79nv3jz'
-
- # Verify that is_active is set
- click_link 'Attributes'
- assert page.has_text? 'modified_by_user_uuid'
- page.within(:xpath, '//a[@data-name="is_active"]') do
- assert_equal "true", text, "Expected user's is_active to be true"
- end
-
- # go to Admin tab
- click_link 'Admin'
- assert page.has_text? 'As an admin, you can deactivate and reset this user'
-
- # Click on Deactivate button
- click_button 'Deactivate Active User'
-
- # Click Ok in the confirm dialog
-=begin
-#use with selenium
- page.driver.browser.switch_to.alert.accept
sleep(0.1)
popup = page.driver.browser.window_handles.last
- #popup = page.driver.browser.window_handle
page.within_window popup do
- assert has_text? 'Are you sure you want to deactivate'
- click_button "OK"
+ assert has_text? 'Virtual Machine'
+ fill_in "email", :with => "foo at example.com"
+ fill_in "repo_name", :with => "test_repo"
+ click_button "Submit"
end
-# use with poltergeist driver
-popup = page.driver.window_handles.last
-page.within_window popup do
- #fill_in "email", :with => "my_email"
- assert has_text? 'Are you sure you want to deactivate'
- click_button "OK"
-end
-=end
+ sleep(0.1)
+
+ # verify that the new user showed up in the users page
+ assert page.has_text? 'foo at example.com'
+
+ page.within(:xpath, '//tr[@data-object-uuid][1]') do
+ assert (text.include? 'foo at example.com false'), 'Expected email'
+ new_user_uuid = text.split[0]
+
+ # go to the new user's page
+ click_link new_user_uuid
+ end
- # Should now be back in the Attributes tab for the user
assert page.has_text? 'modified_by_user_uuid'
page.within(:xpath, '//a[@data-name="is_active"]') do
- assert_equal "false", text, "Expected user's is_active to be false after unsetup"
+ assert_equal "false", text, "Expected new user's is_active to be false"
end
+
+ click_link 'Metadata'
+ assert page.has_text? '(Repository: test_repo)'
+ assert !(page.has_text? '(VirtualMachine:)')
end
test "setup the active user" do
@@ -160,6 +130,30 @@ end
click_link 'Metadata'
assert page.has_text? '(Repository: second_test_repo)'
assert page.has_text? '(VirtualMachine: testvm.shell)'
+ end
+
+ test "unsetup active user" do
+ Capybara.current_driver = :selenium
+
+ visit page_with_token('admin_trustedclient')
+
+ click_link 'Users'
+
+ assert page.has_link? 'zzzzz-tpzed-xurymjxw79nv3jz'
+
+ # click on active user
+ click_link 'zzzzz-tpzed-xurymjxw79nv3jz'
+
+ # Verify that is_active is set
+ click_link 'Attributes'
+ assert page.has_text? 'modified_by_user_uuid'
+ page.within(:xpath, '//a[@data-name="is_active"]') do
+ assert_equal "true", text, "Expected user's is_active to be true"
+ end
+
+ # go to Admin tab
+ click_link 'Admin'
+ assert page.has_text? 'As an admin, you can deactivate and reset this user'
# unsetup user and verify all the above links are deleted
click_link 'Admin'
@@ -167,7 +161,11 @@ end
page.driver.browser.switch_to.alert.accept
sleep(0.1)
-# popup = page.driver.browser.window_handles.last
+ # Should now be back in the Attributes tab for the user
+ assert page.has_text? 'modified_by_user_uuid'
+ page.within(:xpath, '//a[@data-name="is_active"]') do
+ assert_equal "false", text, "Expected user's is_active to be false after unsetup"
+ end
click_link 'Metadata'
assert !(page.has_text? '(Repository: test_repo)')
commit cb2c6a830abda3390146a4933b8cd8ce6ed55d31
Author: radhika chippada <radhika at radhika.curoverse>
Date: Thu Apr 3 14:23:10 2014 -0400
Integration test for setup user
diff --git a/apps/workbench/test/integration/users_test.rb b/apps/workbench/test/integration/users_test.rb
index 39374e7..1576c04 100644
--- a/apps/workbench/test/integration/users_test.rb
+++ b/apps/workbench/test/integration/users_test.rb
@@ -1,5 +1,5 @@
require 'integration_helper'
-#require "selenium-webdriver"
+require "selenium-webdriver"
#require 'headless'
class UsersTest < ActionDispatch::IntegrationTest
@@ -48,7 +48,7 @@ class UsersTest < ActionDispatch::IntegrationTest
assert page.has_text? 'zzzzz-tpzed-d9tiejq69daie8f'
- click_on 'Add a new user'
+ click_link 'Add a new user'
# for now just check that we are back in Users -> List page
assert page.has_text? 'zzzzz-tpzed-d9tiejq69daie8f'
@@ -111,7 +111,7 @@ end
end
test "setup the active user" do
- Capybara.current_driver = Capybara.javascript_driver
+ Capybara.current_driver = :selenium
visit page_with_token('admin_trustedclient')
click_link 'Users'
@@ -121,29 +121,77 @@ end
# click on active user
click_link 'zzzzz-tpzed-xurymjxw79nv3jz'
- # go to Admin tab
+ # Setup user
click_link 'Admin'
- assert page.has_text? 'As an admin, you can deactivate and reset this user'
+ assert page.has_text? 'As an admin, you can setup'
-=begin
- # Click on Setup button
- click_button 'Setup Active User'
+ click_link 'Setup Active User'
- # Click Ok in the confirm dialog
sleep(0.1)
+ popup = page.driver.browser.window_handles.last
+ page.within_window popup do
+ assert has_text? 'Virtual Machine'
+ fill_in "repo_name", :with => "test_repo"
+ click_button "Submit"
+ end
- popup = page.driver.window_handles.last
+ sleep(0.1)
+ assert page.has_text? 'modified_by_client_uuid'
+
+ click_link 'Metadata'
+ assert page.has_text? '(Repository: test_repo)'
+ assert !(page.has_text? '(VirtualMachine:)')
+
+ # Click on Setup button again and this time also choose a VM
+ click_link 'Admin'
+ click_link 'Setup Active User'
+
+ sleep(0.1)
+ popup = page.driver.browser.window_handles.last
page.within_window popup do
- assert has_text? 'Are you sure you want to deactivate Active User'
- fill_in "email", :with => "test at example.com"
- click_button "Ok"
+ fill_in "repo_name", :with => "second_test_repo"
+ select("testvm.shell", :from => 'vm_uuid')
+ click_button "Submit"
end
- # Should now be back in the Attributes tab for the user
+ sleep(0.1)
assert page.has_text? 'modified_by_client_uuid'
- puts "\n\n************* page now = \n#{page.body}"
-=end
+ click_link 'Metadata'
+ assert page.has_text? '(Repository: second_test_repo)'
+ assert page.has_text? '(VirtualMachine: testvm.shell)'
+
+ # unsetup user and verify all the above links are deleted
+ click_link 'Admin'
+ click_button 'Deactivate Active User'
+ page.driver.browser.switch_to.alert.accept
+ sleep(0.1)
+
+# popup = page.driver.browser.window_handles.last
+
+ click_link 'Metadata'
+ assert !(page.has_text? '(Repository: test_repo)')
+ assert !(page.has_text? '(Repository: second_test_repo)')
+ assert !(page.has_text? '(VirtualMachine: testvm.shell)')
+
+ # setup user again and verify links present
+ click_link 'Admin'
+ click_link 'Setup Active User'
+
+ sleep(0.1)
+ popup = page.driver.browser.window_handles.last
+ page.within_window popup do
+ fill_in "repo_name", :with => "second_test_repo"
+ select("testvm.shell", :from => 'vm_uuid')
+ click_button "Submit"
+ end
+
+ sleep(0.1)
+ assert page.has_text? 'modified_by_client_uuid'
+
+ click_link 'Metadata'
+ assert page.has_text? '(Repository: second_test_repo)'
+ assert page.has_text? '(VirtualMachine: testvm.shell)'
end
end
commit 8f8feb2866fd36bbc44188116d3bed6e4a4109a4
Author: radhika chippada <radhika at radhika.curoverse>
Date: Thu Apr 3 11:05:47 2014 -0400
Submit button enabling revisited
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index 28b2f42..475b696 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -84,9 +84,7 @@
var email_disabled = document.forms["setup_form"]["email"].disabled;
var email_value = document.forms["setup_form"]["email"].value;
var prefix_value = document.forms["setup_form"]["openid_prefix"].value;
- if (email_disabled == true) {
- trigger = false;
- } else if (email_value == null || email_value == "" || prefix_value == null || prefix_value == "") {
+ if ((email_disabled == false) && (email_value == null || email_value == "" || prefix_value == null || prefix_value == "")) {
trigger = true;
}
commit 190fe9cdc4ea41267a89f8c0e54dbc179cd1e4b8
Author: radhika chippada <radhika at radhika.curoverse>
Date: Thu Apr 3 07:39:06 2014 -0400
Submit button enabled when existing user
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index 1995388..28b2f42 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -5,7 +5,6 @@
<% end %>
<% disable_email = uuid != nil %>
<% identity_url_prefix = @current_selections[:identity_url_prefix] %>
- <% disable_url_prefix = (identity_url_prefix != nil) %>
<% selected_repo = @current_selections[:repo_name] %>
<% selected_vm = @current_selections[:vm_uuid] %>
@@ -25,7 +24,7 @@
<% end %>
</tr>
<tr>
- <% if disable_url_prefix %>
+ <% if disable_email %>
<td> Identity URL Prefix   </td>
<td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text"
value="<%=identity_url_prefix%>" disabled=true > </td>
@@ -72,18 +71,22 @@
var $input = $('input:text'),
$register = $('#register');
+ var email_disabled = document.forms["setup_form"]["email"].disabled;
var email_value = document.forms["setup_form"]["email"].value;
var prefix_value = document.forms["setup_form"]["openid_prefix"].value;
- if (email_value == null || email_value == "" || prefix_value == null || prefix_value == "") {
+ if ((email_disabled == false) && (email_value == null || email_value == "" || prefix_value == null || prefix_value == "")) {
$register.attr('disabled', true);
}
$input.keyup(function() {
var trigger = false;
+ var email_disabled = document.forms["setup_form"]["email"].disabled;
var email_value = document.forms["setup_form"]["email"].value;
var prefix_value = document.forms["setup_form"]["openid_prefix"].value;
- if (email_value == null || email_value == "" || prefix_value == null || prefix_value == "") {
+ if (email_disabled == true) {
+ trigger = false;
+ } else if (email_value == null || email_value == "" || prefix_value == null || prefix_value == "") {
trigger = true;
}
commit 9d9b194941e7d3c9b459d27657e3c3c67bf388b8
Author: radhika chippada <radhika at radhika.curoverse>
Date: Thu Apr 3 07:17:03 2014 -0400
popup submit button
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index e7e9990..1995388 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -70,14 +70,19 @@
<script>
var $input = $('input:text'),
- $register = $('#register');
- $register.attr('disabled', true);
+ $register = $('#register');
+
+ var email_value = document.forms["setup_form"]["email"].value;
+ var prefix_value = document.forms["setup_form"]["openid_prefix"].value;
+ if (email_value == null || email_value == "" || prefix_value == null || prefix_value == "") {
+ $register.attr('disabled', true);
+ }
+
$input.keyup(function() {
var trigger = false;
var email_value = document.forms["setup_form"]["email"].value;
var prefix_value = document.forms["setup_form"]["openid_prefix"].value;
-
if (email_value == null || email_value == "" || prefix_value == null || prefix_value == "") {
trigger = true;
}
commit 835332abdd0fb8d0046529ff4d2f026f67736418
Author: radhika chippada <radhika at radhika.curoverse>
Date: Wed Apr 2 21:08:03 2014 -0400
Get the default openid_prefix from config.
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index 9a1f22b..e7e9990 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -9,14 +9,16 @@
<% selected_repo = @current_selections[:repo_name] %>
<% selected_vm = @current_selections[:vm_uuid] %>
- <%= form_tag setup_user_path, {id: 'setup_form', name: 'setup_form', method: 'get', class: 'form-search', remote: true} do %>
+ <%= form_tag setup_user_path, {id: 'setup_form', name: 'setup_form', method: 'get',
+ class: 'form-search', remote: true} do %>
<input id="user_uuid" maxlength="250" name="user_uuid" type="hidden" value="<%=uuid%>">
<div>
<table><tbody>
<tr>
<% if disable_email %>
<td> Email </td>
- <td> <input id="email" maxlength="250" name="email" type="text" value="<%=email%>" disabled=true > </td>
+ <td> <input id="email" maxlength="250" name="email" type="text" value="<%=email%>"
+ disabled=true > </td>
<% else %>
<td> Email </td>
<td> <input id="email" maxlength="250" name="email" type="text" > </td>
@@ -25,10 +27,12 @@
<tr>
<% if disable_url_prefix %>
<td> Identity URL Prefix   </td>
- <td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text" value="<%=identity_url_prefix%>" disabled=true > </td>
+ <td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text"
+ value="<%=identity_url_prefix%>" disabled=true > </td>
<% else %>
<td> Openid Prefix </td>
- <td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text" value="https://www.google.com/accounts/o8/id"> </td>
+ <td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text"
+ value="<%= Rails.configuration.default_openid_prefix %>"> </td>
<% end %>
</tr>
<tr>
diff --git a/apps/workbench/config/application.default.yml b/apps/workbench/config/application.default.yml
index bbed01e..dfc4f03 100644
--- a/apps/workbench/config/application.default.yml
+++ b/apps/workbench/config/application.default.yml
@@ -72,3 +72,4 @@ common:
arvados_theme: default
show_user_agreement_inline: false
secret_token: ~
+ default_openid_prefix: https://www.google.com/accounts/o8/id
commit e8dea4fda0347c612ba6b0d4a8045916febeb680
Author: radhika chippada <radhika at radhika.curoverse>
Date: Wed Apr 2 20:56:54 2014 -0400
Look for repo_name in VM link
diff --git a/services/api/app/models/user.rb b/services/api/app/models/user.rb
index 497a693..6db1d3e 100644
--- a/services/api/app/models/user.rb
+++ b/services/api/app/models/user.rb
@@ -320,7 +320,16 @@ class User < ArvadosModel
head_kind: 'arvados#virtualMachine',
link_class: 'permission',
name: 'can_login')
- if !login_perms.any?
+
+ perm_exists = false
+ login_perms.each do |perm|
+ if perm.properties[:username] == repo_name
+ perm_exists = true
+ break
+ end
+ end
+
+ if !perm_exists
login_perm = Link.create(tail_kind: 'arvados#user',
tail_uuid: self.uuid,
head_kind: 'arvados#virtualMachine',
commit a2164fe94a9909e5b38856b881a1d856f822747d
Author: radhika chippada <radhika at radhika.curoverse>
Date: Wed Apr 2 20:28:14 2014 -0400
Require only email and openid prefix in the setup popup. The other fields are optional.
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index f1c15db..9a1f22b 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -9,7 +9,6 @@
<% selected_repo = @current_selections[:repo_name] %>
<% selected_vm = @current_selections[:vm_uuid] %>
-<% puts "\n\n **************** setup_user_url = #{setup_user_url.inspect}" %>
<%= form_tag setup_user_path, {id: 'setup_form', name: 'setup_form', method: 'get', class: 'form-search', remote: true} do %>
<input id="user_uuid" maxlength="250" name="user_uuid" type="hidden" value="<%=uuid%>">
<div>
@@ -69,14 +68,16 @@
var $input = $('input:text'),
$register = $('#register');
$register.attr('disabled', true);
-
$input.keyup(function() {
var trigger = false;
- $input.each(function() {
- if (!$(this).val()) {
- trigger = true;
- }
- });
+
+ var email_value = document.forms["setup_form"]["email"].value;
+ var prefix_value = document.forms["setup_form"]["openid_prefix"].value;
+
+ if (email_value == null || email_value == "" || prefix_value == null || prefix_value == "") {
+ trigger = true;
+ }
+
trigger ? $register.attr('disabled', true) : $register.removeAttr('disabled');
});
</script>
commit 47d130ae61a2aa0c637060d4a5be9f3728af30b7
Author: radhika chippada <radhika at radhika.curoverse>
Date: Wed Apr 2 19:51:45 2014 -0400
New user creation using setup action is working
diff --git a/apps/workbench/app/views/application/index.html.erb b/apps/workbench/app/views/application/index.html.erb
index d456443..7108c70 100644
--- a/apps/workbench/app/views/application/index.html.erb
+++ b/apps/workbench/app/views/application/index.html.erb
@@ -4,18 +4,20 @@
<% content_for :tab_line_buttons do %>
-<% if controller.model_class.creatable? %>
- <% if controller.model_class.name != 'User' %>
- <%= button_to "Add a new #{controller.model_class.to_s.underscore.gsub '_', ' '}",
- { action: 'create', return_to: request.url },
- { class: 'btn btn-primary pull-right' } %>
- <% else %>
- <%= link_to "Add a new #{controller.model_class.to_s.underscore.gsub '_', ' '}", setup_user_popup_path,
- {class: 'btn btn-primary pull-right', :remote => true, 'data-toggle' => "modal", 'data-target' => '#modal-window'} %>
- <div id="modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
- <% end %>
+ <% if controller.model_class.creatable? %>
-<% end %>
+ <% if controller.model_class.name == 'User' %>
+ <%= link_to "Add a new #{controller.model_class.to_s.underscore.gsub '_', ' '}", setup_user_popup_path,
+ {class: 'btn btn-primary pull-right', :remote => true, 'data-toggle' => "modal",
+ 'data-target' => '#modal-window', return_to: request.url} %>
+ <div id="modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
+ <% else %>
+ <%= button_to "Add a new #{controller.model_class.to_s.underscore.gsub '_', ' '}",
+ { action: 'create', return_to: request.url },
+ { class: 'btn btn-primary pull-right' } %>
+ <% end %>
+
+ <% end %>
<% end %>
diff --git a/apps/workbench/app/views/users/setup.js.erb b/apps/workbench/app/views/users/setup.js.erb
index c4059f0..9134623 100644
--- a/apps/workbench/app/views/users/setup.js.erb
+++ b/apps/workbench/app/views/users/setup.js.erb
@@ -1 +1,2 @@
$("#modal-window").modal("hide");
+document.location.reload();
commit 4efa06e83f82096b70c03192bce74df96ed230c5
Author: radhika chippada <radhika at radhika.curoverse>
Date: Wed Apr 2 18:52:04 2014 -0400
"Add a new user" link uses setup method to create a "loaded" user.
diff --git a/apps/workbench/app/controllers/users_controller.rb b/apps/workbench/app/controllers/users_controller.rb
index 3696ecc..5ace8d6 100644
--- a/apps/workbench/app/controllers/users_controller.rb
+++ b/apps/workbench/app/controllers/users_controller.rb
@@ -149,13 +149,16 @@ class UsersController < ApplicationController
respond_to do |format|
if current_user.andand.is_admin
setup_params = {}
- if params['uuid'] && params['uuid'].size>0
- setup_params[:uuid] = params['uuid']
+ if params['user_uuid'] && params['user_uuid'].size>0
+ setup_params[:uuid] = params['user_uuid']
end
if params['email'] && params['email'].size>0
- user = {email: params['email'], openid_prefix: params['openid_prefix']}
+ user = {email: params['email']}
setup_params[:user] = user
end
+ if params['openid_prefix'] && params['openid_prefix'].size>0
+ setup_params[:openid_prefix] = params['openid_prefix']
+ end
if params['repo_name'] && params['repo_name'].size>0
setup_params[:repo_name] = params['repo_name']
end
diff --git a/apps/workbench/app/views/application/index.html.erb b/apps/workbench/app/views/application/index.html.erb
index 67b5004..d456443 100644
--- a/apps/workbench/app/views/application/index.html.erb
+++ b/apps/workbench/app/views/application/index.html.erb
@@ -5,9 +5,16 @@
<% content_for :tab_line_buttons do %>
<% if controller.model_class.creatable? %>
-<%= button_to "Add a new #{controller.model_class.to_s.underscore.gsub '_', ' '}",
- { action: 'create', return_to: request.url },
- { class: 'btn btn-primary pull-right' } %>
+ <% if controller.model_class.name != 'User' %>
+ <%= button_to "Add a new #{controller.model_class.to_s.underscore.gsub '_', ' '}",
+ { action: 'create', return_to: request.url },
+ { class: 'btn btn-primary pull-right' } %>
+ <% else %>
+ <%= link_to "Add a new #{controller.model_class.to_s.underscore.gsub '_', ' '}", setup_user_popup_path,
+ {class: 'btn btn-primary pull-right', :remote => true, 'data-toggle' => "modal", 'data-target' => '#modal-window'} %>
+ <div id="modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
+ <% end %>
+
<% end %>
<% end %>
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index 5711d95..f1c15db 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -1,18 +1,23 @@
<div class="modal-body">
- <% uuid = @object.uuid %>
- <% disable_email = @object.uuid? %>
+ <% if @object%>
+ <% uuid = @object.uuid %>
+ <% email = @object.email %>
+ <% end %>
+ <% disable_email = uuid != nil %>
<% identity_url_prefix = @current_selections[:identity_url_prefix] %>
<% disable_url_prefix = (identity_url_prefix != nil) %>
<% selected_repo = @current_selections[:repo_name] %>
<% selected_vm = @current_selections[:vm_uuid] %>
- <%= form_tag setup_user_url(id: uuid), {id: 'setup_form', name: 'setup_form', method: 'get', class: 'form-search', remote: true, onSubmit: "validate(); return false;"} do %>
+<% puts "\n\n **************** setup_user_url = #{setup_user_url.inspect}" %>
+ <%= form_tag setup_user_path, {id: 'setup_form', name: 'setup_form', method: 'get', class: 'form-search', remote: true} do %>
+ <input id="user_uuid" maxlength="250" name="user_uuid" type="hidden" value="<%=uuid%>">
<div>
<table><tbody>
<tr>
<% if disable_email %>
<td> Email </td>
- <td> <input id="email" maxlength="250" name="email" type="text" value="<%=@object.email%>" disabled=true > </td>
+ <td> <input id="email" maxlength="250" name="email" type="text" value="<%=email%>" disabled=true > </td>
<% else %>
<td> Email </td>
<td> <input id="email" maxlength="250" name="email" type="text" > </td>
diff --git a/apps/workbench/config/routes.rb b/apps/workbench/config/routes.rb
index 43e9bfa..8c89238 100644
--- a/apps/workbench/config/routes.rb
+++ b/apps/workbench/config/routes.rb
@@ -7,6 +7,8 @@ ArvadosWorkbench::Application.routes.draw do
get 'signatures', on: :collection
end
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
resources :nodes
resources :humans
resources :traits
@@ -24,7 +26,6 @@ ArvadosWorkbench::Application.routes.draw do
get 'activity', :on => :collection
post 'sudo', :on => :member
post 'unsetup', :on => :member
- get 'setup', :on => :member
get 'setup_popup', :on => :member
end
resources :logs
commit e6e7736641231fe43b5f68bf4d0653d4321bbc36
Author: radhika chippada <radhika at radhika.curoverse>
Date: Wed Apr 2 12:57:13 2014 -0400
Minor UI tweaks
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index 8d44e90..5711d95 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -2,6 +2,7 @@
<% uuid = @object.uuid %>
<% disable_email = @object.uuid? %>
<% identity_url_prefix = @current_selections[:identity_url_prefix] %>
+ <% disable_url_prefix = (identity_url_prefix != nil) %>
<% selected_repo = @current_selections[:repo_name] %>
<% selected_vm = @current_selections[:vm_uuid] %>
@@ -11,16 +12,16 @@
<tr>
<% if disable_email %>
<td> Email </td>
- <td> <input id="email" maxlength="250" name="email" type="text" value="<%=@object.email%>" disabled=<%=disable_email%> > </td>
+ <td> <input id="email" maxlength="250" name="email" type="text" value="<%=@object.email%>" disabled=true > </td>
<% else %>
<td> Email </td>
<td> <input id="email" maxlength="250" name="email" type="text" > </td>
<% end %>
</tr>
<tr>
- <% if disable_email %>
- <td> Identity URL Prefix </td>
- <td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text" value="<%=identity_url_prefix%>" disabled=<%=disable_email%> > </td>
+ <% if disable_url_prefix %>
+ <td> Identity URL Prefix   </td>
+ <td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text" value="<%=identity_url_prefix%>" disabled=true > </td>
<% else %>
<td> Openid Prefix </td>
<td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text" value="https://www.google.com/accounts/o8/id"> </td>
@@ -34,6 +35,11 @@
<td> Virtual Machine </td>
<td>
<select name="vm_uuid">
+ <% if selected_vm %>
+ <option value=""> Choose One: </option>
+ <% else %>
+ <option value="" selected> Choose One: </option>
+ <% end %>
<% @vms.each do |vm| %>
<% if selected_vm == vm.uuid %>
<option value=<%=vm.uuid%> selected> <%=vm.hostname%> </option>
@@ -46,7 +52,8 @@
</tr>
</tbody></table>
</div>
- <div align="left">
+ <div align="center">
+ <br/>
<button type="submit" id="register" class="btn btn-primary" autofocus>Submit</button>
<button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Cancel</button>
</div>
diff --git a/apps/workbench/app/views/users/_show_admin.html.erb b/apps/workbench/app/views/users/_show_admin.html.erb
index d9db19c..072d7ee 100644
--- a/apps/workbench/app/views/users/_show_admin.html.erb
+++ b/apps/workbench/app/views/users/_show_admin.html.erb
@@ -6,15 +6,16 @@ account.</p>
<%= button_to "Log in as #{@object.full_name}", sudo_user_url(id: @object.uuid), class: 'btn btn-primary' %>
</blockquote>
-<p>As an admin, you can deactivate and reset this user. This will remove all repository/VM permissions for the user. If you "setup" the user again, the user will have to sign the user agreement again.</p>
+<p>As an admin, you can setup this user. Please input a VM and repository for the user. If you had previously provided any of these items, they are pre-filled for you and you can leave them as is if you would like to reuse them.</p>
<blockquote>
-<%= button_to "Deactivate #{@object.full_name}", unsetup_user_url(id: @object.uuid), class: 'btn btn-primary', confirm: "Are you sure you want to deactivate #{@object.full_name}?"%>
+<%= link_to "Setup #{@object.full_name}", setup_popup_user_url(id: @object.uuid), {class: 'btn btn-primary', :remote => true, 'data-toggle' => "modal", 'data-target' => '#modal-window'} %>
+<div id="modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
</blockquote>
-<p>As an admin, you can setup this user. Please input a VM and repository for the user. If you had previously provided any of these items, they are pre-filled for you and you can leave them as is if you would like to reuse them.</p>
+<p>As an admin, you can deactivate and reset this user. This will remove all repository/VM permissions for the user. If you "setup" the user again, the user will have to sign the user agreement again.</p>
<blockquote>
-<%= link_to "Setup #{@object.full_name}", setup_popup_user_url(id: @object.uuid), {class: 'btn btn-primary', :remote => true, 'data-toggle' => "modal", 'data-target' => '#modal-window'} %>
-<div id="modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
+<%= button_to "Deactivate #{@object.full_name}", unsetup_user_url(id: @object.uuid), class: 'btn btn-primary', confirm: "Are you sure you want to deactivate #{@object.full_name}?"%>
</blockquote>
+
commit 33d7da6903a0fc2c9570a11c939dce6a4894f66e
Author: radhika chippada <radhika at radhika.curoverse>
Date: Wed Apr 2 00:04:16 2014 -0400
Disable submit button until all input fields are filled in.
diff --git a/apps/workbench/app/controllers/users_controller.rb b/apps/workbench/app/controllers/users_controller.rb
index 3a5c2b3..3696ecc 100644
--- a/apps/workbench/app/controllers/users_controller.rb
+++ b/apps/workbench/app/controllers/users_controller.rb
@@ -201,8 +201,8 @@ class UsersController < ApplicationController
name: 'can_login')
if oid_login_perms.any?
- identiry_url_prefix = oid_login_perms.first.identity_url_prefix
- current_selections[:identiry_url_prefix] = identiry_url_prefix
+ prefix_properties = oid_login_perms.first.properties
+ current_selections[:identity_url_prefix] = prefix_properties[:identity_url_prefix]
end
# repo perm
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index f27b474..8d44e90 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -1,15 +1,11 @@
- <div class="modal-header">
- <h3 id="myModalLabel">Information you had already provided is prefilled for you. You may change it as needed.</h3>
- </div>
-
<div class="modal-body">
<% uuid = @object.uuid %>
- <% disable_email = @object.uuid? %>
- <% identity_url_prefix = @current_selections[:identiry_url_prefix] %>
+ <% disable_email = @object.uuid? %>
+ <% identity_url_prefix = @current_selections[:identity_url_prefix] %>
<% selected_repo = @current_selections[:repo_name] %>
<% selected_vm = @current_selections[:vm_uuid] %>
-
- <%= form_tag setup_user_url(id: uuid), method: 'get', remote: true, class: 'form-search' do %>
+
+ <%= form_tag setup_user_url(id: uuid), {id: 'setup_form', name: 'setup_form', method: 'get', class: 'form-search', remote: true, onSubmit: "validate(); return false;"} do %>
<div>
<table><tbody>
<tr>
@@ -27,7 +23,7 @@
<td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text" value="<%=identity_url_prefix%>" disabled=<%=disable_email%> > </td>
<% else %>
<td> Openid Prefix </td>
- <td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text"> </td>
+ <td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text" value="https://www.google.com/accounts/o8/id"> </td>
<% end %>
</tr>
<tr>
@@ -51,8 +47,24 @@
</tbody></table>
</div>
<div align="left">
- <button type="submit" class="btn btn-primary" autofocus>Submit</button>
+ <button type="submit" id="register" class="btn btn-primary" autofocus>Submit</button>
<button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Cancel</button>
</div>
<% end %>
</div>
+
+<script>
+ var $input = $('input:text'),
+ $register = $('#register');
+ $register.attr('disabled', true);
+
+ $input.keyup(function() {
+ var trigger = false;
+ $input.each(function() {
+ if (!$(this).val()) {
+ trigger = true;
+ }
+ });
+ trigger ? $register.attr('disabled', true) : $register.removeAttr('disabled');
+ });
+</script>
commit 20e876e9d9809d6097da440453c20f737229ee28
Author: radhika chippada <radhika at radhika.curoverse>
Date: Tue Apr 1 17:21:12 2014 -0400
Added bootstrap css
diff --git a/apps/workbench/app/assets/stylesheets/bootstrap-modal.css.scss b/apps/workbench/app/assets/stylesheets/bootstrap-modal.css.scss
new file mode 100644
index 0000000..417ca74
--- /dev/null
+++ b/apps/workbench/app/assets/stylesheets/bootstrap-modal.css.scss
@@ -0,0 +1,228 @@
+/*!
+* Bootstrap Modal
+*
+* Copyright Jordan Schroter
+* Licensed under the Apache License v2.0
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+*/
+
+body.modal-open,
+.modal-open .navbar-fixed-top,
+.modal-open .navbar-fixed-bottom {
+ margin-right: 0;
+}
+
+.modal {
+ left: 50%;
+ bottom: auto;
+ right: auto;
+ padding: 0;
+ width: 500px;
+ margin-left: -250px;
+ background-color: #ffffff;
+ border: 1px solid #999999;
+ border: 1px solid rgba(0, 0, 0, 0.2);
+ border-radius: 6px;
+ -webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
+ box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
+ background-clip: padding-box;
+}
+
+.modal.container {
+ max-width: none;
+}
+
+
+.modal-open {
+overflow: hidden;
+}
+
+
+/* add a scroll bar to stop page from jerking around */
+.modal-open.page-overflow .page-container,
+.modal-open.page-overflow .page-container .navbar-fixed-top,
+.modal-open.page-overflow .page-container .navbar-fixed-bottom,
+.modal-open.page-overflow .modal-scrollable {
+overflow-y: scroll;
+}
+
+ at media (max-width: 979px) {
+.modal-open.page-overflow .page-container .navbar-fixed-top,
+.modal-open.page-overflow .page-container .navbar-fixed-bottom {
+overflow-y: visible;
+}
+}
+
+
+.modal-scrollable {
+position: fixed;
+top: 0;
+bottom: 0;
+left: 0;
+right: 0;
+overflow: auto;
+}
+
+.modal.fade {
+top: -100%;
+-webkit-transition: opacity 0.3s linear, top 0.3s ease-out, bottom 0.3s ease-out, margin-top 0.3s ease-out;
+-moz-transition: opacity 0.3s linear, top 0.3s ease-out, bottom 0.3s ease-out, margin-top 0.3s ease-out;
+-o-transition: opacity 0.3s linear, top 0.3s ease-out, bottom 0.3s ease-out, margin-top 0.3s ease-out;
+transition: opacity 0.3s linear, top 0.3s ease-out, bottom 0.3s ease-out, margin-top 0.3s ease-out;
+}
+
+.modal.fade.in {
+top: 50%;
+}
+
+.modal-body {
+max-height: none;
+overflow: visible;
+}
+
+.modal.modal-absolute {
+position: absolute;
+z-index: 950;
+}
+
+.modal .loading-mask {
+position: absolute;
+top: 0;
+bottom: 0;
+left: 0;
+right: 0;
+background: #fff;
+border-radius: 6px;
+}
+
+.modal-backdrop.modal-absolute{
+position: absolute;
+z-index: 940;
+}
+
+.modal-backdrop,
+.modal-backdrop.fade.in{
+opacity: 0.7;
+filter: alpha(opacity=70);
+background: #fff;
+}
+
+/* Modal Overflow */
+
+.modal-overflow.modal {
+top: 1%;
+}
+
+.modal-overflow.modal.fade {
+top: -100%;
+}
+
+.modal-overflow.modal.fade.in {
+top: 1%;
+}
+
+.modal-overflow .modal-body {
+overflow: auto;
+-webkit-overflow-scrolling: touch;
+}
+
+/* Responsive */
+
+ at media (min-width: 1200px) {
+.modal.container {
+width: 1170px;
+margin-left: -585px;
+}
+}
+
+ at media (max-width: 979px) {
+.modal,
+.modal.container,
+.modal.modal-overflow {
+top: 1%;
+right: 1%;
+left: 1%;
+bottom: auto;
+width: auto !important;
+height: auto !important;
+margin: 0 !important;
+padding: 0 !important;
+}
+
+.modal.fade.in,
+.modal.container.fade.in,
+.modal.modal-overflow.fade.in {
+top: 1%;
+bottom: auto;
+}
+
+.modal-body,
+.modal-overflow .modal-body {
+position: static;
+margin: 0;
+height: auto !important;
+max-height: none !important;
+overflow: visible !important;
+}
+
+.modal-footer,
+.modal-overflow .modal-footer {
+position: static;
+}
+}
+
+.loading-spinner {
+position: absolute;
+top: 50%;
+left: 50%;
+margin: -12px 0 0 -12px;
+}
+
+/*
+Animate.css - http://daneden.me/animate
+Licensed under the ☺ license (http://licence.visualidiot.com/)
+
+Copyright (c) 2012 Dan Eden*/
+
+.animated {
+-webkit-animation-duration: 1s;
+-moz-animation-duration: 1s;
+-o-animation-duration: 1s;
+animation-duration: 1s;
+-webkit-animation-fill-mode: both;
+-moz-animation-fill-mode: both;
+-o-animation-fill-mode: both;
+animation-fill-mode: both;
+}
+
+ at -webkit-keyframes shake {
+0%, 100% {-webkit-transform: translateX(0);}
+10%, 30%, 50%, 70%, 90% {-webkit-transform: translateX(-10px);}
+20%, 40%, 60%, 80% {-webkit-transform: translateX(10px);}
+}
+
+ at -moz-keyframes shake {
+0%, 100% {-moz-transform: translateX(0);}
+10%, 30%, 50%, 70%, 90% {-moz-transform: translateX(-10px);}
+20%, 40%, 60%, 80% {-moz-transform: translateX(10px);}
+}
+
+ at -o-keyframes shake {
+0%, 100% {-o-transform: translateX(0);}
+10%, 30%, 50%, 70%, 90% {-o-transform: translateX(-10px);}
+20%, 40%, 60%, 80% {-o-transform: translateX(10px);}
+}
+
+ at keyframes shake {
+0%, 100% {transform: translateX(0);}
+10%, 30%, 50%, 70%, 90% {transform: translateX(-10px);}
+20%, 40%, 60%, 80% {transform: translateX(10px);}
+}
+
+.shake {
+-webkit-animation-name: shake;
+-moz-animation-name: shake;
+-o-animation-name: shake;
+animation-name: shake;
+}
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index 0fc0110..f27b474 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -3,11 +3,11 @@
</div>
<div class="modal-body">
- <%= uuid = @object.uuid %>
- <%= disable_email = @object.uuid? %>
- <%= identity_url_prefix = @current_selections[:identiry_url_prefix] %>
- <%= selected_repo = @current_selections[:repo_name] %>
- <%= selected_vm = @current_selections[:vm_uuid] %>
+ <% uuid = @object.uuid %>
+ <% disable_email = @object.uuid? %>
+ <% identity_url_prefix = @current_selections[:identiry_url_prefix] %>
+ <% selected_repo = @current_selections[:repo_name] %>
+ <% selected_vm = @current_selections[:vm_uuid] %>
<%= form_tag setup_user_url(id: uuid), method: 'get', remote: true, class: 'form-search' do %>
<div>
@@ -51,8 +51,8 @@
</tbody></table>
</div>
<div align="left">
- <button type="submit" class="btn">Submit</button>
- <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
+ <button type="submit" class="btn btn-primary" autofocus>Submit</button>
+ <button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Cancel</button>
</div>
<% end %>
</div>
commit 5a7b7aa6a6a11b5e0a397d01a6fe527169ed5f15
Author: radhika chippada <radhika at radhika.curoverse>
Date: Tue Apr 1 16:26:58 2014 -0400
Pre-fill form fields with previous selections where applicable.
diff --git a/apps/workbench/app/controllers/users_controller.rb b/apps/workbench/app/controllers/users_controller.rb
index 0ed1a95..3a5c2b3 100644
--- a/apps/workbench/app/controllers/users_controller.rb
+++ b/apps/workbench/app/controllers/users_controller.rb
@@ -176,10 +176,60 @@ class UsersController < ApplicationController
def setup_popup
@vms = VirtualMachine.all.results
+
+ @current_selections = find_current_links @object
+
respond_to do |format|
format.html
format.js
end
end
+ protected
+
+ def find_current_links user
+ current_selections = {}
+
+ if !user
+ return current_selections
+ end
+
+ # oid login perm
+ oid_login_perms = Link.where(tail_uuid: user.email,
+ head_kind: 'arvados#user',
+ link_class: 'permission',
+ name: 'can_login')
+
+ if oid_login_perms.any?
+ identiry_url_prefix = oid_login_perms.first.identity_url_prefix
+ current_selections[:identiry_url_prefix] = identiry_url_prefix
+ end
+
+ # repo perm
+ repo_perms = Link.where(tail_uuid: user.uuid,
+ head_kind: 'arvados#repository',
+ link_class: 'permission',
+ name: 'can_write')
+ if repo_perms.any?
+ repo_uuid = repo_perms.first.head_uuid
+ repos = Repository.where(head_uuid: repo_uuid)
+ if repos.any?
+ repo_name = repos.first.name
+ current_selections[:repo_name] = repo_name
+ end
+ end
+
+ # vm login perm
+ vm_login_perms = Link.where(tail_uuid: user.uuid,
+ head_kind: 'arvados#virtualMachine',
+ link_class: 'permission',
+ name: 'can_login')
+ if vm_login_perms.any?
+ vm_uuid = vm_login_perms.first.head_uuid
+ current_selections[:vm_uuid] = vm_uuid
+ end
+
+ return current_selections
+ end
+
end
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index c1b874b..0fc0110 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -5,37 +5,45 @@
<div class="modal-body">
<%= uuid = @object.uuid %>
<%= disable_email = @object.uuid? %>
+ <%= identity_url_prefix = @current_selections[:identiry_url_prefix] %>
+ <%= selected_repo = @current_selections[:repo_name] %>
+ <%= selected_vm = @current_selections[:vm_uuid] %>
+
<%= form_tag setup_user_url(id: uuid), method: 'get', remote: true, class: 'form-search' do %>
<div>
<table><tbody>
<tr>
<% if disable_email %>
- <td> Email : </td>
- <td> <input id="email" maxlength="250" name="email" type="text" disabled=<%=disable_email%> > </td>
+ <td> Email </td>
+ <td> <input id="email" maxlength="250" name="email" type="text" value="<%=@object.email%>" disabled=<%=disable_email%> > </td>
<% else %>
- <td> Email : </td>
+ <td> Email </td>
<td> <input id="email" maxlength="250" name="email" type="text" > </td>
<% end %>
</tr>
<tr>
<% if disable_email %>
- <td> Openid Prefix : </td>
- <td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text" disabled=<%=disable_email%> > </td>
+ <td> Identity URL Prefix </td>
+ <td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text" value="<%=identity_url_prefix%>" disabled=<%=disable_email%> > </td>
<% else %>
- <td> Openid Prefix : </td>
+ <td> Openid Prefix </td>
<td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text"> </td>
<% end %>
</tr>
<tr>
- <td> Repository Name : </td>
- <td> <input id="repo_name" maxlength="250" name="repo_name" type="text">
+ <td> Repository Name </td>
+ <td> <input id="repo_name" maxlength="250" name="repo_name" type="text" value="<%=selected_repo%>">
</tr>
<tr>
- <td> Virtual Machine : </td>
+ <td> Virtual Machine </td>
<td>
<select name="vm_uuid">
<% @vms.each do |vm| %>
- <option value=<%=vm.uuid%> > <%=vm.hostname%> </option>
+ <% if selected_vm == vm.uuid %>
+ <option value=<%=vm.uuid%> selected> <%=vm.hostname%> </option>
+ <% else %>
+ <option value=<%=vm.uuid%> > <%=vm.hostname%> </option>
+ <% end %>
<% end %>
</select>
</td>
commit 9f87668ecf0768f83b95253d8888481b1d8ff95e
Author: radhika chippada <radhika at radhika.curoverse>
Date: Tue Apr 1 14:38:50 2014 -0400
Virtual machines in a dropdown option in setup popup
diff --git a/apps/workbench/app/controllers/users_controller.rb b/apps/workbench/app/controllers/users_controller.rb
index 445848e..0ed1a95 100644
--- a/apps/workbench/app/controllers/users_controller.rb
+++ b/apps/workbench/app/controllers/users_controller.rb
@@ -175,6 +175,7 @@ class UsersController < ApplicationController
end
def setup_popup
+ @vms = VirtualMachine.all.results
respond_to do |format|
format.html
format.js
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index b5af57a..c1b874b 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -1,10 +1,10 @@
- <div class="modal-header">
+ <div class="modal-header">
<h3 id="myModalLabel">Information you had already provided is prefilled for you. You may change it as needed.</h3>
</div>
<div class="modal-body">
<%= uuid = @object.uuid %>
- <%= disable_email = false %>
+ <%= disable_email = @object.uuid? %>
<%= form_tag setup_user_url(id: uuid), method: 'get', remote: true, class: 'form-search' do %>
<div>
<table><tbody>
@@ -32,7 +32,13 @@
</tr>
<tr>
<td> Virtual Machine : </td>
- <td> <input id="vm_uuid" maxlength="250" name="vm_uuid" type="text">
+ <td>
+ <select name="vm_uuid">
+ <% @vms.each do |vm| %>
+ <option value=<%=vm.uuid%> > <%=vm.hostname%> </option>
+ <% end %>
+ </select>
+ </td>
</tr>
</tbody></table>
</div>
commit 4882cd9ebd6311c4f84d8efff21561b1a229e244
Author: radhika chippada <radhika at radhika.curoverse>
Date: Tue Apr 1 13:47:11 2014 -0400
Pass all parameters to the setup method
diff --git a/apps/workbench/app/controllers/users_controller.rb b/apps/workbench/app/controllers/users_controller.rb
index f869920..445848e 100644
--- a/apps/workbench/app/controllers/users_controller.rb
+++ b/apps/workbench/app/controllers/users_controller.rb
@@ -148,7 +148,22 @@ class UsersController < ApplicationController
def setup
respond_to do |format|
if current_user.andand.is_admin
- if @object.setup
+ setup_params = {}
+ if params['uuid'] && params['uuid'].size>0
+ setup_params[:uuid] = params['uuid']
+ end
+ if params['email'] && params['email'].size>0
+ user = {email: params['email'], openid_prefix: params['openid_prefix']}
+ setup_params[:user] = user
+ end
+ if params['repo_name'] && params['repo_name'].size>0
+ setup_params[:repo_name] = params['repo_name']
+ end
+ if params['vm_uuid'] && params['vm_uuid'].size>0
+ setup_params[:vm_uuid] = params['vm_uuid']
+ end
+
+ if User.setup setup_params
format.js
else
self.render_error status: 422
diff --git a/apps/workbench/app/models/user.rb b/apps/workbench/app/models/user.rb
index 24d3958..44d615b 100644
--- a/apps/workbench/app/models/user.rb
+++ b/apps/workbench/app/models/user.rb
@@ -45,10 +45,8 @@ class User < ArvadosBase
{}))
end
- def setup
- $arvados_api_client.api(self.class,
- "/setup",
- {uuid: self.uuid, repo_name: 'abcdefg'})
+ def self.setup params
+ $arvados_api_client.api(self, "/setup", params)
end
end
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index 6f947ef..b5af57a 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -4,7 +4,7 @@
<div class="modal-body">
<%= uuid = @object.uuid %>
- <%= disable_email = @object.uuid? %>
+ <%= disable_email = false %>
<%= form_tag setup_user_url(id: uuid), method: 'get', remote: true, class: 'form-search' do %>
<div>
<table><tbody>
commit a992c11d76c013d42470a5142714d68e918bccfa
Author: radhika chippada <radhika at radhika.curoverse>
Date: Tue Apr 1 11:51:03 2014 -0400
Multiple input elements in popup
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index 1005f21..6f947ef 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -1,12 +1,44 @@
<div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <h3 id="myModalLabel">Modal header</h3>
+ <h3 id="myModalLabel">Information you had already provided is prefilled for you. You may change it as needed.</h3>
</div>
<div class="modal-body">
- <%= form_tag setup_user_url(id: @object.uuid), method: 'get', remote: true, class: 'form-search' do %>
- <input id="repo_name" maxlength="250" name="repo_name" type="text">
- <button type="submit" class="btn">Submit</button>
- <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button> </div>
- <% end %>
+ <%= uuid = @object.uuid %>
+ <%= disable_email = @object.uuid? %>
+ <%= form_tag setup_user_url(id: uuid), method: 'get', remote: true, class: 'form-search' do %>
+ <div>
+ <table><tbody>
+ <tr>
+ <% if disable_email %>
+ <td> Email : </td>
+ <td> <input id="email" maxlength="250" name="email" type="text" disabled=<%=disable_email%> > </td>
+ <% else %>
+ <td> Email : </td>
+ <td> <input id="email" maxlength="250" name="email" type="text" > </td>
+ <% end %>
+ </tr>
+ <tr>
+ <% if disable_email %>
+ <td> Openid Prefix : </td>
+ <td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text" disabled=<%=disable_email%> > </td>
+ <% else %>
+ <td> Openid Prefix : </td>
+ <td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text"> </td>
+ <% end %>
+ </tr>
+ <tr>
+ <td> Repository Name : </td>
+ <td> <input id="repo_name" maxlength="250" name="repo_name" type="text">
+ </tr>
+ <tr>
+ <td> Virtual Machine : </td>
+ <td> <input id="vm_uuid" maxlength="250" name="vm_uuid" type="text">
+ </tr>
+ </tbody></table>
+ </div>
+ <div align="left">
+ <button type="submit" class="btn">Submit</button>
+ <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
+ </div>
+ <% end %>
</div>
commit 1697fcdd746eb5a30127275e533c3d799aa9f681
Author: radhika chippada <radhika at radhika.curoverse>
Date: Mon Mar 31 23:46:42 2014 -0400
Popup closes on submit
diff --git a/apps/workbench/app/controllers/users_controller.rb b/apps/workbench/app/controllers/users_controller.rb
index 7a70d22..f869920 100644
--- a/apps/workbench/app/controllers/users_controller.rb
+++ b/apps/workbench/app/controllers/users_controller.rb
@@ -146,10 +146,17 @@ class UsersController < ApplicationController
end
def setup
- if current_user.andand.is_admin
- @object.setup
+ respond_to do |format|
+ if current_user.andand.is_admin
+ if @object.setup
+ format.js
+ else
+ self.render_error status: 422
+ end
+ else
+ self.render_error status: 422
+ end
end
- show
end
def setup_popup
diff --git a/apps/workbench/app/views/users/setup.js.erb b/apps/workbench/app/views/users/setup.js.erb
new file mode 100644
index 0000000..c4059f0
--- /dev/null
+++ b/apps/workbench/app/views/users/setup.js.erb
@@ -0,0 +1 @@
+$("#modal-window").modal("hide");
commit 921ec0ddab4c949659d54490204acdd431986450
Author: radhika chippada <radhika at radhika.curoverse>
Date: Mon Mar 31 17:54:32 2014 -0400
Working on setup popup
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index b6e9e00..1005f21 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -4,12 +4,9 @@
</div>
<div class="modal-body">
- <form method="POST" class="form-horizontal" onsubmit="return false">
- <input id="repository_name" maxlength="250" name="repositoryname" type="text">
- </form>
+ <%= form_tag setup_user_url(id: @object.uuid), method: 'get', remote: true, class: 'form-search' do %>
+ <input id="repo_name" maxlength="250" name="repo_name" type="text">
+ <button type="submit" class="btn">Submit</button>
+ <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button> </div>
+ <% end %>
</div>
- <div class="modal-footer">
- <button id="save-button" class="btn" onclick="save_user()">Save</button>
- <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
- </div>
-
diff --git a/apps/workbench/app/views/users/_show_admin.html.erb b/apps/workbench/app/views/users/_show_admin.html.erb
index fd979b8..d9db19c 100644
--- a/apps/workbench/app/views/users/_show_admin.html.erb
+++ b/apps/workbench/app/views/users/_show_admin.html.erb
@@ -15,6 +15,6 @@ account.</p>
<p>As an admin, you can setup this user. Please input a VM and repository for the user. If you had previously provided any of these items, they are pre-filled for you and you can leave them as is if you would like to reuse them.</p>
<blockquote>
-<%= link_to "Setup #{@object.full_name}", setup_popup_path, {class: 'btn btn-primary', :remote => true, 'data-toggle' => "modal", 'data-target' => '#modal-window'} %>
+<%= link_to "Setup #{@object.full_name}", setup_popup_user_url(id: @object.uuid), {class: 'btn btn-primary', :remote => true, 'data-toggle' => "modal", 'data-target' => '#modal-window'} %>
<div id="modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
</blockquote>
diff --git a/apps/workbench/app/views/users/setup_popup.js.erb b/apps/workbench/app/views/users/setup_popup.js.erb
index 2eca58b..e725a92 100644
--- a/apps/workbench/app/views/users/setup_popup.js.erb
+++ b/apps/workbench/app/views/users/setup_popup.js.erb
@@ -1,6 +1 @@
-$("#modal-window").html("<%= escape_javascript(render 'setup_popup') %>");
-
-function save_user () {
- $('#modal-window').modal('hide');
- repo_name = document.getElementById ("repository_name").value;
-};
+$("#modal-window").html("<%= escape_javascript(render partial: 'setup_popup') %>");
diff --git a/apps/workbench/config/routes.rb b/apps/workbench/config/routes.rb
index fbda8d4..43e9bfa 100644
--- a/apps/workbench/config/routes.rb
+++ b/apps/workbench/config/routes.rb
@@ -7,7 +7,6 @@ ArvadosWorkbench::Application.routes.draw do
get 'signatures', on: :collection
end
get '/user_agreements/signatures' => 'user_agreements#signatures'
- get 'users/setup_popup' => 'users#setup_popup', :as => :setup_popup
resources :nodes
resources :humans
resources :traits
@@ -24,8 +23,9 @@ ArvadosWorkbench::Application.routes.draw do
get 'welcome', :on => :collection
get 'activity', :on => :collection
post 'sudo', :on => :member
- post 'setup', :on => :member
post 'unsetup', :on => :member
+ get 'setup', :on => :member
+ get 'setup_popup', :on => :member
end
resources :logs
resources :factory_jobs
commit c6cb3423e9ca2b421bda3bb97c1448dcde19df97
Author: radhika chippada <radhika at radhika.curoverse>
Date: Mon Mar 31 10:53:20 2014 -0400
Setup popup display
diff --git a/apps/workbench/app/controllers/users_controller.rb b/apps/workbench/app/controllers/users_controller.rb
index 9c53228..7a70d22 100644
--- a/apps/workbench/app/controllers/users_controller.rb
+++ b/apps/workbench/app/controllers/users_controller.rb
@@ -152,4 +152,11 @@ class UsersController < ApplicationController
show
end
+ def setup_popup
+ respond_to do |format|
+ format.html
+ format.js
+ end
+ end
+
end
diff --git a/apps/workbench/app/models/user.rb b/apps/workbench/app/models/user.rb
index 6009b19..24d3958 100644
--- a/apps/workbench/app/models/user.rb
+++ b/apps/workbench/app/models/user.rb
@@ -48,7 +48,7 @@ class User < ArvadosBase
def setup
$arvados_api_client.api(self.class,
"/setup",
- {uuid: self.uuid})
+ {uuid: self.uuid, repo_name: 'abcdefg'})
end
end
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index 167d4a8..b6e9e00 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -1,15 +1,15 @@
-
-<div id="modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Modal header</h3>
</div>
+
<div class="modal-body">
- Enter something: <input type="text" id="myInput">
+ <form method="POST" class="form-horizontal" onsubmit="return false">
+ <input id="repository_name" maxlength="250" name="repositoryname" type="text">
+ </form>
</div>
<div class="modal-footer">
- <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
- <button class="btn btn-primary">Save changes</button>
+ <button id="save-button" class="btn" onclick="save_user()">Save</button>
+ <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
</div>
-</div>
diff --git a/apps/workbench/app/views/users/_show_admin.html.erb b/apps/workbench/app/views/users/_show_admin.html.erb
index 077de78..fd979b8 100644
--- a/apps/workbench/app/views/users/_show_admin.html.erb
+++ b/apps/workbench/app/views/users/_show_admin.html.erb
@@ -15,11 +15,6 @@ account.</p>
<p>As an admin, you can setup this user. Please input a VM and repository for the user. If you had previously provided any of these items, they are pre-filled for you and you can leave them as is if you would like to reuse them.</p>
<blockquote>
-
-<div>
-<a href="#" class="btn btn-primary" data-toggle="modal"
- data-target="#modal-window">Setup <%= "#{@object.full_name}" %> </a>
- <%= render :partial => 'setup_popup' %>
-</div>
-
+<%= link_to "Setup #{@object.full_name}", setup_popup_path, {class: 'btn btn-primary', :remote => true, 'data-toggle' => "modal", 'data-target' => '#modal-window'} %>
+<div id="modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
</blockquote>
diff --git a/apps/workbench/app/views/users/setup_popup.js.erb b/apps/workbench/app/views/users/setup_popup.js.erb
index a928e96..2eca58b 100644
--- a/apps/workbench/app/views/users/setup_popup.js.erb
+++ b/apps/workbench/app/views/users/setup_popup.js.erb
@@ -1 +1,6 @@
$("#modal-window").html("<%= escape_javascript(render 'setup_popup') %>");
+
+function save_user () {
+ $('#modal-window').modal('hide');
+ repo_name = document.getElementById ("repository_name").value;
+};
diff --git a/apps/workbench/config/routes.rb b/apps/workbench/config/routes.rb
index 7b73346..fbda8d4 100644
--- a/apps/workbench/config/routes.rb
+++ b/apps/workbench/config/routes.rb
@@ -7,6 +7,7 @@ ArvadosWorkbench::Application.routes.draw do
get 'signatures', on: :collection
end
get '/user_agreements/signatures' => 'user_agreements#signatures'
+ get 'users/setup_popup' => 'users#setup_popup', :as => :setup_popup
resources :nodes
resources :humans
resources :traits
commit 3ca0861ae65a9c61f0db226bbe9f70cfc0a4ec7b
Author: radhika chippada <radhika at radhika.curoverse>
Date: Sun Mar 30 21:15:45 2014 -0400
Working on setup popup
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
index fb119c3..167d4a8 100644
--- a/apps/workbench/app/views/users/_setup_popup.html.erb
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -5,11 +5,11 @@
<h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body">
- **here comes whatever you want to show!**
+ Enter something: <input type="text" id="myInput">
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
- <button class="btn btn-primary">Save changes</button>
+ <button class="btn btn-primary">Save changes</button>
</div>
</div>
diff --git a/apps/workbench/app/views/users/_show_admin.html.erb b/apps/workbench/app/views/users/_show_admin.html.erb
index b63f41c..077de78 100644
--- a/apps/workbench/app/views/users/_show_admin.html.erb
+++ b/apps/workbench/app/views/users/_show_admin.html.erb
@@ -17,7 +17,8 @@ account.</p>
<blockquote>
<div>
-<%= button_to "Setup #{@object.full_name}", setup_user_url(id: @object.uuid), {class: 'btn btn-primary', 'data-toggle' => 'modal', 'data-target' => '#modal-window'} %>
+<a href="#" class="btn btn-primary" data-toggle="modal"
+ data-target="#modal-window">Setup <%= "#{@object.full_name}" %> </a>
<%= render :partial => 'setup_popup' %>
</div>
commit fe0d9b8e3a46c610deb95b9a8b501e8c2aad9f54
Author: radhika chippada <radhika at radhika.curoverse>
Date: Sun Mar 30 18:07:46 2014 -0400
Add a setup action to users controller and user model
diff --git a/apps/workbench/app/assets/javascripts/application.js b/apps/workbench/app/assets/javascripts/application.js
index e7884b9..3ad7944 100644
--- a/apps/workbench/app/assets/javascripts/application.js
+++ b/apps/workbench/app/assets/javascripts/application.js
@@ -18,6 +18,7 @@
//= require bootstrap/tooltip
//= require bootstrap/popover
//= require bootstrap/collapse
+//= require bootstrap/modal
//= require bootstrap3-editable/bootstrap-editable
//= require_tree .
diff --git a/apps/workbench/app/controllers/users_controller.rb b/apps/workbench/app/controllers/users_controller.rb
index 1610653..9c53228 100644
--- a/apps/workbench/app/controllers/users_controller.rb
+++ b/apps/workbench/app/controllers/users_controller.rb
@@ -1,7 +1,7 @@
class UsersController < ApplicationController
skip_before_filter :find_object_by_uuid, :only => [:welcome, :activity]
skip_around_filter :thread_with_mandatory_api_token, :only => :welcome
- before_filter :ensure_current_user_is_admin, only: [:sudo, :unsetup]
+ before_filter :ensure_current_user_is_admin, only: [:sudo, :unsetup, :setup]
def welcome
if current_user
@@ -145,4 +145,11 @@ class UsersController < ApplicationController
show
end
+ def setup
+ if current_user.andand.is_admin
+ @object.setup
+ end
+ show
+ end
+
end
diff --git a/apps/workbench/app/models/user.rb b/apps/workbench/app/models/user.rb
index 6c889e6..6009b19 100644
--- a/apps/workbench/app/models/user.rb
+++ b/apps/workbench/app/models/user.rb
@@ -45,4 +45,10 @@ class User < ArvadosBase
{}))
end
+ def setup
+ $arvados_api_client.api(self.class,
+ "/setup",
+ {uuid: self.uuid})
+ end
+
end
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
new file mode 100644
index 0000000..fb119c3
--- /dev/null
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -0,0 +1,15 @@
+
+<div id="modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
+ <h3 id="myModalLabel">Modal header</h3>
+ </div>
+ <div class="modal-body">
+ **here comes whatever you want to show!**
+ </div>
+ <div class="modal-footer">
+ <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
+ <button class="btn btn-primary">Save changes</button>
+ </div>
+</div>
+
diff --git a/apps/workbench/app/views/users/_show_admin.html.erb b/apps/workbench/app/views/users/_show_admin.html.erb
index 90afd11..b63f41c 100644
--- a/apps/workbench/app/views/users/_show_admin.html.erb
+++ b/apps/workbench/app/views/users/_show_admin.html.erb
@@ -11,3 +11,14 @@ account.</p>
<blockquote>
<%= button_to "Deactivate #{@object.full_name}", unsetup_user_url(id: @object.uuid), class: 'btn btn-primary', confirm: "Are you sure you want to deactivate #{@object.full_name}?"%>
</blockquote>
+
+<p>As an admin, you can setup this user. Please input a VM and repository for the user. If you had previously provided any of these items, they are pre-filled for you and you can leave them as is if you would like to reuse them.</p>
+
+<blockquote>
+
+<div>
+<%= button_to "Setup #{@object.full_name}", setup_user_url(id: @object.uuid), {class: 'btn btn-primary', 'data-toggle' => 'modal', 'data-target' => '#modal-window'} %>
+ <%= render :partial => 'setup_popup' %>
+</div>
+
+</blockquote>
diff --git a/apps/workbench/app/views/users/setup_popup.js.erb b/apps/workbench/app/views/users/setup_popup.js.erb
new file mode 100644
index 0000000..a928e96
--- /dev/null
+++ b/apps/workbench/app/views/users/setup_popup.js.erb
@@ -0,0 +1 @@
+$("#modal-window").html("<%= escape_javascript(render 'setup_popup') %>");
diff --git a/apps/workbench/config/routes.rb b/apps/workbench/config/routes.rb
index 6504df0..7b73346 100644
--- a/apps/workbench/config/routes.rb
+++ b/apps/workbench/config/routes.rb
@@ -23,6 +23,7 @@ ArvadosWorkbench::Application.routes.draw do
get 'welcome', :on => :collection
get 'activity', :on => :collection
post 'sudo', :on => :member
+ post 'setup', :on => :member
post 'unsetup', :on => :member
end
resources :logs
diff --git a/apps/workbench/test/integration/users_test.rb b/apps/workbench/test/integration/users_test.rb
index c7769ca..39374e7 100644
--- a/apps/workbench/test/integration/users_test.rb
+++ b/apps/workbench/test/integration/users_test.rb
@@ -1,7 +1,45 @@
require 'integration_helper'
+#require "selenium-webdriver"
+#require 'headless'
class UsersTest < ActionDispatch::IntegrationTest
+ test "login as active user but not admin" do
+ Capybara.current_driver = Capybara.javascript_driver
+ visit page_with_token('active_trustedclient')
+
+ assert page.has_no_link? 'Users' 'Found Users link for non-admin user'
+ end
+
+ test "login as admin user and verify active user data" do
+ Capybara.current_driver = Capybara.javascript_driver
+ visit page_with_token('admin_trustedclient')
+
+ # go to Users list page
+ click_link 'Users'
+
+ # check active user attributes in the list page
+ page.within(:xpath, '//tr[@data-object-uuid="zzzzz-tpzed-xurymjxw79nv3jz"]') do
+ assert (text.include? 'true false'), 'Expected is_active'
+ end
+
+ click_link 'zzzzz-tpzed-xurymjxw79nv3jz'
+ assert page.has_text? 'Attributes'
+ assert page.has_text? 'Metadata'
+ assert page.has_text? 'Admin'
+
+ # go to the Attributes tab
+ click_link 'Attributes'
+ assert page.has_text? 'modified_by_user_uuid'
+ page.within(:xpath, '//a[@data-name="is_active"]') do
+ assert_equal "true", text, "Expected user's is_active to be true"
+ end
+ page.within(:xpath, '//a[@data-name="is_admin"]') do
+ assert_equal "false", text, "Expected user's is_admin to be false"
+ end
+
+ end
+
test "create a new user" do
Capybara.current_driver = Capybara.javascript_driver
visit page_with_token('admin_trustedclient')
@@ -16,8 +54,11 @@ class UsersTest < ActionDispatch::IntegrationTest
assert page.has_text? 'zzzzz-tpzed-d9tiejq69daie8f'
end
+ #@headless
test "unsetup active user" do
Capybara.current_driver = Capybara.javascript_driver
+ #Capybara.current_driver = :selenium
+
visit page_with_token('admin_trustedclient')
click_link 'Users'
@@ -26,11 +67,8 @@ class UsersTest < ActionDispatch::IntegrationTest
# click on active user
click_link 'zzzzz-tpzed-xurymjxw79nv3jz'
- assert page.has_text? 'Attributes'
- assert page.has_text? 'Metadata'
- assert page.has_text? 'Admin'
- # go to the Attributes tab
+ # Verify that is_active is set
click_link 'Attributes'
assert page.has_text? 'modified_by_user_uuid'
page.within(:xpath, '//a[@data-name="is_active"]') do
@@ -46,12 +84,23 @@ class UsersTest < ActionDispatch::IntegrationTest
# Click Ok in the confirm dialog
=begin
+#use with selenium
+ page.driver.browser.switch_to.alert.accept
sleep(0.1)
- popup = page.driver.window_handles.last
+ popup = page.driver.browser.window_handles.last
+ #popup = page.driver.browser.window_handle
page.within_window popup do
- assert has_text? 'Are you sure you want to deactivate Active User'
- click_button "Ok"
+ assert has_text? 'Are you sure you want to deactivate'
+ click_button "OK"
end
+
+# use with poltergeist driver
+popup = page.driver.window_handles.last
+page.within_window popup do
+ #fill_in "email", :with => "my_email"
+ assert has_text? 'Are you sure you want to deactivate'
+ click_button "OK"
+end
=end
# Should now be back in the Attributes tab for the user
@@ -59,7 +108,6 @@ class UsersTest < ActionDispatch::IntegrationTest
page.within(:xpath, '//a[@data-name="is_active"]') do
assert_equal "false", text, "Expected user's is_active to be false after unsetup"
end
-
end
test "setup the active user" do
@@ -72,9 +120,6 @@ class UsersTest < ActionDispatch::IntegrationTest
# click on active user
click_link 'zzzzz-tpzed-xurymjxw79nv3jz'
- assert page.has_text? 'Attributes'
- assert page.has_text? 'Metadata'
- assert page.has_text? 'Admin'
# go to Admin tab
click_link 'Admin'
commit cb19d007add188f2c83a082c419ee0b523fb664b
Author: radhika chippada <radhika at radhika.curoverse>
Date: Fri Mar 28 15:44:31 2014 -0400
Confirm dialog check commented our for now. Why is that I can't intercept the dialog and instead why is the OK button clicked automatically?
diff --git a/apps/workbench/test/integration/users_test.rb b/apps/workbench/test/integration/users_test.rb
index 5c4848e..c7769ca 100644
--- a/apps/workbench/test/integration/users_test.rb
+++ b/apps/workbench/test/integration/users_test.rb
@@ -34,7 +34,7 @@ class UsersTest < ActionDispatch::IntegrationTest
click_link 'Attributes'
assert page.has_text? 'modified_by_user_uuid'
page.within(:xpath, '//a[@data-name="is_active"]') do
- assert_equal text, "true", "Expected user's is_active to be true"
+ assert_equal "true", text, "Expected user's is_active to be true"
end
# go to Admin tab
@@ -45,18 +45,19 @@ class UsersTest < ActionDispatch::IntegrationTest
click_button 'Deactivate Active User'
# Click Ok in the confirm dialog
+=begin
sleep(0.1)
-
popup = page.driver.window_handles.last
page.within_window popup do
assert has_text? 'Are you sure you want to deactivate Active User'
click_button "Ok"
end
+=end
# Should now be back in the Attributes tab for the user
assert page.has_text? 'modified_by_user_uuid'
page.within(:xpath, '//a[@data-name="is_active"]') do
- assert_equal text, "false", "Expected user's is_active to be false after unsetup"
+ assert_equal "false", text, "Expected user's is_active to be false after unsetup"
end
end
commit a15ff495c8c576378f55f58fe22ce9f3c49121e8
Author: radhika chippada <radhika at radhika.curoverse>
Date: Fri Mar 28 15:21:05 2014 -0400
Add users integration test class. Beginnings of setup and unsetup method tests.
diff --git a/apps/workbench/test/integration/users_test.rb b/apps/workbench/test/integration/users_test.rb
new file mode 100644
index 0000000..5c4848e
--- /dev/null
+++ b/apps/workbench/test/integration/users_test.rb
@@ -0,0 +1,103 @@
+require 'integration_helper'
+
+class UsersTest < ActionDispatch::IntegrationTest
+
+ test "create a new user" do
+ Capybara.current_driver = Capybara.javascript_driver
+ visit page_with_token('admin_trustedclient')
+
+ click_link 'Users'
+
+ assert page.has_text? 'zzzzz-tpzed-d9tiejq69daie8f'
+
+ click_on 'Add a new user'
+
+ # for now just check that we are back in Users -> List page
+ assert page.has_text? 'zzzzz-tpzed-d9tiejq69daie8f'
+ end
+
+ test "unsetup active user" do
+ Capybara.current_driver = Capybara.javascript_driver
+ visit page_with_token('admin_trustedclient')
+
+ click_link 'Users'
+
+ assert page.has_link? 'zzzzz-tpzed-xurymjxw79nv3jz'
+
+ # click on active user
+ click_link 'zzzzz-tpzed-xurymjxw79nv3jz'
+ assert page.has_text? 'Attributes'
+ assert page.has_text? 'Metadata'
+ assert page.has_text? 'Admin'
+
+ # go to the Attributes tab
+ click_link 'Attributes'
+ assert page.has_text? 'modified_by_user_uuid'
+ page.within(:xpath, '//a[@data-name="is_active"]') do
+ assert_equal text, "true", "Expected user's is_active to be true"
+ end
+
+ # go to Admin tab
+ click_link 'Admin'
+ assert page.has_text? 'As an admin, you can deactivate and reset this user'
+
+ # Click on Deactivate button
+ click_button 'Deactivate Active User'
+
+ # Click Ok in the confirm dialog
+ sleep(0.1)
+
+ popup = page.driver.window_handles.last
+ page.within_window popup do
+ assert has_text? 'Are you sure you want to deactivate Active User'
+ click_button "Ok"
+ end
+
+ # Should now be back in the Attributes tab for the user
+ assert page.has_text? 'modified_by_user_uuid'
+ page.within(:xpath, '//a[@data-name="is_active"]') do
+ assert_equal text, "false", "Expected user's is_active to be false after unsetup"
+ end
+
+ end
+
+ test "setup the active user" do
+ Capybara.current_driver = Capybara.javascript_driver
+ visit page_with_token('admin_trustedclient')
+
+ click_link 'Users'
+
+ assert page.has_link? 'zzzzz-tpzed-xurymjxw79nv3jz'
+
+ # click on active user
+ click_link 'zzzzz-tpzed-xurymjxw79nv3jz'
+ assert page.has_text? 'Attributes'
+ assert page.has_text? 'Metadata'
+ assert page.has_text? 'Admin'
+
+ # go to Admin tab
+ click_link 'Admin'
+ assert page.has_text? 'As an admin, you can deactivate and reset this user'
+
+=begin
+ # Click on Setup button
+ click_button 'Setup Active User'
+
+ # Click Ok in the confirm dialog
+ sleep(0.1)
+
+ popup = page.driver.window_handles.last
+ page.within_window popup do
+ assert has_text? 'Are you sure you want to deactivate Active User'
+ fill_in "email", :with => "test at example.com"
+ click_button "Ok"
+ end
+
+ # Should now be back in the Attributes tab for the user
+ assert page.has_text? 'modified_by_client_uuid'
+
+ puts "\n\n************* page now = \n#{page.body}"
+=end
+ end
+
+end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list