Permalink
Browse files

Various bug fixes and enhancements.

  • Loading branch information...
1 parent a0d46c3 commit 1487a84051c1383867869f28a23838ed09a07c58 @Bringo Bringo committed Mar 27, 2012
Showing with 305 additions and 20 deletions.
  1. +56 −0 app/controllers/annotation_types_controller.rb
  2. +1 −0 app/controllers/assets_controller.rb
  3. +44 −1 app/controllers/genres_controller.rb
  4. +16 −0 app/controllers/instantiation_date_types_controller.rb
  5. +2 −3 app/controllers/instantiations_controller.rb
  6. +2 −2 app/controllers/picklists_controller.rb
  7. +2 −0 app/helpers/annotation_types_helper.rb
  8. +2 −0 app/helpers/instantiation_date_types_helper.rb
  9. +2 −0 app/models/annotation_type.rb
  10. +1 −0 app/models/asset.rb
  11. +7 −0 app/views/annotation_types/_form.html.erb
  12. +2 −0 app/views/annotation_types/edit.html.erb
  13. +26 −0 app/views/annotation_types/index.html.erb
  14. +2 −0 app/views/annotation_types/new.html.erb
  15. +5 −1 app/views/assets/_annotation_fields.html.erb
  16. +8 −0 app/views/assets/_asset_relation.html.erb
  17. +1 −2 app/views/assets/index.haml
  18. +9 −0 app/views/genres/_form.html.erb
  19. +2 −0 app/views/genres/edit.html.erb
  20. +26 −0 app/views/genres/index.html.erb
  21. +2 −0 app/views/genres/new.html.erb
  22. +5 −1 app/views/instantiations/_annotation_fields.html.erb
  23. +7 −5 app/views/instantiations/_form.html.erb
  24. +4 −2 config/auth_rules/mpr.rb
  25. +5 −0 config/auth_rules/wnyc.rb
  26. +3 −2 config/routes.rb
  27. +14 −0 db/migrate/20120325210855_create_annotation_types.rb
  28. +8 −1 db/schema.rb
  29. +9 −0 test/fixtures/annotation_types.yml
  30. +8 −0 test/functional/annotation_types_controller_test.rb
  31. +8 −0 test/functional/instantiation_date_types_controller_test.rb
  32. +8 −0 test/unit/annotation_type_test.rb
  33. +4 −0 test/unit/helpers/annotation_types_helper_test.rb
  34. +4 −0 test/unit/helpers/instantiation_date_types_helper_test.rb
View
56 app/controllers/annotation_types_controller.rb
@@ -0,0 +1,56 @@
+class AnnotationTypesController < ApplicationController
+ before_filter :get_annotation_type, :only => [:edit, :update, :destroy]
+
+ def index
+ respond_to do |format|
+ format.html do
+ @annotation_types = AnnotationType.paginate(:order => "name asc", :page => params[:page], :per_page => 25)
+ end
+ format.json do
+ render :json => AnnotationType.find(:all, :conditions => ["name like ? and visible = 1", "%#{params[:term]}%"],
+ :order => "name ASC").map(&:name)
+ end
+ end
+ end
+
+ def new
+ @annotation_type = AnnotationType.new
+ end
+
+ def create
+ @annotation_type = AnnotationType.new(params[:annotation_type])
+
+ respond_to do |format|
+ if @annotation_type.save
+ flash[:message] = "Successfully created new annotation type."
+ format.html { redirect_to annotation_types_url }
+ else
+ format.html { render :action => "new" }
+ end
+ end
+ end
+
+ def update
+ respond_to do |format|
+ if @annotation_type.update_attributes(params[:annotation_type])
+ flash[:message] = "Successfully updated annotation type."
+ format.html { redirect_to annotation_types_url }
+ else
+ format.html { render :action => "edit" }
+ end
+ end
+ end
+
+ def destroy
+ @annotation_type.destroy
+ flash[:message] = "Successfully destroyed #{@annotation_type.name}"
+ respond_to do |format|
+ format.html { redirect_to annotation_types_url }
+ end
+ end
+
+protected
+ def get_annotation_type
+ @annotation_type = AnnotationType.find(params[:id])
+ end
+end
View
1 app/controllers/assets_controller.rb
@@ -132,6 +132,7 @@ def new
@asset.titles << Title.new(:title_type => TitleType.find_or_create_by_name(tt))
end
end
+ @asset.asset_dates.build
end
format.xml do
View
45 app/controllers/genres_controller.rb
@@ -1,7 +1,9 @@
class GenresController < PicklistsController
+ before_filter :get_genre, :only => [:edit, :update, :destroy]
+
def index
respond_to do |format|
- format.html { super }
+ format.html { @genres = Genre.paginate(:order => "name ASC", :page => params[:page], :per_page => 50) }
format.json do
render :json => @klass.find(:all,
:conditions => ["name like ? and visible = 1", "%#{params[:q]}%"],
@@ -10,6 +12,47 @@ def index
end
end
end
+
+ def new
+ @genre = Genre.new
+ end
+
+ def create
+ @genre = Genre.new(params[:genre])
+
+ respond_to do |format|
+ if @genre.save
+ flash[:message] = "Successfully created new genre."
+ format.html { redirect_to genres_url }
+ else
+ format.html { render :action => "new" }
+ end
+ end
+ end
+
+ def update
+ respond_to do |format|
+ if @genre.update_attributes(params[:genre])
+ flash[:message] = "Successfully updated genre."
+ format.html { redirect_to genres_url }
+ else
+ format.html { render :action => "edit" }
+ end
+ end
+ end
+
+ def destroy
+ @genre.destroy
+ flash[:message] = "Successfully destroyed #{@genre.name}"
+ respond_to do |format|
+ format.html { redirect_to genres_url }
+ end
+ end
+
+protected
+ def get_genre
+ @genre = Genre.find(params[:id])
+ end
protected
def should_emit_warning; false; end
View
16 app/controllers/instantiation_date_types_controller.rb
@@ -0,0 +1,16 @@
+class InstantiationDateTypesController < PicklistsController
+ def set_standard_pbcore
+ @standard_pbcore = %w(availableEnd availableStart broadcast
+ content created issued portrayed published revised).to_set.freeze
+ end
+
+ def index
+ respond_to do |format|
+ format.html { super }
+ format.json do
+ render :json => @klass.find(:all, :conditions => ["name like ? and visible = 1", "%#{params[:term]}%"],
+ :order => "name ASC").map(&:name)
+ end
+ end
+ end
+end
View
5 app/controllers/instantiations_controller.rb
@@ -30,9 +30,8 @@ def new
@instantiation.format_ids.build
end
- # I don't think we need this anymore with the new form design
- #@instantiation.essence_tracks.build
-
+ @instantiation.essence_tracks.build
+
respond_to do |format|
format.html
format.xml { render :xml => @instantiation.to_xml }
View
4 app/controllers/picklists_controller.rb
@@ -9,15 +9,15 @@ class PicklistsController < ApplicationController
'instantiation_generations', 'instantiation_media_types', 'format_physicals',
'identifier_sources', 'publisher_roles', 'relation_types', 'title_types',
'essence_track_types', 'essence_track_identifier_sources',
- 'format_identifier_sources', 'genres', 'extension_names', 'subjects',
+ 'format_identifier_sources', 'genres', 'instantiation_date_types', 'extension_names', 'subjects',
'asset_date_types'
]
def index
respond_to do |format|
format.html do
if @klass.nil?
- @controllers = (SUBCLASSES + ['templates', 'value_lists']).sort
+ @controllers = (SUBCLASSES + ['annotation_types', 'templates', 'value_lists']).sort
render :action => 'picklists_index'
else
@emit_warning = should_emit_warning
View
2 app/helpers/annotation_types_helper.rb
@@ -0,0 +1,2 @@
+module AnnotationTypesHelper
+end
View
2 app/helpers/instantiation_date_types_helper.rb
@@ -0,0 +1,2 @@
+module InstantiationDateTypesHelper
+end
View
2 app/models/annotation_type.rb
@@ -0,0 +1,2 @@
+class AnnotationType < ActiveRecord::Base
+end
View
1 app/models/asset.rb
@@ -157,6 +157,7 @@ class Asset < ActiveRecord::Base
).flatten
end
text(:format) { instantiations.map{|a| a.format.nil? ? '' : a.format.name} }
+ text(:duration) { instantiations.map{|a| a.format_duration.nil? ? '' : a.format_duration }}
time :created_at
time :updated_at
string :uuid
View
7 app/views/annotation_types/_form.html.erb
@@ -0,0 +1,7 @@
+<% semantic_form_for @annotation_type do |f| %>
+ <% f.inputs do %>
+ <%= f.input :name, :as => :string %>
+ <%= f.input :visible %>
+ <% end %>
+ <%= f.buttons %>
+<% end %>
View
2 app/views/annotation_types/edit.html.erb
@@ -0,0 +1,2 @@
+<h2><%= title "Edit: #{@annotation_type.name}" %></h2>
+<%= render 'form' %>
View
26 app/views/annotation_types/index.html.erb
@@ -0,0 +1,26 @@
+<h2><%= title "Annotation Types" %></h2>
+<p>
+ <%= link_to 'Create new Annotation Type', new_annotation_type_path %>
+</p>
+<%= will_paginate @annotation_types %>
+<table class="pbcore-admin">
+ <tr>
+ <th>Type</th>
+ <th>Visible</th>
+ <th></th>
+ <th></th>
+ </tr>
+ <% @annotation_types.each do |annotation_type| -%>
+ <tr class="<%= cycle("odd", "even") -%><%= " visible" if annotation_type.visible %>">
+ <td><%= annotation_type.name %></td>
+ <td class="visibility"><%= yes_or_no(annotation_type.visible) %></td>
+ <td>
+ <%= link_to 'Edit', edit_annotation_type_path(annotation_type) %>
+ </td>
+ <td>
+ <%= link_to('Destroy', annotation_type, :method => "delete", :confirm => "Are you sure?") %>
+ </td>
+ </tr>
+ <% end -%>
+</table>
+<%= will_paginate @annotation_types %>
View
2 app/views/annotation_types/new.html.erb
@@ -0,0 +1,2 @@
+<h2><%= title "New Annotation Type" %></h2>
+<%= render 'form' %>
View
6 app/views/assets/_annotation_fields.html.erb
@@ -1,5 +1,9 @@
<% f.inputs do %>
- <%= f.input :annotation_type, :as => :string, :required => false, :wrapper_html => { :class => "col-1" } %>
+ <%= f.input :annotation_type, :as => :pbcore_combobox,
+ :required => false,
+ :input_html => { :class => "pbcore-autocomplete",
+ "data-autocomplete-source" => annotation_types_path },
+ :wrapper_html => { :class => "col-1" } %>
<%= f.input :annotation, :as => :string, :required => false, :wrapper_html => { :class => "col-2" } %>
<%= link_to_remove_fields "remove", f %>
<% end %>
View
8 app/views/assets/_asset_relation.html.erb
@@ -0,0 +1,8 @@
+<% if asset.relations.present? %>
+ <dl class="asset_dates">
+ <% asset.relations.each do |relation| %>
+ <dt><%= relation.relation_type.name %>:</dt>
+ <dd><%= relation.relation_identifier %></dd>
+ <% end %>
+ </dl>
+<% end %>
View
3 app/views/assets/index.haml
@@ -9,10 +9,9 @@
%h2
= link_to asset.title, asset_url(asset.uuid)
%h3&= asset.identifier
+ = render "asset_date", :asset => asset
- if PBCore.config["show_asset_descriptions_in_search_results"].present? and PBCore.config["show_asset_descriptions_in_search_results"] == true
= render "asset_description", :asset => asset
- - else
- = render "asset_date", :asset => asset
- if asset.has_thumbnail?
= link_to img_thumb_tag(asset.thumbnail, "thumb", "80x60"), asset_url(asset.uuid), :class => "index_thumbnail"
View
9 app/views/genres/_form.html.erb
@@ -0,0 +1,9 @@
+<% semantic_form_for @genre do |f| %>
+ <% f.inputs do %>
+ <%= f.input :name, :as => :string %>
+ <%= f.input :genre_authority_used, :as => :string, :label => "Source" %>
+ <%= f.input :ref, :as => :string %>
+ <%= f.input :visible %>
+ <% end %>
+ <%= f.buttons %>
+<% end %>
View
2 app/views/genres/edit.html.erb
@@ -0,0 +1,2 @@
+<h2><%= title "Edit: #{@genre.name}" %></h2>
+<%= render 'form' %>
View
26 app/views/genres/index.html.erb
@@ -0,0 +1,26 @@
+<h2><%= title "Genres" %></h2>
+<p>
+ <%= link_to 'Create new Genre', new_genre_path %>
+</p>
+<%= will_paginate @genres %>
+<table class="pbcore-admin">
+ <tr>
+ <th>Genre</th>
+ <th>Visible</th>
+ <th></th>
+ <th></th>
+ </tr>
+ <% @genres.each do |genre| -%>
+ <tr class="<%= cycle("odd", "even") -%><%= " visible" if genre.visible %>">
+ <td><%= genre.name %></td>
+ <td class="visibility"><%= yes_or_no(genre.visible) %></td>
+ <td>
+ <%= link_to 'Edit', edit_genre_path(genre) %>
+ </td>
+ <td>
+ <%= link_to('Destroy', genre, :method => "delete", :confirm => "Are you sure?") if genre.safe_to_delete? %>
+ </td>
+ </tr>
+ <% end -%>
+</table>
+<%= will_paginate @genres %>
View
2 app/views/genres/new.html.erb
@@ -0,0 +1,2 @@
+<h2><%= title "New Genre" %></h2>
+<%= render 'form' %>
View
6 app/views/instantiations/_annotation_fields.html.erb
@@ -1,5 +1,9 @@
<% f.inputs do %>
- <%= f.input :annotation_type, :as => :string, :required => false, :wrapper_html => { :class => "col-1" } %>
+ <%= f.input :annotation_type, :as => :pbcore_combobox,
+ :required => false,
+ :input_html => { :class => "pbcore-autocomplete",
+ "data-autocomplete-source" => annotation_types_path },
+ :wrapper_html => { :class => "col-1" } %>
<%= f.input :annotation, :as => :string, :required => false, :wrapper_html => { :class => "col-2" } %>
<%= link_to_remove_fields "remove", f %>
<% end %>
View
12 app/views/instantiations/_form.html.erb
@@ -19,11 +19,13 @@
<% end %>
<%= add_another form, :instantiation_dimensions %>
- <h3>Instantiation Standard</h3>
- <% form.inputs do %>
- <%= form.input :standard, :as => :string, :required => false %>
- <%= form.input :standard_ref, :as => :string, :label => "Ref", :required => false %>
- <%= form.input :standard_source, :as => :string, :label => "Source", :required => false %>
+ <% unless PBCore.config["theme"] == "wnyc" %>
+ <h3>Instantiation Standard</h3>
+ <% form.inputs do %>
+ <%= form.input :standard, :as => :string, :required => false %>
+ <%= form.input :standard_ref, :as => :string, :label => "Ref", :required => false %>
+ <%= form.input :standard_source, :as => :string, :label => "Source", :required => false %>
+ <% end %>
<% end %>
<h3>Instantiation Information</h3>
View
6 config/auth_rules/mpr.rb
@@ -10,9 +10,10 @@
has_permission_on :users, :to => [:show, :update] do
if_attribute :id => is { user.id }
end
+ has_permission_on :annotation_types, :to => :read
has_permission_on :picklists, :to => [:read]
- (PicklistsController::SUBCLASSES - ['subjects']).each do |kl|
- has_permission_on kl.to_sym, :to => [:read]
+ (PicklistsController::SUBCLASSES.each do |kl|
+ has_permission_on kl.to_sym, :to => :read
end
end
@@ -48,6 +49,7 @@
(PicklistsController::SUBCLASSES - ['subjects']).each do |kl|
has_permission_on kl.to_sym, :to => :crud
end
+ has_permission_on :annotation_types, :to => :crud
has_permission_on :assets, :to => :multilend
has_permission_on :assets, :to => :destroy_found_set
has_permission_on :assets, :to => :replace
View
5 config/auth_rules/wnyc.rb 100644 → 100755
@@ -10,6 +10,10 @@
has_permission_on :users, :to => [:show, :update] do
if_attribute :id => is { user.id }
end
+ has_permission_on :annotation_types, :to => :read
+ (PicklistsController::SUBCLASSES).each do |kl|
+ has_permission_on kl.to_sym, :to => :read
+ end
end
role :cataloger do
@@ -44,6 +48,7 @@
(PicklistsController::SUBCLASSES - ['subjects']).each do |kl|
has_permission_on kl.to_sym, :to => :crud
end
+ has_permission_on :annotation_types, :to => :crud
has_permission_on :assets, :to => :multilend
has_permission_on :assets, :to => :destroy_found_set
has_permission_on :assets, :to => :replace
View
5 config/routes.rb
@@ -1,4 +1,5 @@
ActionController::Routing::Routes.draw do |map|
+
map.resources :s3_uploads
map.logout '/logout', :controller => 'sessions', :action => 'destroy'
@@ -22,12 +23,12 @@
[:audience_levels, :audience_ratings, :contributor_roles, :creator_roles,
:description_types, :instantiation_colors, :instantiation_generations, :instantiation_media_types,
- :format_digitals, :format_physicals, :identifier_sources, :publisher_roles,
+ :format_digitals, :format_physicals, :identifier_sources, :instantiation_date_types, :publisher_roles,
:relation_types, :title_types, :essence_track_types, :essence_track_identifier_sources,
:format_identifier_sources, :genres, :extension_names, :subjects, :asset_date_types].each do |t|
map.resources t
end
-
+ map.resources :annotation_types
map.resources :value_lists
map.resources :languages, :only => [:index]
map.ids 'ids', :controller => 'last_used_ids', :action => 'index'
View
14 db/migrate/20120325210855_create_annotation_types.rb
@@ -0,0 +1,14 @@
+class CreateAnnotationTypes < ActiveRecord::Migration
+ def self.up
+ create_table :annotation_types do |t|
+ t.string :name
+ t.boolean :visible, :default => true
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :annotation_types
+ end
+end
View
9 db/schema.rb
@@ -9,7 +9,14 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120214070449) do
+ActiveRecord::Schema.define(:version => 20120325210855) do
+
+ create_table "annotation_types", :force => true do |t|
+ t.string "name"
+ t.boolean "visible"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
create_table "annotations", :force => true do |t|
t.integer "container_id"
View
9 test/fixtures/annotation_types.yml
@@ -0,0 +1,9 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+one:
+ string:
+ boolean:
+
+two:
+ string:
+ boolean:
View
8 test/functional/annotation_types_controller_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class AnnotationTypesControllerTest < ActionController::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
View
8 test/functional/instantiation_date_types_controller_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class InstantiationDateTypesControllerTest < ActionController::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
View
8 test/unit/annotation_type_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class AnnotationTypeTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
View
4 test/unit/helpers/annotation_types_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class AnnotationTypesHelperTest < ActionView::TestCase
+end
View
4 test/unit/helpers/instantiation_date_types_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class InstantiationDateTypesHelperTest < ActionView::TestCase
+end

0 comments on commit 1487a84

Please sign in to comment.