sufia 2.0.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +111 -0
  3. data/Gemfile +4 -4
  4. data/History.md +126 -0
  5. data/README.md +23 -5
  6. data/SUFIA_VERSION +1 -1
  7. data/app/assets/javascripts/sufia/multiForm.js +10 -2
  8. data/app/assets/stylesheets/{application-bootstrap.css → application-bootstrap.css.erb} +7 -7
  9. data/app/assets/stylesheets/{bootstrap.min.css → bootstrap.min.css.erb} +1 -1
  10. data/app/controllers/concerns/sufia/users_controller_behavior.rb +9 -3
  11. data/app/controllers/single_use_link_controller.rb +1 -1
  12. data/app/helpers/sufia_helper.rb +7 -1
  13. data/app/models/contact_form.rb +0 -14
  14. data/app/views/_user_util_links.html.erb +0 -15
  15. data/app/views/batch_edits/_check_all.html.erb +2 -2
  16. data/app/views/batch_edits/_delete_selected.html.erb +1 -1
  17. data/app/views/layouts/{_head-tag-content.html.erb → _head_tag_content.html.erb} +0 -0
  18. data/app/views/layouts/homepage.html.erb +2 -2
  19. data/app/views/layouts/sufia-one-column.html.erb +1 -1
  20. data/app/views/layouts/sufia-two-column.html.erb +1 -1
  21. data/app/views/users/edit.html.erb +1 -1
  22. data/app/views/users/show.html.erb +1 -17
  23. data/config/routes.rb +31 -33
  24. data/lib/generators/sufia/sufia_generator.rb +5 -3
  25. data/lib/generators/sufia/templates/catalog_controller.rb +5 -1
  26. data/lib/generators/sufia/templates/config/redis_config.rb +1 -14
  27. data/lib/sufia/batch_edits_controller_behavior.rb +1 -1
  28. data/lib/sufia/controller.rb +1 -1
  29. data/lib/sufia/dashboard_controller_behavior.rb +8 -2
  30. data/lib/sufia/files_controller_behavior.rb +1 -2
  31. data/lib/sufia/version.rb +1 -1
  32. data/spec/active_fedora/unsaved_digital_object_spec.rb +1 -15
  33. data/spec/controllers/authorities_controller_spec.rb +1 -15
  34. data/spec/controllers/batch_controller_spec.rb +10 -16
  35. data/spec/controllers/batch_edits_controller_spec.rb +1 -1
  36. data/spec/controllers/catalog_controller_spec.rb +1 -15
  37. data/spec/controllers/dashboard_controller_spec.rb +23 -17
  38. data/spec/controllers/downloads_controller_spec.rb +1 -15
  39. data/spec/controllers/generic_files_controller_spec.rb +18 -32
  40. data/spec/controllers/mailbox_controller_spec.rb +1 -15
  41. data/spec/controllers/single_use_link_controller_spec.rb +6 -13
  42. data/spec/controllers/users_controller_spec.rb +27 -41
  43. data/spec/factories/users.rb +5 -14
  44. data/spec/features/browse_dashboard_files.rb +21 -0
  45. data/spec/features/browse_files.rb +31 -0
  46. data/spec/features/contact_form.rb +99 -0
  47. data/spec/features/display_dashboard.rb +46 -0
  48. data/spec/features/ingest_upload_files.rb +24 -0
  49. data/spec/features/users_spec.rb +25 -0
  50. data/spec/helpers/generic_file_helper_spec.rb +10 -3
  51. data/spec/helpers/sufia_helper_spec.rb +1 -1
  52. data/spec/lib/sufia/id_service_spec.rb +1 -15
  53. data/spec/models/audit_job_spec.rb +1 -15
  54. data/spec/models/batch_spec.rb +1 -15
  55. data/spec/models/batch_update_job_spec.rb +3 -16
  56. data/spec/models/characterize_job_spec.rb +4 -4
  57. data/spec/models/checksum_audit_log_spec.rb +1 -15
  58. data/spec/models/event_jobs_spec.rb +1 -15
  59. data/spec/models/file_content_datastream_spec.rb +5 -19
  60. data/spec/models/fits_datastream_spec.rb +1 -15
  61. data/spec/models/generic_file/web_form_spec.rb +34 -0
  62. data/spec/models/generic_file_spec.rb +11 -39
  63. data/spec/models/local_authority_spec.rb +3 -15
  64. data/spec/models/properties_datastream_spec.rb +1 -1
  65. data/spec/models/single_use_link_spec.rb +1 -1
  66. data/spec/models/solr_document_spec.rb +1 -1
  67. data/spec/models/transcode_audio_job_spec.rb +1 -1
  68. data/spec/models/transcode_video_job_spec.rb +1 -1
  69. data/spec/models/trophy_spec.rb +1 -1
  70. data/spec/models/unzip_job_spec.rb +1 -15
  71. data/spec/models/user_spec.rb +1 -15
  72. data/spec/rake/sufia_fixtures_spec.rb +3 -17
  73. data/spec/routing/route_spec.rb +7 -21
  74. data/spec/spec_helper.rb +8 -20
  75. data/spec/support/features.rb +6 -0
  76. data/spec/support/features/session_helpers.rb +21 -0
  77. data/spec/support/lib/generators/test_app_generator.rb +4 -0
  78. data/spec/views/batch_edits/check_all_spec.rb +6 -4
  79. data/sufia-models/app/models/checksum_audit_log.rb +1 -15
  80. data/sufia-models/app/models/domain_term.rb +3 -15
  81. data/sufia-models/app/models/geo_names_resource.rb +1 -13
  82. data/sufia-models/app/models/local_authority.rb +12 -17
  83. data/sufia-models/app/models/local_authority_entry.rb +1 -15
  84. data/sufia-models/app/models/single_use_link.rb +2 -3
  85. data/sufia-models/app/models/trophy.rb +1 -1
  86. data/sufia-models/app/models/version_committer.rb +1 -15
  87. data/sufia-models/lib/sufia/models.rb +6 -2
  88. data/sufia-models/lib/sufia/models/engine.rb +1 -1
  89. data/sufia-models/lib/sufia/models/generic_file.rb +3 -0
  90. data/sufia-models/lib/sufia/models/generic_file/accessible_attributes.rb +87 -0
  91. data/sufia-models/lib/sufia/models/generic_file/permissions.rb +2 -1
  92. data/sufia-models/lib/sufia/models/generic_file/web_form.rb +4 -1
  93. data/sufia-models/lib/sufia/models/user.rb +9 -2
  94. data/sufia-models/lib/sufia/models/version.rb +1 -1
  95. data/{lib → sufia-models/lib}/tasks/resque.rake +0 -0
  96. data/sufia-models/sufia-models.gemspec +13 -11
  97. data/sufia.gemspec +1 -3
  98. data/tasks/sufia-dev.rake +21 -10
  99. metadata +30 -84
  100. data/config/cucumber.yml +0 -8
  101. data/features/browse_dashboard_files.feature +0 -16
  102. data/features/browse_files.feature +0 -16
  103. data/features/contact_form.feature +0 -86
  104. data/features/display_dashboard.feature +0 -42
  105. data/features/ingest_upload_files.feature +0 -21
  106. data/features/step_definitions/edit_metadata_steps.rb +0 -89
  107. data/features/step_definitions/fixture_steps.rb +0 -35
  108. data/features/step_definitions/show_document_steps.rb +0 -103
  109. data/features/step_definitions/sufia.rb +0 -69
  110. data/features/step_definitions/user_steps.rb +0 -58
  111. data/features/step_definitions/web_steps.rb +0 -235
  112. data/features/support/cleanup.rb +0 -19
  113. data/features/support/env.rb +0 -90
  114. data/features/support/headless.rb +0 -26
  115. data/features/support/paths.rb +0 -101
  116. data/features/users.feature +0 -18
  117. data/spec/lib/sufia/role_mapper_spec.rb +0 -28
  118. data/spec/support/Gemfile +0 -24
  119. data/spec/views/single_user_link/download.html.erb_spec.rb +0 -5
  120. data/spec/views/single_user_link/generate_download.html.erb_spec.rb +0 -5
  121. data/spec/views/single_user_link/generate_show.html.erb_spec.rb +0 -5
  122. data/spec/views/single_user_link/show.html.erb_spec.rb +0 -5
  123. data/tasks/cucumber.rake +0 -72
@@ -73,7 +73,7 @@ class SingleUseLinkController < DownloadsController
73
73
  def lookup_hash
74
74
  id = params[:id]
75
75
  # invalid hash send not found
76
- link = SingleUseLink.find_by_downloadKey(id) || not_found
76
+ link = SingleUseLink.where(downloadKey:id).first || not_found
77
77
 
78
78
  # expired hash send not found
79
79
  now = DateTime.now
@@ -96,8 +96,14 @@ module SufiaHelper
96
96
  if item.is_a? Array
97
97
  render_array_facet_value(facet_solr_field, item, options)
98
98
  end
99
- path =sufia.url_for(add_facet_params_and_redirect(facet_solr_field, item.value).merge(:only_path=>true))
99
+ if params[:controller] == "dashboard"
100
+ path = sufia.url_for(add_facet_params_and_redirect(facet_solr_field, item.value).merge(:only_path=>true))
100
101
  (link_to_unless(options[:suppress_link], item.value, path, :class=>"facet_select") + " " + render_facet_count(item.hits)).html_safe
102
+ else
103
+ # This is for controllers that use this helper method that are defined outside Sufia
104
+ path = url_for(add_facet_params_and_redirect(facet_solr_field, item.value).merge(:only_path=>true))
105
+ (link_to_unless(options[:suppress_link], item.value, path, :class=>"facet_select") + " " + render_facet_count(item.hits)).html_safe
106
+ end
101
107
  end
102
108
 
103
109
  # link_back_to_catalog(:label=>'Back to Search')
@@ -1,17 +1,3 @@
1
- # Copyright © 2012 The Pennsylvania State University
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
1
  require 'mail_form'
16
2
 
17
3
  class ContactForm < MailForm::Base
@@ -1,18 +1,3 @@
1
- <%#
2
- Copyright © 2012 The Pennsylvania State University
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- %>
16
1
  <% if user_signed_in? %>
17
2
  <%= render :partial => 'users/notify_link' %>
18
3
  <a href="<%= sufia.profile_path(current_user) %>" class="btn btn-small " title="click for User Profile"><i class="icon-user">&nbsp;</i><%= current_user.name %></a>
@@ -3,7 +3,7 @@
3
3
  <%= check_box_tag 'check_all', 'yes', @all_checked, :disabled => ((@batch_size_on_other_page + @document_list.count) > @max_batch_size) %>
4
4
  <a class="dropdown-toggle" data-toggle="dropdown" href="#"><span class="icon-cog" title="click for selection options"></span></a>
5
5
  <ul class="dropdown-menu">
6
- <%= render partial:'batch_edits_actions' %>
6
+ <%= render partial: "#{controller_name}/batch_edits_actions" %>
7
7
  </ul>
8
8
  </div>
9
- <% end %>
9
+ <% end %>
@@ -1,4 +1,4 @@
1
- <%= form_tag(batch_edits_path, :method => :put, :class=> "batch-select-all hidden", "data-behavior" => 'batch-select-all') do -%>
1
+ <%= form_tag(batch_edits_path, :method => :delete, :class=> "batch-select-all hidden", "data-behavior" => 'batch-select-all') do -%>
2
2
  <%= hidden_field_tag('update_type', 'delete_all') %>
3
3
  <%= submit_tag("Delete Selected", :class=>'batch-all-button btn btn-primary submits-batches', :data => { :confirm => "Deleting a file from #{t('sufia.product_name')} is permanent. Click OK to delete this file from #{t('sufia.product_name')}, or Cancel to cancel this operation"}) %>
4
4
  <% end %>
@@ -17,7 +17,7 @@ limitations under the License.
17
17
  <!DOCTYPE html>
18
18
  <html>
19
19
  <head>
20
- <%= render :partial => "layouts/head-tag-content"%>
20
+ <%= render :partial => "layouts/head_tag_content"%>
21
21
  </head>
22
22
 
23
23
  <body>
@@ -53,4 +53,4 @@ limitations under the License.
53
53
  <%= render partial: '/footer' %>
54
54
  <div id="ajax-modal" class="modal hide" tabindex="-1"></div>
55
55
  </body>
56
- </html>
56
+ </html>
@@ -17,7 +17,7 @@ limitations under the License.
17
17
  <!DOCTYPE html>
18
18
  <html>
19
19
  <head>
20
- <%= render :partial => "layouts/head-tag-content"%>
20
+ <%= render :partial => "layouts/head_tag_content"%>
21
21
  </head>
22
22
 
23
23
  <body>
@@ -17,7 +17,7 @@ limitations under the License.
17
17
  <!DOCTYPE html>
18
18
  <html>
19
19
  <head>
20
- <%= render :partial => "layouts/head-tag-content"%>
20
+ <%= render :partial => "layouts/head_tag_content"%>
21
21
  </head>
22
22
 
23
23
  <body>
@@ -21,7 +21,7 @@ $("a[rel=popover]").popover({ html: true });
21
21
 
22
22
  <h1>Edit Profile</h1>
23
23
  <div class="span45 well">
24
- <%= form_for @user, :url => sufia.update_profile_path(URI.escape(@user.to_s, '@.')), :html => {:multipart => true, :class => 'form-horizontal' } do |f| %>
24
+ <%= form_for @user, :url => sufia.profile_path(URI.escape(@user.to_s, '@.')), :html => {:multipart => true, :class => 'form-horizontal' } do |f| %>
25
25
  <div class="control-group">
26
26
  <%= f.label :avatar, '<i class="icon-camera-retro"></i> Change picture'.html_safe, :class => "control-label" %>
27
27
  <div class="controls">
@@ -1,19 +1,3 @@
1
- <%#
2
- Copyright © 2012 The Pennsylvania State University
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- %>
16
-
17
1
  <h1 class="span110">
18
2
  <span class="span60">
19
3
  <%= image_tag @user.avatar.url(:thumb), :width => 100 %>
@@ -24,7 +8,7 @@ limitations under the License.
24
8
  <% if not signed_in? %>
25
9
  <!-- sign in to access social functions -->
26
10
  <% elsif current_user == @user %>
27
- <a class="btn btn-primary" href="<%= sufia.edit_profile_path(URI.escape(@user.to_s, '@.')) %>"><i class="icon-edit"></i> Edit Your Profile </a>
11
+ <a class="btn btn-primary" href="<%= sufia.edit_profile_path(@user) %>"><i class="icon-edit"></i> Edit Your Profile </a>
28
12
  <% elsif current_user.following?(@user) %>
29
13
  <a class="btn btn-primary" href="<%= sufia.unfollow_user_path(@user.to_s) %>"><i class="icon-eye-close"></i> Unfollow </a>
30
14
  <% else %>
data/config/routes.rb CHANGED
@@ -1,19 +1,19 @@
1
1
  Sufia::Engine.routes.draw do
2
- match 'single_use_link/generate_download/:id' => 'single_use_link#generate_download', :as => :generate_download_single_use_link
3
- match 'single_use_link/generate_show/:id' => 'single_use_link#generate_show', :as => :generate_show_single_use_link
4
- match 'single_use_link/show/:id' => 'single_use_link#show', :as => :show_single_use_link
5
- match 'single_use_link/download/:id' => 'single_use_link#download', :as => :download_single_use_link
2
+ get 'single_use_link/generate_download/:id' => 'single_use_link#generate_download', :as => :generate_download_single_use_link
3
+ get 'single_use_link/generate_show/:id' => 'single_use_link#generate_show', :as => :generate_show_single_use_link
4
+ get 'single_use_link/show/:id' => 'single_use_link#show', :as => :show_single_use_link
5
+ get 'single_use_link/download/:id' => 'single_use_link#download', :as => :download_single_use_link
6
6
 
7
- match 'batch_edits/clear' => 'batch_edits#clear', :as => :batch_edits_clear
7
+ match 'batch_edits/clear' => 'batch_edits#clear', :as => :batch_edits_clear, via: [:get, :post]
8
8
 
9
9
  # Route path-less requests to the index view of catalog
10
10
  root :to => "catalog#index"
11
11
 
12
12
  # "Recently added files" route for catalog index view
13
- match "catalog/recent" => "catalog#recent", :as => :catalog_recent
13
+ get "catalog/recent" => "catalog#recent", :as => :catalog_recent
14
14
 
15
15
  # "Notifications" route for catalog index view
16
- match "users/notifications_number" => "users#notifications_number", :as => :user_notify
16
+ get "users/notifications_number" => "users#notifications_number", :as => :user_notify
17
17
 
18
18
  # Generic file routes
19
19
  resources :generic_files, :path => :files, :except => :index do
@@ -27,21 +27,19 @@ Sufia::Engine.routes.draw do
27
27
  resources :downloads, :only => "show"
28
28
 
29
29
  # Messages
30
- match 'notifications' => 'mailbox#index', :as => :mailbox
31
- match 'notifications/delete_all' => 'mailbox#delete_all', :as => :mailbox_delete_all
32
- match 'notifications/:uid/delete' => 'mailbox#delete', :as => :mailbox_delete
30
+ get 'notifications' => 'mailbox#index', :as => :mailbox
31
+ match 'notifications/delete_all' => 'mailbox#delete_all', as: :mailbox_delete_all, via: [:get, :post]
32
+ match 'notifications/:uid/delete' => 'mailbox#delete', as: :mailbox_delete, via: [:get, :post]
33
33
 
34
34
  # User profile & follows
35
- match 'users' => 'users#index', :as => :profiles
36
- match 'users/:uid' => 'users#show', :as => :profile
37
- match 'users/:uid/edit' => 'users#edit', :as => :edit_profile
38
- match 'users/:uid/update' => 'users#update', :as => :update_profile, :via => :put
39
- match "users/:uid/trophy" => "users#toggle_trophy", :as => :update_trophy_user, :via => :post
40
-
41
-
42
-
43
- match 'users/:uid/follow' => 'users#follow', :as => :follow_user
44
- match 'users/:uid/unfollow' => 'users#unfollow', :as => :unfollow_user
35
+ resources :users, only: [:index, :show, :edit, :update], as: :profiles
36
+ # get 'users' => 'users#index', :as => :profiles
37
+ # get 'users/:uid' => 'users#show', :as => :profile
38
+ # get 'users/:uid/edit' => 'users#edit', :as => :edit_profile
39
+ # put 'users/:uid/update' => 'users#update', :as => :update_profile
40
+ post "users/:id/trophy" => "users#toggle_trophy", :as => :update_trophy_user
41
+ match 'users/:id/follow' => 'users#follow', :as => :follow_user, via: [:get, :post]
42
+ match 'users/:id/unfollow' => 'users#unfollow', :as => :unfollow_user, via: [:get, :post]
45
43
 
46
44
  # Dashboard routes (based partly on catalog routes)
47
45
  resources 'dashboard', :only=>:index do
@@ -54,23 +52,23 @@ Sufia::Engine.routes.draw do
54
52
 
55
53
 
56
54
  # advanced routes for advanced search
57
- match 'search' => 'advanced#index', :as => :advanced
55
+ get 'search' => 'advanced#index', :as => :advanced
58
56
 
59
57
  # Authority vocabulary queries route
60
- match 'authorities/:model/:term' => 'authorities#query'
58
+ get 'authorities/:model/:term' => 'authorities#query'
61
59
 
62
60
  # LDAP-related routes for group and user lookups
63
- match 'directory/user/:uid' => 'directory#user'
64
- match 'directory/user/:uid/:attribute' => 'directory#user_attribute'
65
- match 'directory/group/:cn' => 'directory#group', :constraints => { :cn => /.*/ }
61
+ get 'directory/user/:uid' => 'directory#user'
62
+ get 'directory/user/:uid/:attribute' => 'directory#user_attribute'
63
+ get 'directory/group/:cn' => 'directory#group', :constraints => { :cn => /.*/ }
66
64
 
67
65
  # Batch edit routes
68
- match 'batches/:id/edit' => 'batch#edit', :as => :batch_edit
69
- match 'batches/:id/' => 'batch#update', :as => :batch_generic_files
66
+ get 'batches/:id/edit' => 'batch#edit', :as => :batch_edit
67
+ post 'batches/:id/' => 'batch#update', :as => :batch_generic_files
70
68
 
71
69
  # Contact form routes
72
- match 'contact' => 'contact_form#create', :via => :post, :as => :contact_form_index
73
- match 'contact' => 'contact_form#new', :via => :get, :as => :contact_form_index
70
+ post 'contact' => 'contact_form#create', :as => :contact_form_index
71
+ get 'contact' => 'contact_form#new'
74
72
 
75
73
  # Resque monitoring routes. Don't bother with this route unless Sufia::ResqueAdmin
76
74
  # has been defined in the initalizers.
@@ -83,15 +81,15 @@ Sufia::Engine.routes.draw do
83
81
  end
84
82
 
85
83
  # Static page routes (workaround)
86
- match ':action' => 'static#:action', :constraints => { :action => /about|help|terms|zotero|mendeley|agreement|subject_libraries|versions/ }, :as => :static
84
+ get ':action' => 'static#:action', :constraints => { :action => /about|help|terms|zotero|mendeley|agreement|subject_libraries|versions/ }, :as => :static
87
85
 
88
86
  #Single use link errors
89
- match 'single_use_link/not_found' => 'errors#single_use_error'
90
- match 'single_use_link/expired' => 'errors#single_use_error'
87
+ get 'single_use_link/not_found' => 'errors#single_use_error'
88
+ get 'single_use_link/expired' => 'errors#single_use_error'
91
89
 
92
90
  # Catch-all (for routing errors)
93
91
  unless Rails.env.development? || Rails.env.test?
94
- match '*error' => 'errors#routing'
92
+ match '*error' => 'errors#routing', via: [:get, :post]
95
93
  end
96
94
 
97
95
  end
@@ -62,7 +62,7 @@ add_groups_to_users.rb create_local_authorities.rb create_trophies.rb}.each do
62
62
  " \n# Adds Sufia behaviors into the application controller \n" +
63
63
  " include Sufia::Controller\n"
64
64
  end
65
- gsub_file file_path, "layout 'blacklight'", "layout 'sufia-one-column'"
65
+ gsub_file file_path, "layout 'blacklight'", "layout :search_layout"
66
66
  else
67
67
  puts " \e[31mFailure\e[0m Could not find #{file_path}. To add Sufia behaviors to your Controllers, you must include the Sufia::Controller module in the Controller class definition."
68
68
  end
@@ -86,9 +86,11 @@ add_groups_to_users.rb create_local_authorities.rb create_trophies.rb}.each do
86
86
  sentinel = /HydraHead.add_routes\(self\)/
87
87
  inject_into_file 'config/routes.rb', "\n #{routing_code}\n", { :after => sentinel, :verbose => false }
88
88
 
89
- routing_code = "mount Sufia::Engine => '/'"
89
+ routing_code = "\n # This must be the very last route in the file because it has a catch all route for 404 errors.
90
+ # This behavior seems to show up only in production mode.
91
+ mount Sufia::Engine => '/'\n"
90
92
  sentinel = /devise_for :users/
91
- inject_into_file 'config/routes.rb', "\n #{routing_code}\n", { :after => sentinel, :verbose => false }
93
+ inject_into_file 'config/routes.rb', routing_code, { :after => sentinel, :verbose => false }
92
94
 
93
95
  end
94
96
 
@@ -56,7 +56,7 @@ class CatalogController < ApplicationController
56
56
 
57
57
  def recent_me
58
58
  if user_signed_in?
59
- (_, @recent_user_documents) = get_search_results(:q =>filter_not_mine,
59
+ (_, @recent_user_documents) = get_search_results(:q =>filter_mine,
60
60
  :sort=>sort_field, :rows=>4)
61
61
  end
62
62
  end
@@ -377,6 +377,10 @@ class CatalogController < ApplicationController
377
377
  "{!lucene q.op=AND df=#{depositor}}-#{current_user.user_key}"
378
378
  end
379
379
 
380
+ def filter_mine
381
+ "{!lucene q.op=AND df=#{depositor}}#{current_user.user_key}"
382
+ end
383
+
380
384
  def sort_field
381
385
  "#{Solrizer.solr_name('system_create', :sortable)} desc"
382
386
  end
@@ -1,17 +1,3 @@
1
- # Copyright © 2012 The Pennsylvania State University
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
1
  if defined?(PhusionPassenger)
16
2
  PhusionPassenger.on_event(:starting_worker_process) do |forked|
17
3
  # We're in smart spawning mode.
@@ -23,6 +9,7 @@ if defined?(PhusionPassenger)
23
9
  # The important two lines
24
10
  $redis.client.disconnect if $redis
25
11
  $redis = Redis.new(host: config[:host], port: config[:port], thread_safe: true) rescue nil
12
+ Resque.redis = $redis
26
13
  Resque.redis.client.reconnect if Resque.redis
27
14
  end
28
15
  end
@@ -34,7 +34,7 @@ module Sufia
34
34
 
35
35
  # map the permissions to parameter like input so that the assign will work
36
36
  # todo sort the access level some how...
37
- perm_param ={'user'=>{},'group'=>{"public"=>"1"}}
37
+ perm_param ={'user'=>{},'group'=>{"public"=>"read"}}
38
38
  permissions.each{ |perm| perm_param[perm[:type]][perm[:name]] = perm[:access]}
39
39
  @show_file.permissions = HashWithIndifferentAccess.new(perm_param)
40
40
  end
@@ -52,7 +52,7 @@ module Sufia::Controller
52
52
  @batches=[]
53
53
  return if action_name == "index" && controller_name == "mailbox"
54
54
  if user_signed_in?
55
- @notify_number= current_user.mailbox.inbox(:unread => true).count(:id, :distinct => true)
55
+ @notify_number= current_user.mailbox.inbox(:unread => true).count
56
56
  @batches=current_user.mailbox.inbox.map {|msg| msg.last_message.body[/<a class="batchid ui-helper-hidden">(.*)<\/a>The file(.*)/,1]}.select{|val| !val.blank?}
57
57
  end
58
58
  end
@@ -44,8 +44,14 @@ module Sufia
44
44
  end
45
45
 
46
46
  def index
47
- extra_head_content << view_context.auto_discovery_link_tag(:rss, sufia.url_for(params.merge(:format => 'rss')), :title => "RSS for results")
48
- extra_head_content << view_context.auto_discovery_link_tag(:atom, sufia.url_for(params.merge(:format => 'atom')), :title => "Atom for results")
47
+ if params[:controller] == "dashboard"
48
+ extra_head_content << view_context.auto_discovery_link_tag(:rss, sufia.url_for(params.merge(:format => 'rss')), :title => "RSS for results")
49
+ extra_head_content << view_context.auto_discovery_link_tag(:atom, sufia.url_for(params.merge(:format => 'atom')), :title => "Atom for results")
50
+ else
51
+ # This is for controllers that use this behavior that are defined outside Sufia
52
+ extra_head_content << view_context.auto_discovery_link_tag(:rss, url_for(params.merge(:format => 'rss')), :title => "RSS for results")
53
+ extra_head_content << view_context.auto_discovery_link_tag(:atom, url_for(params.merge(:format => 'atom')), :title => "Atom for results")
54
+ end
49
55
  (@response, @document_list) = get_search_results
50
56
  @user = current_user
51
57
  @events = @user.events(100)
@@ -225,8 +225,7 @@ module Sufia
225
225
 
226
226
  # this is provided so that implementing application can override this behavior and map params to different attributes
227
227
  def update_metadata
228
- valid_attributes = params[:generic_file].select { |k,v| (@generic_file.terms_for_editing + [:permissions]).include? k.to_sym}
229
- @generic_file.attributes = valid_attributes
228
+ @generic_file.attributes = @generic_file.sanitize_attributes(params[:generic_file])
230
229
  @generic_file.set_visibility(params[:visibility])
231
230
  @generic_file.date_modified = DateTime.now
232
231
  end
data/lib/sufia/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sufia
2
- VERSION = "2.0.1"
2
+ VERSION = "3.0.0"
3
3
  end
@@ -1,18 +1,4 @@
1
- # Copyright © 2012 The Pennsylvania State University
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
16
2
 
17
3
  describe ActiveFedora::UnsavedDigitalObject do
18
4
  it "should have an ARK-style pid" do
@@ -1,18 +1,4 @@
1
- # Copyright © 2012 The Pennsylvania State University
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
16
2
 
17
3
  describe AuthoritiesController do
18
4
  describe "#query" do
@@ -1,18 +1,4 @@
1
- # Copyright © 2012 The Pennsylvania State University
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
16
2
 
17
3
  describe BatchController do
18
4
  before do
@@ -48,7 +34,7 @@ describe BatchController do
48
34
  end
49
35
  it "should enqueue a batch update job" do
50
36
  params = {'generic_file' => {'read_groups_string' => '', 'read_users_string' => 'archivist1, archivist2', 'tag' => ['']}, 'id' => @batch.pid, 'controller' => 'batch', 'action' => 'update'}
51
- s1 = stub('one')
37
+ s1 = double('one')
52
38
  BatchUpdateJob.should_receive(:new).with(@user.user_key, params).and_return(s1)
53
39
  Sufia.queue.should_receive(:push).with(s1).once
54
40
  post :update, :id=>@batch.pid, "generic_file"=>{"read_groups_string"=>"", "read_users_string"=>"archivist1, archivist2", "tag"=>[""]}
@@ -63,7 +49,15 @@ describe BatchController do
63
49
  flash[:notice].should include("Your files are being processed")
64
50
  end
65
51
  end
52
+
66
53
  describe "when user has edit permissions on a file" do
54
+ it "should set the groups" do
55
+ post :update, :id=>@batch.pid, "generic_file"=>{"permissions"=>{"group"=>{"public"=>"1", "registered"=>"2"}}}
56
+ @file.reload.read_groups.should == []
57
+ @file.reload.edit_groups.should == []
58
+ response.should redirect_to @routes.url_helpers.dashboard_index_path
59
+ end
60
+
67
61
  it "should set the users with read access" do
68
62
  post :update, :id=>@batch.pid, "generic_file"=>{"read_groups_string"=>"", "read_users_string"=>"archivist1, archivist2", "tag"=>[""]}
69
63
  file = GenericFile.find(@file.pid)