Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions app/models/concerns/downloadable_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ module DownloadableFile
extend ActiveSupport::Concern

included do
has_attached_file :file, Settings.paperclip.to_hash.merge(validate_media_type: false)
has_attached_file :file, PaperclipSettings.config.merge(validate_media_type: false)

# TODO: Limit attachment types for safe uploads
do_not_validate_attachment_file_type :file
end

def download_url
if fog?
if PaperclipSettings.fog?
# This is a workaround due to a bug or limitation in fog to generate a
# private, expiring URL and have it force a download.
#
Expand All @@ -31,10 +31,4 @@ def download_url
end
end

private

def fog?
Settings.paperclip.storage == "fog"
end

end
13 changes: 13 additions & 0 deletions config/initializers/paperclip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,16 @@
Paperclip.options[:content_type_mappings] = {
xls: "CDF V2 Document, No summary info",
}

class PaperclipSettings

def self.config
secrets = Hash(Rails.application.secrets.paperclip).symbolize_keys
Settings.paperclip.to_hash.merge(secrets)
end

def self.fog?
config[:storage] == "fog"
end

end
22 changes: 22 additions & 0 deletions config/secrets.yml.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
development:
secret_key_base: ~

# You should change this if you want to be able to access the API
api:
basic_auth_name: <%= SecureRandom.hex %>
basic_auth_password: <%= SecureRandom.hex %>

# You should change this if you want to be able to access the SecureRooms API
secure_rooms_api:
basic_auth_name: <%= SecureRandom.hex %>
basic_auth_password: <%= SecureRandom.hex %>

# Uncomment these lines if you wish to use S3 in your application.
# paperclip:
# storage: fog
# fog_credentials:
# provider: AWS
# aws_access_key_id: Your-Key-Here
# aws_secret_access_key: Your-Key-Here
# fog_directory: Your-Bucket-Name-Here
# fog_public: false
# path: ":class/:attachment/:id_partition/:style/:safe_filename"


test:
secret_key_base: needs_a_value_for_ci

Expand Down
12 changes: 0 additions & 12 deletions config/settings.local.yml.template

This file was deleted.

12 changes: 1 addition & 11 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,6 @@ relays:
admin_enabled: true
reservation_enabled: true

# You should change this if you want to be able to access the API
api:
basic_auth_name: <%= SecureRandom.hex %>
basic_auth_password: <%= SecureRandom.hex %>

# You should change this if you want to be able to access the SecureRooms API
secure_rooms_api:
basic_auth_name: <%= SecureRandom.hex %>
basic_auth_password: <%= SecureRandom.hex %>

#
# For these settings use SettingsHelper#feature_on?
feature:
Expand Down Expand Up @@ -135,7 +125,7 @@ split_accounts:
- administrator
# - account_manager

# This may be overridden in settings.local.yml if your fork is using S3, so
# This may be overridden in secrets.yml if your fork is using S3, so
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part isn't quite true as it stands. I think it might be nice to think about how this can work.

What might work is to do a Settings.paperclip.merge(Rails.application.secrets.paperclip) and then we can get the best of both worlds. Thoughts on that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Where would we actually do the merge?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we use the paperclip settings in app/models/concerns/downloadable_file.rb. So probably in there.

# be sure to check there for configuration
paperclip:
storage: filesystem
Expand Down