sufia 3.6.0 → 3.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 600ffd64ac5050922d558df0919adff82b5c86e9
4
- data.tar.gz: 1c3206cbd65b85dfdbc75c37a0fd539aa577518e
3
+ metadata.gz: b53a899aa9c270ada0aab595ca8da81fc10d7325
4
+ data.tar.gz: 2acd0577db3a932cc963588569d7bde1e96a8bb5
5
5
  SHA512:
6
- metadata.gz: f5b565ade76f51e2b2a89d291c0bea3413c90c4e7a3769fdf5d87baa16d727aa7bc3bd76719cb8722975402540187c703ec7df09adbc1d8f8c30a0eec84b25b6
7
- data.tar.gz: 40a89c2d24aa9a953991eeb6d7453ab3de9e4e935445a122680f791172c45aa85971c6ec977f84dfe010bf0817cf51668bdd264174f15e529847b14b4272baa4
6
+ metadata.gz: a85c16093df9b3a1baded8276f9bdd8f38f93c45c448c36658cba440fc4d5527c0b7fa031a0a8f78d01c89cd73deb2930df1be6eaa36721b949233f3c8339be0
7
+ data.tar.gz: 81ef3a1faa2ceba2551cf4039ae9fffc8a87e78b853fc8eeb250ffac73579f15d75edf6f62b829b08a936ee9bc3403d4f63108c72edd16d9c4f058330e490c90
data/SUFIA_VERSION CHANGED
@@ -1 +1 @@
1
- 3.6.0
1
+ 3.6.1
@@ -9,10 +9,9 @@ $("a[rel=popover]").popover({ html: true });
9
9
  <div class="control-group">
10
10
  <%= f.label :avatar, '<i class="icon-camera-retro"></i> Change picture'.html_safe, :class => "control-label" %>
11
11
  <div class="controls">
12
- <% if @user.avatar? %>
13
- <%= image_tag @user.avatar.url(:thumb) %>
14
- <% end %>
12
+ <%= image_tag @user.avatar.url(:thumb) if @user.avatar? %>
15
13
  <%= f.file_field :avatar %>
14
+ <%= f.hidden_field :avatar_cache %>
16
15
  <span class="label label-important">JPG, GIF, or PNG (less than 2MB)</span>
17
16
  </div>
18
17
  </div>
@@ -21,7 +20,7 @@ $("a[rel=popover]").popover({ html: true });
21
20
  <%= f.label :delete_avatar, '<i class="icon-remove"></i> Delete picture'.html_safe, :class => 'control-label' %>
22
21
  <div class="controls">
23
22
  <label class="checkbox">
24
- <%= check_box_tag 'delete_avatar' %> Yes
23
+ <%= f.check_box :remove_avatar %> Yes
25
24
  <a href="#" id="delete_picture_help" rel="popover" data-content="If you would like to remove your picture entirely, check the box and save your profile." data-original-title="Delete Picture"><i class="icon-question-sign icon-large"></i></a>
26
25
  </label>
27
26
  </div>
@@ -60,7 +59,6 @@ $("a[rel=popover]").popover({ html: true });
60
59
 
61
60
  <%= render :partial => 'trophy_edit', :locals => {:trophies => @trophies} %>
62
61
 
63
-
64
62
  <div class="form-actions">
65
63
  <%= f.button '<i class="icon-save"></i> Save Profile'.html_safe, :type => 'submit', :class => "btn-primary btn-large" %>
66
64
  </div>
@@ -78,4 +76,3 @@ $("a[rel=popover]").popover({ html: true });
78
76
  <i class="icon-caret-right"></i> <%= g %><br />
79
77
  <% end %>
80
78
  </div>
81
-
data/lib/sufia/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sufia
2
- VERSION = "3.6.0"
2
+ VERSION = "3.6.1"
3
3
  end
@@ -69,7 +69,7 @@ describe UsersController do
69
69
  flash[:alert].should include("Permission denied: cannot access this page.")
70
70
  end
71
71
  it "should set an avatar and redirect to profile" do
72
- @user.avatar.file?.should be_false
72
+ @user.avatar?.should be_false
73
73
  s1 = double('one')
74
74
  UserEditProfileEventJob.should_receive(:new).with(@user.user_key).and_return(s1)
75
75
  Sufia.queue.should_receive(:push).with(s1).once
@@ -77,23 +77,21 @@ describe UsersController do
77
77
  post :update, id: @user.user_key, user: { avatar: f }
78
78
  response.should redirect_to(@routes.url_helpers.profile_path(URI.escape(@user.user_key,'@.')))
79
79
  flash[:notice].should include("Your profile has been updated")
80
- User.find_by_user_key(@user.user_key).avatar.file?.should be_true
80
+ User.find_by_user_key(@user.user_key).avatar?.should be_true
81
81
  end
82
82
  it "should validate the content type of an avatar" do
83
- #Resque.should_receive(:enqueue).with(UserEditProfileEventJob, @user.user_key).never
84
83
  Sufia.queue.should_receive(:push).never
85
84
  f = fixture_file_upload('/image.jp2', 'image/jp2')
86
85
  post :update, id: @user.user_key, user: { avatar: f }
87
86
  response.should redirect_to(@routes.url_helpers.edit_profile_path(URI.escape(@user.user_key,'@.')))
88
- flash[:alert].should include("Avatar content type is invalid")
87
+ flash[:alert].should include("Avatar You are not allowed to upload \"jp2\" files, allowed types: jpg, jpeg, png, gif, bmp, tif, tiff")
89
88
  end
90
89
  it "should validate the size of an avatar" do
91
90
  f = fixture_file_upload('/4-20.png', 'image/png')
92
- #Resque.should_receive(:enqueue).with(UserEditProfileEventJob, @user.user_key).never
93
91
  Sufia.queue.should_receive(:push).never
94
92
  post :update, id: @user.user_key, user: { avatar: f }
95
93
  response.should redirect_to(@routes.url_helpers.edit_profile_path(URI.escape(@user.user_key,'@.')))
96
- flash[:alert].should include("Avatar file size must be less than 2097152 Bytes")
94
+ flash[:alert].should include("Avatar file size must be less than 2MB")
97
95
  end
98
96
  it "should delete an avatar" do
99
97
  s1 = double('one')
@@ -102,7 +100,7 @@ describe UsersController do
102
100
  post :update, id: @user.user_key, delete_avatar: true
103
101
  response.should redirect_to(@routes.url_helpers.profile_path(URI.escape(@user.user_key,'@.')))
104
102
  flash[:notice].should include("Your profile has been updated")
105
- @user.avatar.file?.should be_false
103
+ @user.avatar?.should be_false
106
104
  end
107
105
  it "should refresh directory attributes" do
108
106
  s1 = double('one')
@@ -132,11 +130,11 @@ describe UsersController do
132
130
  file_id = f.pid.split(":").last
133
131
  Trophy.create(:generic_file_id => file_id, :user_id => @user.id)
134
132
  @user.trophy_ids.length.should == 1
135
- post :update, id: @user.user_key, 'remove_trophy_'+file_id=> 'yes'
133
+ post :update, id: @user.user_key, 'remove_trophy_'+file_id=> 'yes'
136
134
  response.should redirect_to(@routes.url_helpers.profile_path(URI.escape(@user.user_key,'@.')))
137
135
  flash[:notice].should include("Your profile has been updated")
138
136
  @user.trophy_ids.length.should == 0
139
- f.destroy
137
+ f.destroy
140
138
  end
141
139
  end
142
140
  describe "#follow" do
@@ -21,14 +21,11 @@ module Sufia::User
21
21
  # Setup accessible (or protected) attributes for your model
22
22
  deprecated_attr_accessible *permitted_attributes
23
23
 
24
- # Add user avatar (via paperclip library)
25
- has_attached_file :avatar, :styles => { medium: "300x300>", thumb: "100x100>" }, :default_url => '/assets/missing_:style.png'
26
- validates :avatar, :attachment_content_type => { :content_type => /^image\/(jpg|jpeg|pjpeg|png|x-png|gif)$/ }, :if => Proc.new { |p| p.avatar.file? }
27
- validates :avatar, :attachment_size => { :less_than => 2.megabytes }, :if => Proc.new { |p| p.avatar.file? }
28
-
24
+ mount_uploader :avatar, AvatarUploader, :mount_on => :avatar_file_name
25
+ validates_with AvatarValidator
29
26
  end
30
27
 
31
- # Format the json for select2 which requires just an id and a field called text.
28
+ # Format the json for select2 which requires just an id and a field called text.
32
29
  # If we need an alternate format we should probably look at a json template gem
33
30
  def as_json(opts = nil)
34
31
  {id: user_key, text: display_name ? "#{display_name} (#{user_key})" : user_key}
@@ -76,8 +73,8 @@ module Sufia::User
76
73
  module ClassMethods
77
74
 
78
75
  def permitted_attributes
79
- [:email, :login, :display_name, :address, :admin_area,
80
- :department, :title, :office, :chat_id, :website, :affiliation,
76
+ [:email, :login, :display_name, :address, :admin_area,
77
+ :department, :title, :office, :chat_id, :website, :affiliation,
81
78
  :telephone, :avatar, :group_list, :groups_last_update, :facebook_handle,
82
79
  :twitter_handle, :googleplus_handle]
83
80
  end
@@ -0,0 +1,22 @@
1
+ class Sufia::AvatarUploader < CarrierWave::Uploader::Base
2
+ include CarrierWave::MiniMagick
3
+ include CarrierWave::Compatibility::Paperclip
4
+
5
+ process convert: 'png'
6
+
7
+ version :medium do
8
+ process resize_to_limit: [300, 300]
9
+ end
10
+
11
+ version :thumb do
12
+ process resize_to_limit: [100, 100]
13
+ end
14
+
15
+ def default_url
16
+ "/assets/missing_#{version_name}.png"
17
+ end
18
+
19
+ def extension_white_list
20
+ %w(jpg jpeg png gif bmp tif tiff)
21
+ end
22
+ end
@@ -0,0 +1,8 @@
1
+ module Sufia
2
+ class AvatarValidator < ActiveModel::Validator
3
+ def validate(record)
4
+ return unless record.avatar?
5
+ record.errors.add(:avatar_file_size, 'must be less than 2MB') if record.avatar.size > 2.megabytes.to_i
6
+ end
7
+ end
8
+ end
@@ -1,9 +1,15 @@
1
1
  class AddAvatarsToUsers < ActiveRecord::Migration
2
2
  def self.up
3
- add_attachment :users, :avatar
3
+ add_column :users, "avatar_file_name", :string
4
+ add_column :users, "avatar_content_type", :string
5
+ add_column :users, "avatar_file_size", :integer
6
+ add_column :users, "avatar_updated_at", :datetime
4
7
  end
5
8
 
6
9
  def self.down
7
- remove_attachment :users, :avatar
10
+ remove_column :users, "avatar_file_name"
11
+ remove_column :users, "avatar_content_type"
12
+ remove_column :users, "avatar_file_size"
13
+ remove_column :users, "avatar_updated_at"
8
14
  end
9
15
  end
@@ -4,7 +4,7 @@ require 'hydra/head'
4
4
  require 'nest'
5
5
  require 'mailboxer'
6
6
  require 'acts_as_follower'
7
- require 'paperclip'
7
+ require 'carrierwave'
8
8
  require "active_resource" # used by GenericFile to catch errors & by GeoNamesResource
9
9
  require 'resque/server'
10
10
 
@@ -22,7 +22,7 @@ module Sufia
22
22
  config.fits_path = "fits.sh"
23
23
  config.enable_contact_form_delivery = false
24
24
  config.dropbox_api_key = nil
25
- config.enable_local_ingest = nil
25
+ config.enable_local_ingest = nil
26
26
  config.queue = Sufia::Resque::Queue
27
27
 
28
28
  config.autoload_paths += %W(
@@ -1,5 +1,5 @@
1
1
  module Sufia
2
2
  module Models
3
- VERSION = "3.6.0"
3
+ VERSION = "3.6.1"
4
4
  end
5
5
  end
@@ -29,20 +29,14 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency 'rails', '> 4.0.0', '< 5.0'
30
30
  spec.add_dependency 'activeresource' # No longer a dependency of rails 4.0
31
31
 
32
- # spec.add_dependency "hydra", "6.1.0.rc2"
33
- # Since hydra 6.1 isn't out yet, we'll just build it so that it's compatible
34
- # without an explicit dependency
35
- spec.add_dependency "active-fedora", "~> 6.7.0"
36
- spec.add_dependency "blacklight", "~> 4.5.0"
37
- spec.add_dependency "hydra-head", "~> 6.4.0"
38
-
32
+ spec.add_dependency "hydra", "6.1.0"
39
33
  spec.add_dependency 'nest', '~> 1.1.1'
40
34
  spec.add_dependency 'resque', '~> 1.23'
41
35
  spec.add_dependency 'resque-pool', '0.3.0'
42
36
  spec.add_dependency 'noid', '~> 0.6.6'
43
37
  spec.add_dependency 'mailboxer', '~> 0.11.0'
44
38
  spec.add_dependency 'acts_as_follower', '>= 0.1.1', '< 0.3'
45
- spec.add_dependency 'paperclip', '~> 3.4.0'
39
+ spec.add_dependency 'carrierwave', '~> 0.9.0'
46
40
  spec.add_dependency 'hydra-derivatives', '~> 0.0.5'
47
41
  spec.add_dependency 'activerecord-import'
48
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sufia
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.0
4
+ version: 3.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.6.0
19
+ version: 3.6.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 3.6.0
26
+ version: 3.6.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: blacklight_advanced_search
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -613,6 +613,8 @@ files:
613
613
  - sufia-models/app/models/local_authority_entry.rb
614
614
  - sufia-models/app/models/single_use_link.rb
615
615
  - sufia-models/app/models/subject_local_authority_entry.rb
616
+ - sufia-models/app/models/sufia/avatar_uploader.rb
617
+ - sufia-models/app/models/sufia/avatar_validator.rb
616
618
  - sufia-models/app/models/trophy.rb
617
619
  - sufia-models/app/models/version_committer.rb
618
620
  - sufia-models/config/locales/sufia.en.yml