add Repositories resource, fix authorized_user attr name, some wb fixes
authorTom Clegg <tom@clinicalfuture.com>
Tue, 11 Jun 2013 17:00:06 +0000 (13:00 -0400)
committerTom Clegg <tom@clinicalfuture.com>
Tue, 11 Jun 2013 17:00:06 +0000 (13:00 -0400)
43 files changed:
apps/workbench/app/assets/javascripts/repositories.js.coffee [new file with mode: 0644]
apps/workbench/app/assets/stylesheets/application.css
apps/workbench/app/assets/stylesheets/repositories.css.scss [new file with mode: 0644]
apps/workbench/app/controllers/application_controller.rb
apps/workbench/app/controllers/authorized_keys_controller.rb
apps/workbench/app/controllers/repositories_controller.rb [new file with mode: 0644]
apps/workbench/app/controllers/sessions_controller.rb
apps/workbench/app/helpers/repositories_helper.rb [new file with mode: 0644]
apps/workbench/app/models/arvados_base.rb
apps/workbench/app/models/arvados_resource_list.rb
apps/workbench/app/models/authorized_key.rb
apps/workbench/app/models/repository.rb [new file with mode: 0644]
apps/workbench/app/models/user.rb
apps/workbench/app/views/application/index.html.erb [new file with mode: 0644]
apps/workbench/app/views/authorized_keys/_form.html.erb [deleted file]
apps/workbench/app/views/authorized_keys/index.html.erb [deleted file]
apps/workbench/app/views/authorized_keys/new.html.erb [deleted file]
apps/workbench/app/views/authorized_keys/show.html.erb [deleted file]
apps/workbench/app/views/layouts/application.html.erb
apps/workbench/app/views/virtual_machines/index.html.erb [deleted file]
apps/workbench/config/routes.rb
apps/workbench/test/fixtures/repositories.yml [new file with mode: 0644]
apps/workbench/test/functional/repositories_controller_test.rb [new file with mode: 0644]
apps/workbench/test/unit/helpers/repositories_helper_test.rb [new file with mode: 0644]
apps/workbench/test/unit/repository_test.rb [new file with mode: 0644]
services/api/app/assets/javascripts/repositories.js.coffee [new file with mode: 0644]
services/api/app/assets/stylesheets/repositories.css.scss [new file with mode: 0644]
services/api/app/controllers/application_controller.rb
services/api/app/controllers/arvados/v1/repositories_controller.rb [new file with mode: 0644]
services/api/app/helpers/repositories_helper.rb [new file with mode: 0644]
services/api/app/models/arvados_model.rb
services/api/app/models/authorized_key.rb
services/api/app/models/repository.rb [new file with mode: 0644]
services/api/app/models/user.rb
services/api/config/routes.rb
services/api/db/migrate/20130610202538_create_repositories.rb [new file with mode: 0644]
services/api/db/migrate/20130611163736_rename_authorized_key_authorized_user_to_authorized_user_uuid.rb [new file with mode: 0644]
services/api/db/schema.rb
services/api/test/fixtures/authorized_keys.yml
services/api/test/fixtures/repositories.yml [new file with mode: 0644]
services/api/test/functional/repositories_controller_test.rb [new file with mode: 0644]
services/api/test/unit/helpers/repositories_helper_test.rb [new file with mode: 0644]
services/api/test/unit/repository_test.rb [new file with mode: 0644]

diff --git a/apps/workbench/app/assets/javascripts/repositories.js.coffee b/apps/workbench/app/assets/javascripts/repositories.js.coffee
new file mode 100644 (file)
index 0000000..7615679
--- /dev/null
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
index 829b1759f1eb3e59d4a0a0630f4c61fd466473cd..8f67306c2be6c296a06d70ed1805d092a5642ffc 100644 (file)
@@ -42,3 +42,7 @@ body .editable-empty {
 body .editable-empty:hover {
     color: #0088cc;
 }
+table.arv-index tbody td.arv-object-AuthorizedKey.arv-attr-public_key {
+    overflow-x: hidden;
+    max-width: 120px;
+}
diff --git a/apps/workbench/app/assets/stylesheets/repositories.css.scss b/apps/workbench/app/assets/stylesheets/repositories.css.scss
new file mode 100644 (file)
index 0000000..85e38d2
--- /dev/null
@@ -0,0 +1,3 @@
+// Place all the styles related to the Repositories controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
index b65b00aae9802cf52ff4157bc36621dac35950cb..3fabcaa8ebecd4b4d654ada4f782aa06bfe04965 100644 (file)
@@ -100,12 +100,12 @@ class ApplicationController < ActionController::Base
     end
   end
 
-  protected
-    
   def model_class
     controller_name.classify.constantize
   end
 
+  protected
+    
   def find_object_by_uuid
     if params[:id] and params[:id].match /\D/
       params[:uuid] = params.delete :id
index 5ca5222d6e93ee107078693045fee575a12bab3b..a2beb494e41149b60e1981eaf6b9bbd6aa5ed39e 100644 (file)
@@ -1,12 +1,12 @@
 class AuthorizedKeysController < ApplicationController
   def new
     super
-    @object.authorized_user = current_user.uuid if current_user
+    @object.authorized_user_uuid = current_user.uuid if current_user
     @object.key_type = 'SSH'
   end
 
   def create
-    @object = AuthorizedKey.new authorized_user: current_user.uuid, key_type: 'SSH'
+    @object = AuthorizedKey.new authorized_user_uuid: current_user.uuid, key_type: 'SSH'
     super
   end
 end
diff --git a/apps/workbench/app/controllers/repositories_controller.rb b/apps/workbench/app/controllers/repositories_controller.rb
new file mode 100644 (file)
index 0000000..d710bd6
--- /dev/null
@@ -0,0 +1,2 @@
+class RepositoriesController < ApplicationController
+end
index 6531e3d9ed885ec6f420435222c7e41344d923e0..ba081375892d8b65c8a14a70440cc7a6b510dfc0 100644 (file)
@@ -3,7 +3,7 @@ class SessionsController < ApplicationController
   skip_before_filter :find_object_by_uuid, :only => [:destroy, :index]
   def destroy
     session.clear
-    redirect_to $arvados_api_client.orvos_logout_url(return_to: logged_out_url)
+    redirect_to $arvados_api_client.arvados_logout_url(return_to: logged_out_url)
   end
   def index
     redirect_to root_url if session[:arvados_api_token]
diff --git a/apps/workbench/app/helpers/repositories_helper.rb b/apps/workbench/app/helpers/repositories_helper.rb
new file mode 100644 (file)
index 0000000..2860b5a
--- /dev/null
@@ -0,0 +1,2 @@
+module RepositoriesHelper
+end
index cb4463a9be36932c8dc306cee7fa0d874c3c4a67..267a4a9133ef1c9b5c05372488faa349d0ae332e 100644 (file)
@@ -204,6 +204,10 @@ class ArvadosBase < ActiveRecord::Base
     }
   end
 
+  def self.creatable?
+    current_user
+  end
+
   def editable?
     (current_user and
      (current_user.is_admin or
@@ -257,8 +261,11 @@ class ArvadosBase < ActiveRecord::Base
     self
   end
 
-  def current_user
+  def self.current_user
     Thread.current[:user] ||= User.current if Thread.current[:arvados_api_token]
     Thread.current[:user]
   end
+  def current_user
+    self.class.current_user
+  end
 end
index a3032a67f295e88943d5987cca5c7fa2ace40b57..c8e6de6302863dd8082cdeee7fd8882f46aad527 100644 (file)
@@ -94,4 +94,8 @@ class ArvadosResourceList
   def to_hash
     Hash[results.collect { |x| [x.uuid, x] }]
   end
+
+  def empty?
+    results.empty?
+  end
 end
index 62ee83238dae697bfaa72b71d3994d3077b86fde..c018cc56b04051a442b382c4546f9fea0e253bce 100644 (file)
@@ -1,6 +1,6 @@
 class AuthorizedKey < ArvadosBase
   def attribute_editable?(attr)
-    if attr.to_s == 'authorized_user'
+    if attr.to_s == 'authorized_user_uuid'
       current_user and current_user.is_admin
     else
       super(attr)
diff --git a/apps/workbench/app/models/repository.rb b/apps/workbench/app/models/repository.rb
new file mode 100644 (file)
index 0000000..06c70f4
--- /dev/null
@@ -0,0 +1,5 @@
+class Repository < ArvadosBase
+  def self.creatable?
+    current_user and current_user.is_admin
+  end
+end
index 625f505a1cbe7a66593b5cf1588710090398bddf..0dec2e0ba87936abc7c2550b2f941233a809d50b 100644 (file)
@@ -9,4 +9,8 @@ class User < ArvadosBase
     res = $arvados_api_client.api self, '/current'
     $arvados_api_client.unpack_api_response(res)
   end
+
+  def full_name
+    (self.first_name || "") + " " + (self.last_name || "")
+  end
 end
diff --git a/apps/workbench/app/views/application/index.html.erb b/apps/workbench/app/views/application/index.html.erb
new file mode 100644 (file)
index 0000000..0d7657f
--- /dev/null
@@ -0,0 +1,50 @@
+<% if @objects.empty? %>
+
+<p>
+  No <%= controller.model_class.to_s.underscore.pluralize.gsub '_', ' ' %> to display.
+</p>
+
+<% else %>
+
+<% attr_blacklist = 'created_at modified_at modified_by_user modified_by_client updated_at' %>
+
+<table class="table arv-index">
+  <thead>
+    <tr>
+      <% @objects.first.attributes_for_display.each do |attr, attrvalue| %>
+      <% next if attr_blacklist.index attr %>
+      <th class="arv-attr-<%= attr %>">
+        <%= attr.sub /_uuid/, '' %>
+      </th>
+      <% end %>
+    </tr>
+  </thead>
+      
+  <tbody>
+    <% @objects.each do |object| %>
+    <tr>
+      <% object.attributes_for_display.each do |attr, attrvalue| %>
+      <% next if attr_blacklist.index attr %>
+      <td class="arv-object-<%= object.class.to_s %> arv-attr-<%= attr %>">
+        <% if attr == 'uuid' %>
+        <%= link_to_if_arvados_object object %>
+        <% elsif object.attribute_editable? attr %>
+        <%= render_editable_attribute object, attr %>
+        <% else %>
+        <%= link_to_if_arvados_object attrvalue, {referring_attr: attr, referring_object: @object, with_prefixes: true, with_class_name: true} %>
+        <% end %>
+      </td>
+      <% end %>
+    </tr>
+    <% end %>
+  </tbody>
+
+  <tfoot>
+  </tfoot>
+</table>
+
+<% end %>
+
+<% if controller.model_class.creatable? %>
+<%= button_to "Add a new #{controller.model_class.to_s.underscore.gsub '_', ' '}", { action: 'create', return_to: './' }, { class: 'btn btn-primary' } %>
+<% end %>
diff --git a/apps/workbench/app/views/authorized_keys/_form.html.erb b/apps/workbench/app/views/authorized_keys/_form.html.erb
deleted file mode 100644 (file)
index 5a7231d..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-<%= form_for @object do |f| %>
-<table class="table">
-  <tr>
-    <td>
-      name
-    </td><td>
-      <%= f.text_field :name %>
-    </td>
-  </tr>
-  <tr>
-    <td>
-      authorized user
-    </td><td>
-      <%= f.text_field :authorized_user %>
-    </td>
-  </tr>
-  <tr>
-    <td>
-      public key
-    </td><td>
-      <%= f.text_area :public_key %>
-    </td>
-  </tr>
-  <tr>
-    <td></td>
-    <td>
-      <%= f.submit class: 'btn btn-primary' %>
-    </td>
-  </tr>
-</table>
-<% end %>
diff --git a/apps/workbench/app/views/authorized_keys/index.html.erb b/apps/workbench/app/views/authorized_keys/index.html.erb
deleted file mode 100644 (file)
index bdfc2f7..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-<table class="table">
-  <thead>
-    <tr class="contain-align-left">
-      <th>
-       id
-      </th><th>
-       owner
-      </th><th>
-       name
-      </th><th>
-       key&nbsp;type
-      </th><th>
-       public&nbsp;key
-      </th><th>
-       expires
-      </th>
-    </tr>
-  </thead>
-  <tbody>
-
-    <% @objects.sort_by { |ak| ak[:created_at] }.each do |ak| %>
-
-    <tr>
-      <td>
-        <%= link_to_if_arvados_object ak %>
-      </td><td>
-        <%= render_editable_attribute ak, 'owner' %>
-      </td><td>
-        <%= render_editable_attribute ak, 'name' %>
-      </td><td>
-        <%= render_editable_attribute ak, 'key_type', ak.key_type, "data-type" => "select", "data-source" => '[{value:"SSH",text:"SSH"}]' %>
-      </td><td style="max-width: 120px; overflow-x: hidden">
-        <%= render_editable_attribute ak, 'public_key' %>
-      </td><td>
-        <%= render_editable_attribute ak, 'expires_at' %>
-      </td><td>
-        <%= link_to raw('<i class="icon-trash"></i>'), { action: 'destroy', id: ak.uuid }, { confirm: 'Delete this key?', method: 'delete' } %>
-      </td>
-    </tr>
-
-    <% end %>
-    <% if @objects.count == 0 %>
-    <tr>
-      <td colspan="7">
-        (no authorized keys)
-      </td>
-    </tr>
-    <% end %>
-
-  </tbody>
-</table>
-
-<%= button_to "Add a new key", { action: 'create', return_to: './' }, { class: 'btn btn-primary' } %>
diff --git a/apps/workbench/app/views/authorized_keys/new.html.erb b/apps/workbench/app/views/authorized_keys/new.html.erb
deleted file mode 100644 (file)
index 23997ae..0000000
+++ /dev/null
@@ -1 +0,0 @@
-<%= render partial: 'form' %>
diff --git a/apps/workbench/app/views/authorized_keys/show.html.erb b/apps/workbench/app/views/authorized_keys/show.html.erb
deleted file mode 100644 (file)
index 9079085..0000000
+++ /dev/null
@@ -1 +0,0 @@
-<%= render :partial => 'application/arvados_object' %>
index a9081ccaf5c6b801e1e6f9681cc71d2e78aaa69e..bca12e974d79ed7aa71fd8dd60da4a6ad70498c7 100644 (file)
@@ -35,6 +35,7 @@
            <% [
               [false, 'Keys', authorized_keys_path],
               [false, 'VMs', virtual_machines_path],
+              [false, 'Repos', repositories_path],
               [true, 'Data', collections_path],
               [true, 'Groups', groups_path],
               [true, 'Pipeline Templates', pipeline_templates_path],
@@ -48,6 +49,7 @@
          </ul>
          <ul class="nav pull-right">
       <% if current_user -%>
+            <li><span class="badge badge-info" style="margin: 10px auto 10px; padding-top: 4px; padding-bottom: 4px"><%= current_user.email %></span></li>
             <li><a href="<%= logout_path %>">Log out</a></li>
       <% else -%>
             <li><a href="<%= root_path %>">Log in</a></li>
diff --git a/apps/workbench/app/views/virtual_machines/index.html.erb b/apps/workbench/app/views/virtual_machines/index.html.erb
deleted file mode 100644 (file)
index adc4095..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-<table class="table">
-  <thead>
-    <tr class="contain-align-left">
-      <th>
-       id
-      </th><th>
-       owner
-      </th><th>
-       hostname
-      </th>
-    </tr>
-  </thead>
-  <tbody>
-
-    <% @objects.sort_by { |vm| vm[:hostname] }.each do |vm| %>
-
-    <tr>
-      <td>
-        <%= link_to_if_arvados_object vm %>
-      </td><td>
-        <%= render_editable_attribute vm, 'owner' %>
-      </td><td>
-        <%= render_editable_attribute vm, 'hostname' %>
-      </td>
-    </tr>
-
-    <% end %>
-    <% if @objects.count == 0 %>
-    <tr>
-      <td colspan="7">
-        (no VMs)
-      </td>
-    </tr>
-    <% end %>
-
-  </tbody>
-</table>
-
-<% if current_user and current_user.is_admin %>
-<%= button_to "Add a new VM", { action: 'create', return_to: './' }, { class: 'btn btn-primary' } %>
-<% end %>
index 8e50e0d196ad5b3d1a1ea715a38a925badfdce41..30ef4c2ee941f89d1c7b678569b927d62b1b33b2 100644 (file)
@@ -1,4 +1,7 @@
 ArvadosWorkbench::Application.routes.draw do
+  resources :repositories
+
+
   resources :virtual_machines
 
 
diff --git a/apps/workbench/test/fixtures/repositories.yml b/apps/workbench/test/fixtures/repositories.yml
new file mode 100644 (file)
index 0000000..c63aac0
--- /dev/null
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+# This model initially had no columns defined.  If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+#  column: value
diff --git a/apps/workbench/test/functional/repositories_controller_test.rb b/apps/workbench/test/functional/repositories_controller_test.rb
new file mode 100644 (file)
index 0000000..a49f87a
--- /dev/null
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class RepositoriesControllerTest < ActionController::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end
diff --git a/apps/workbench/test/unit/helpers/repositories_helper_test.rb b/apps/workbench/test/unit/helpers/repositories_helper_test.rb
new file mode 100644 (file)
index 0000000..51b6177
--- /dev/null
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class RepositoriesHelperTest < ActionView::TestCase
+end
diff --git a/apps/workbench/test/unit/repository_test.rb b/apps/workbench/test/unit/repository_test.rb
new file mode 100644 (file)
index 0000000..327170c
--- /dev/null
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class RepositoryTest < ActiveSupport::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end
diff --git a/services/api/app/assets/javascripts/repositories.js.coffee b/services/api/app/assets/javascripts/repositories.js.coffee
new file mode 100644 (file)
index 0000000..7615679
--- /dev/null
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
diff --git a/services/api/app/assets/stylesheets/repositories.css.scss b/services/api/app/assets/stylesheets/repositories.css.scss
new file mode 100644 (file)
index 0000000..85e38d2
--- /dev/null
@@ -0,0 +1,3 @@
+// Place all the styles related to the Repositories controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
index cba949bdedc44c789ef22eaf0105869cf816d6b6..a10ec5e52c3aca2a12173cf6579abd47d18930f4 100644 (file)
@@ -59,7 +59,7 @@ class ApplicationController < ActionController::Base
     end
   end
 
-  unless Rails.application.config.consider_all_requests_local
+  begin
     rescue_from Exception,
     :with => :render_error
     rescue_from ActiveRecord::RecordNotFound,
@@ -70,6 +70,8 @@ class ApplicationController < ActionController::Base
     :with => :render_not_found
     rescue_from ActionController::UnknownAction,
     :with => :render_not_found
+    rescue_from ArvadosModel::PermissionDeniedError,
+    :with => :render_error
   end
 
   def render_error(e)
diff --git a/services/api/app/controllers/arvados/v1/repositories_controller.rb b/services/api/app/controllers/arvados/v1/repositories_controller.rb
new file mode 100644 (file)
index 0000000..d7a6367
--- /dev/null
@@ -0,0 +1,2 @@
+class Arvados::V1::RepositoriesController < ApplicationController
+end
diff --git a/services/api/app/helpers/repositories_helper.rb b/services/api/app/helpers/repositories_helper.rb
new file mode 100644 (file)
index 0000000..2860b5a
--- /dev/null
@@ -0,0 +1,2 @@
+module RepositoriesHelper
+end
index a4a0148d845f95f9ddbcffe0bed048c45747c246..2a19a60c585a9404a08c451ac2d17200a3519cde 100644 (file)
@@ -13,6 +13,9 @@ class ArvadosModel < ActiveRecord::Base
   before_update :maybe_update_modified_by_fields
   validate :ensure_serialized_attribute_type
 
+  class PermissionDeniedError < StandardError
+  end
+
   def self.kind_class(kind)
     kind.match(/^arvados\#(.+?)(_list|List)?$/)[1].pluralize.classify.constantize rescue nil
   end
@@ -33,7 +36,7 @@ class ArvadosModel < ActiveRecord::Base
   protected
 
   def ensure_permission_to_create
-    raise "Permission denied" unless permission_to_create
+    raise PermissionDeniedError unless permission_to_create
   end
 
   def permission_to_create
@@ -41,7 +44,7 @@ class ArvadosModel < ActiveRecord::Base
   end
 
   def ensure_permission_to_update
-    raise "Permission denied" unless permission_to_update
+    raise PermissionDeniedError unless permission_to_update
   end
 
   def permission_to_update
index e931fe77bafcda1e0d260fbe7bdcdc9bae854e84..d079952beed19178f8bfd99704225e56d417d268 100644 (file)
@@ -2,20 +2,20 @@ class AuthorizedKey < ArvadosModel
   include AssignUuid
   include KindAndEtag
   include CommonApiTemplate
-  before_create :permission_to_set_authorized_user
-  before_update :permission_to_set_authorized_user
+  before_create :permission_to_set_authorized_user_uuid
+  before_update :permission_to_set_authorized_user_uuid
 
-  belongs_to :authorized_user, :foreign_key => :authorized_user, :class_name => 'User', :primary_key => :uuid
+  belongs_to :authorized_user, :foreign_key => :authorized_user_uuid, :class_name => 'User', :primary_key => :uuid
 
   api_accessible :superuser, :extend => :common do |t|
     t.add :name
     t.add :key_type
-    t.add :authorized_user
+    t.add :authorized_user_uuid
     t.add :public_key
     t.add :expires_at
   end
 
-  def permission_to_set_authorized_user
+  def permission_to_set_authorized_user_uuid
     # Anonymous users cannot do anything here
     return false if !current_user
 
@@ -23,7 +23,7 @@ class AuthorizedKey < ArvadosModel
     return true if current_user.is_admin
 
     # All users can attach keys to their own accounts
-    return true if current_user.uuid == authorized_user
+    return true if current_user.uuid == authorized_user_uuid
 
     # Default = deny.
     false
diff --git a/services/api/app/models/repository.rb b/services/api/app/models/repository.rb
new file mode 100644 (file)
index 0000000..f9be0bf
--- /dev/null
@@ -0,0 +1,20 @@
+class Repository < ArvadosModel
+  include AssignUuid
+  include KindAndEtag
+  include CommonApiTemplate
+
+  api_accessible :superuser, :extend => :common do |t|
+    t.add :name
+    t.add :fetch_url
+    t.add :push_url
+  end
+
+  protected
+
+  def permission_to_create
+    current_user and current_user.is_admin
+  end
+  def permission_to_update
+    current_user and current_user.is_admin
+  end
+end
index e87fb3159dd966536b627d6657c2fcf383ef46dd..bd4de977cad91301b630ef24d82082f8a31787a8 100644 (file)
@@ -6,7 +6,7 @@ class User < ArvadosModel
   has_many :api_client_authorizations
   before_update :prevent_privilege_escalation
 
-  has_many :authorized_keys, :foreign_key => :authorized_user, :primary_key => :uuid
+  has_many :authorized_keys, :foreign_key => :authorized_user_uuid, :primary_key => :uuid
 
   api_accessible :superuser, :extend => :common do |t|
     t.add :email
index a83e7a871806c54720e7c19314ce1e2423157fa9..8919e8821b2348edcb5bfcd07a83027a7d9a4fb6 100644 (file)
@@ -1,4 +1,5 @@
 Server::Application.routes.draw do
+  resources :repositories
   resources :virtual_machines
   resources :authorized_keys
   resources :keep_disks
@@ -97,6 +98,7 @@ Server::Application.routes.draw do
       resources :keep_disks
       resources :authorized_keys
       resources :virtual_machines
+      resources :repositories
     end
   end
 
diff --git a/services/api/db/migrate/20130610202538_create_repositories.rb b/services/api/db/migrate/20130610202538_create_repositories.rb
new file mode 100644 (file)
index 0000000..27a962d
--- /dev/null
@@ -0,0 +1,18 @@
+class CreateRepositories < ActiveRecord::Migration
+  def change
+    create_table :repositories do |t|
+      t.string :uuid, :null => false
+      t.string :owner, :null => false
+      t.string :modified_by_client
+      t.string :modified_by_user
+      t.datetime :modified_at
+      t.string :name
+      t.string :fetch_url
+      t.string :push_url
+
+      t.timestamps
+    end
+    add_index :repositories, :uuid, :unique => true
+    add_index :repositories, :name
+  end
+end
diff --git a/services/api/db/migrate/20130611163736_rename_authorized_key_authorized_user_to_authorized_user_uuid.rb b/services/api/db/migrate/20130611163736_rename_authorized_key_authorized_user_to_authorized_user_uuid.rb
new file mode 100644 (file)
index 0000000..f1203e9
--- /dev/null
@@ -0,0 +1,13 @@
+class RenameAuthorizedKeyAuthorizedUserToAuthorizedUserUuid < ActiveRecord::Migration
+  def up
+    remove_index :authorized_keys, [:authorized_user, :expires_at]
+    rename_column :authorized_keys, :authorized_user, :authorized_user_uuid
+    add_index :authorized_keys, [:authorized_user_uuid, :expires_at]
+  end
+
+  def down
+    remove_index :authorized_keys, [:authorized_user_uuid, :expires_at]
+    rename_column :authorized_keys, :authorized_user_uuid, :authorized_user
+    add_index :authorized_keys, [:authorized_user, :expires_at]
+  end
+end
index 73b5ff9441d068a0737282dc6f5514ebb6900da0..a2ffacad7d11d9c813040d380472851f0f6e5811 100644 (file)
@@ -11,7 +11,7 @@
 #
 # It's strongly recommended to check this file into your version control system.
 
-ActiveRecord::Schema.define(:version => 20130608053730) do
+ActiveRecord::Schema.define(:version => 20130611163736) do
 
   create_table "api_client_authorizations", :force => true do |t|
     t.string   "api_token",               :null => false
@@ -48,21 +48,21 @@ ActiveRecord::Schema.define(:version => 20130608053730) do
   add_index "api_clients", ["uuid"], :name => "index_api_clients_on_uuid", :unique => true
 
   create_table "authorized_keys", :force => true do |t|
-    t.string   "uuid",               :null => false
-    t.string   "owner",              :null => false
+    t.string   "uuid",                 :null => false
+    t.string   "owner",                :null => false
     t.string   "modified_by_client"
     t.string   "modified_by_user"
     t.datetime "modified_at"
     t.string   "name"
     t.string   "key_type"
-    t.string   "authorized_user"
+    t.string   "authorized_user_uuid"
     t.text     "public_key"
     t.datetime "expires_at"
     t.datetime "created_at"
     t.datetime "updated_at"
   end
 
-  add_index "authorized_keys", ["authorized_user", "expires_at"], :name => "index_authorized_keys_on_authorized_user_and_expires_at"
+  add_index "authorized_keys", ["authorized_user_uuid", "expires_at"], :name => "index_authorized_keys_on_authorized_user_uuid_and_expires_at"
   add_index "authorized_keys", ["uuid"], :name => "index_authorized_keys_on_uuid", :unique => true
 
   create_table "collections", :force => true do |t|
@@ -323,6 +323,22 @@ ActiveRecord::Schema.define(:version => 20130608053730) do
   add_index "pipeline_templates", ["modified_at"], :name => "index_pipeline_templates_on_modified_at"
   add_index "pipeline_templates", ["uuid"], :name => "index_pipeline_templates_on_uuid", :unique => true
 
+  create_table "repositories", :force => true do |t|
+    t.string   "uuid",               :null => false
+    t.string   "owner",              :null => false
+    t.string   "modified_by_client"
+    t.string   "modified_by_user"
+    t.datetime "modified_at"
+    t.string   "name"
+    t.string   "fetch_url"
+    t.string   "push_url"
+    t.datetime "created_at"
+    t.datetime "updated_at"
+  end
+
+  add_index "repositories", ["name"], :name => "index_repositories_on_name"
+  add_index "repositories", ["uuid"], :name => "index_repositories_on_uuid", :unique => true
+
   create_table "specimens", :force => true do |t|
     t.string   "uuid"
     t.string   "owner"
index dfcc27fac530fa6c053adcfe656f8a336ad33699..3b7fe2d14283c566d22aff79497ac55e8b906a43 100644 (file)
@@ -8,7 +8,7 @@ one:
   modified_at: 2013-06-06 14:35:19
   name: MyString
   key_type: MyString
-  authorized_user: MyString
+  authorized_user_uuid: MyString
   public_key: MyText
   expires_at: 2013-06-06 14:35:19
 
@@ -20,6 +20,6 @@ two:
   modified_at: 2013-06-06 14:35:19
   name: MyString
   key_type: MyString
-  authorized_user: MyString
+  authorized_user_uuid: MyString
   public_key: MyText
   expires_at: 2013-06-06 14:35:19
diff --git a/services/api/test/fixtures/repositories.yml b/services/api/test/fixtures/repositories.yml
new file mode 100644 (file)
index 0000000..e3865fb
--- /dev/null
@@ -0,0 +1,9 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+  fetch_url: MyString
+  push_url: MyString
+
+two:
+  fetch_url: MyString
+  push_url: MyString
diff --git a/services/api/test/functional/repositories_controller_test.rb b/services/api/test/functional/repositories_controller_test.rb
new file mode 100644 (file)
index 0000000..a49f87a
--- /dev/null
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class RepositoriesControllerTest < ActionController::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end
diff --git a/services/api/test/unit/helpers/repositories_helper_test.rb b/services/api/test/unit/helpers/repositories_helper_test.rb
new file mode 100644 (file)
index 0000000..51b6177
--- /dev/null
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class RepositoriesHelperTest < ActionView::TestCase
+end
diff --git a/services/api/test/unit/repository_test.rb b/services/api/test/unit/repository_test.rb
new file mode 100644 (file)
index 0000000..327170c
--- /dev/null
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class RepositoryTest < ActiveSupport::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end