From 9c74f471ad81d14cd5e9abffd3f009ae4969a763 Mon Sep 17 00:00:00 2001 From: briley Date: Mon, 9 Apr 2018 13:48:24 -0700 Subject: [PATCH 1/4] removed delete of array element fixes issue with removing item from array while iterating over it --- app/controllers/org_admin/templates_controller.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/controllers/org_admin/templates_controller.rb b/app/controllers/org_admin/templates_controller.rb index 7440e04c47..0da50442b2 100644 --- a/app/controllers/org_admin/templates_controller.rb +++ b/app/controllers/org_admin/templates_controller.rb @@ -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 From dd94ff815ce8e8e6722847099b1452a3bfdc9af2 Mon Sep 17 00:00:00 2001 From: Jimmy Angelakos Date: Tue, 10 Apr 2018 11:27:47 +0100 Subject: [PATCH 2/4] Resize logo to correct height - fixes #1357 --- app/models/org.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/org.rb b/app/models/org.rb index dee239c492..303cc0d219 100644 --- a/app/models/org.rb +++ b/app/models/org.rb @@ -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 From 9a8e08640121ac30d6e75905517be547536a4900 Mon Sep 17 00:00:00 2001 From: Jimmy Angelakos Date: Tue, 10 Apr 2018 11:33:17 +0100 Subject: [PATCH 3/4] Fix failing test --- test/unit/org_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/org_test.rb b/test/unit/org_test.rb index 40720a34db..0d5e2848f4 100644 --- a/test/unit/org_test.rb +++ b/test/unit/org_test.rb @@ -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| @@ -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 From 9e70b543fb44a4f7b849e6692a4c9e9256e0ba6c Mon Sep 17 00:00:00 2001 From: Jimmy Angelakos Date: Mon, 16 Apr 2018 13:28:51 +0100 Subject: [PATCH 4/4] Enable recaptcha for contact_us form: fixes #501 --- app/controllers/contacts_controller.rb | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 app/controllers/contacts_controller.rb diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb new file mode 100644 index 0000000000..45bf21d2e7 --- /dev/null +++ b/app/controllers/contacts_controller.rb @@ -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