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 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 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 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