Skip to content

Commit

Permalink
tracking list CRUD
Browse files Browse the repository at this point in the history
  • Loading branch information
noel committed Apr 30, 2012
1 parent 5e0b719 commit 56b9682
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 20 deletions.
23 changes: 9 additions & 14 deletions app/controllers/tracking_lists_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,19 @@ class TrackingListsController < ApplicationController
# Prevents the following error from showing up, common in Rails engines
# A copy of ApplicationController has been removed from the module tree but is still active!
unloadable

before_filter :get_trackable_items_user
before_filter :get_tracking_list


def show
respond_to do |format|
format.html
end
@tracking_list = TrackingList.find(params[:id])
end

protected

def get_trackable_items_user
@trackable_items_user = User.find(params[:user_id])
def index
@tracking_lists = TrackingList.all
end

def get_tracking_list
@tracking_list = @trackable_items_user.tracking_list
def new
@tracking_list = TrackingList.new
@tracking_list.save
render :action => "show",:id=>@tracking_list.id
end

end
11 changes: 6 additions & 5 deletions app/views/tracking_lists/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

<table>
<tr>
<th>Title</th>
<th>ID</th>
<th></th>
<th></th>
</tr>

<% @tracking_lists.each do |tracking_list| %>
<tr>
<td><%= tracking_list.title %></td>
<td><%= link_to 'Show', tracking_list %></td>
<td><%= link_to 'Edit', edit_tracking_list_path(tracking_list) %></td>
<td><%= tracking_list.id %></td>
<td><%= link_to 'Show', url_for_tracking_list(tracking_list.id) %></td>
</tr>
<% end %>
</table>
</table>

<%= link_to "Create New Tracking List" , url_for_new_tracking_list %>
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'trackable_items'
# Routes needs more thought since some default routes in ArchivesCentral are taking precedence.
ActionController::Routing::Routes.draw do |map|
map.resources :tracking_lists, :path_prefix => ':urlified_name', :only => [:show, :index]
map.resources :tracking_lists, :path_prefix => ':urlified_name', :only => [:show, :new, :index]
map.resources :repositories, :path_prefix => ':urlified_name'
map.resources :shelf_locations, :path_prefix => ':urlified_name'
end
18 changes: 18 additions & 0 deletions lib/kete_trackable_items_controller_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def self.included(klass)

module UrlFor

# Repository URLs
def url_for_repository(repo_id)
url_for(
:controller => "repositories",
Expand Down Expand Up @@ -44,6 +45,7 @@ def url_for_new_repository
:urlified_name => @current_basket.urlified_name)
end

# Shelf Location URLs
def url_for_shelf_location(shelf_id)
url_for(
:controller => "shelf_locations",
Expand All @@ -67,6 +69,22 @@ def url_to_edit_shelf_location(shelf_id)
:urlified_name => @current_basket.urlified_name,
:id => shelf_id)
end

#Tracking List URLs
def url_for_tracking_list(tracking_list_id)
url_for(
:controller => "tracking_lists",
:action => :show,
:urlified_name => @current_basket.urlified_name,
:id => tracking_list_id)
end

def url_for_new_tracking_list
url_for(
:controller => "tracking_lists",
:action => :new,
:urlified_name => @current_basket.urlified_name)
end
end

end

0 comments on commit 56b9682

Please sign in to comment.