Skip to content
Closed
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
6 changes: 5 additions & 1 deletion app/controllers/admin/sponsors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,16 @@ def update
private

def sponsor_params
params.require(:sponsor).permit(:name, :avatar, :website, :seats, :accessibility_info,
params
.require(:sponsor)
.permit(:name, :avatar, :website, :seats, :accessibility_info,
:number_of_coaches, :level, :description,
address_attributes: %i[id flat street postal_code city
latitude longitude directions],
contacts_attributes: %i[id name surname email mailing_list_consent
_destroy])
.with_defaults(avatar: "https://en.m.wikipedia.org/wiki/File:Blank_Square.svg")
Copy link
Member

Choose a reason for hiding this comment

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

Do their ToU allow remote loading like this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point. I think very technically no. We could download and host it somewhere - in which case, are we moving towards #2226 anyway?

Copy link
Member

Choose a reason for hiding this comment

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

I believe that is allowed 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Short term, if someone in the organisation hosts it, we could use that? Or I can stick it in the S3 bucket I made for #2226 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could even host it here on Github, maybe?


end

def set_sponsor
Expand Down
2 changes: 1 addition & 1 deletion app/models/sponsor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Sponsor < ApplicationRecord
accepts_nested_attributes_for :address

validates :level, inclusion: { in: Sponsor.levels.keys }
validates :name, :address, :avatar, :website, :level, presence: true
validates :name, :address, :website, :level, presence: true
validate :website_is_url, if: :website?

default_scope -> { order('updated_at desc') }
Expand Down
12 changes: 6 additions & 6 deletions app/uploaders/avatar_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ def store_dir
end

# Provide a default URL as a default if there hasn't been a file uploaded:
# def default_url
# # For Rails 3.1+ asset pipeline compatibility:
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
#
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
def default_url
# For Rails 3.1+ asset pipeline compatibility:
# ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))

"https://en.m.wikipedia.org/wiki/File:Blank_Square.svg"
end

# Process files as they are uploaded:
# process :scale => [200, 300]
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/sponsors/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
hint: raw(t('admin.shared.markdown_hint', link: link_to(t('admin.shared.markdown'), 'https://commonmark.org/help/')))
- if current_user.has_role?(:admin)
= f.input :level, collection: Sponsor.levels.keys, label_method: :humanize
= f.input :avatar, as: :file, required: [email protected]?
= f.input :avatar, as: :file
- if @sponsor.avatar?
= image_tag(@sponsor.avatar.url, alt: "#{@sponsor.name} logo", class: 'small-image mw-100 mb-4', 'data-test': 'sponsor-logo')
= f.hidden_field :image_cache
Expand Down
Loading