Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging in latest bug fixes #1388

Merged
merged 8 commits into from
Apr 17, 2018
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
31 changes: 31 additions & 0 deletions app/controllers/contacts_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class ContactUs::ContactsController < ApplicationController

def create
@contact = ContactUs::Contact.new(params[:contact_us_contact])

if verify_recaptcha(model: @contact) && @contact.save
redirect_to(ContactUs.success_redirect || '/', :notice => _('Contact email was successfully sent.'))
else
flash[:alert] = _('Captcha verification failed, please retry.')
redirect_to request.referrer
#render_new_page
end
end

def new
@contact = ContactUs::Contact.new
render_new_page
end

protected

def render_new_page
case ContactUs.form_gem
when 'formtastic' then render 'new_formtastic'
when 'simple_form' then render 'new_simple_form'
else
render 'new'
end
end

end
11 changes: 7 additions & 4 deletions app/controllers/org_admin/templates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -375,15 +375,18 @@ def template_options()
if org_id.present? || funder_id.present?
unless funder_id.blank?
# Load the funder's template(s)
templates = Template.valid.publicly_visible.where(published: true, org_id: funder_id).to_a
funder_templates = Template.valid.publicly_visible.where(published: true, org_id: funder_id)

unless org_id.blank?
if org_id.blank?
templates = funder_templates.to_a
else
# Swap out any organisational cusotmizations of a funder template
templates.each do |tmplt|
funder_templates.each do |tmplt|
customization = Template.valid.find_by(published: true, org_id: org_id, customization_of: tmplt.dmptemplate_id)
if customization.present? && tmplt.created_at < customization.created_at
templates.delete(tmplt)
templates << customization
else
templates << tmplt
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/org.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ def grant_api!(token_permission_type)
#
def resize_image
unless logo.nil?
if logo.height != 75
self.logo = logo.thumb('x75') # resize height and maintain aspect ratio
if logo.height != 100
self.logo = logo.thumb('x100') # resize height and maintain aspect ratio
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/unit/org_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class OrgTest < ActiveSupport::TestCase
end

# ---------------------------------------------------
test "should resize logo to a height of 75" do
test "should resize logo to a height of 100" do
['logo.jpg', # this one is at 160x160
'logo_300x300.jpg',
'logo_100x100.jpg'].each do |file|
Expand All @@ -75,7 +75,7 @@ class OrgTest < ActiveSupport::TestCase
@org.logo = Dragonfly.app.fetch_file("#{path}")

assert @org.valid?, "expected the logo to have been attached to the org"
assert_equal 75, @org.logo.height, "expected the logo to have been resized properly"
assert_equal 100, @org.logo.height, "expected the logo to have been resized properly"
end
end

Expand Down