refinerycms-inquiries 2.1.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +5 -6
- data/Gemfile +14 -18
- data/Rakefile +0 -1
- data/app/assets/stylesheets/refinery/inquiries/inquiries.css.scss +3 -0
- data/app/controllers/refinery/inquiries/admin/inquiries_controller.rb +9 -3
- data/app/controllers/refinery/inquiries/admin/settings_controller.rb +34 -16
- data/app/controllers/refinery/inquiries/inquiries_controller.rb +29 -13
- data/app/mailers/refinery/inquiries/inquiry_mailer.rb +20 -10
- data/app/models/refinery/inquiries/inquiry.rb +13 -11
- data/app/models/refinery/inquiries/setting.rb +33 -31
- data/app/views/refinery/inquiries/admin/inquiries/_submenu.html.erb +7 -7
- data/app/views/refinery/inquiries/admin/settings/_confirmation_email_form.html.erb +2 -2
- data/app/views/refinery/inquiries/inquiries/_form.html.erb +35 -0
- data/app/views/refinery/inquiries/inquiries/new.html.erb +4 -38
- data/bin/rails +5 -0
- data/bin/rake +21 -0
- data/bin/rspec +22 -0
- data/bin/spring +18 -0
- data/config/locales/bg.yml +2 -2
- data/config/locales/cs.yml +2 -2
- data/config/locales/da.yml +2 -2
- data/config/locales/de.yml +2 -2
- data/config/locales/en-GB.yml +2 -2
- data/config/locales/en.yml +2 -2
- data/config/locales/es.yml +2 -2
- data/config/locales/fr.yml +2 -2
- data/config/locales/it.yml +1 -1
- data/config/locales/lt.yml +2 -2
- data/config/locales/lv.yml +2 -2
- data/config/locales/nb.yml +2 -2
- data/config/locales/nl.yml +2 -2
- data/config/locales/pl.yml +2 -2
- data/config/locales/pt-BR.yml +2 -2
- data/config/locales/ru.yml +2 -2
- data/config/locales/sk.yml +2 -2
- data/config/locales/sl.yml +2 -2
- data/config/locales/sv.yml +2 -2
- data/config/locales/zh-CN.yml +2 -2
- data/config/locales/zh-TW.yml +79 -0
- data/config/routes.rb +11 -7
- data/db/migrate/20101208082840_create_inquiries.rb +4 -3
- data/db/seeds.rb +9 -11
- data/lib/generators/refinery/inquiries/templates/config/initializers/refinery/inquiries.rb.erb +8 -0
- data/lib/refinery/inquiries/configuration.rb +6 -0
- data/lib/refinery/inquiries/engine.rb +3 -7
- data/readme.md +23 -10
- data/refinerycms-inquiries.gemspec +4 -3
- data/spec/factories/inquiry.rb +4 -2
- data/spec/features/refinery/inquiries/admin/inquiries_spec.rb +32 -43
- data/spec/features/refinery/inquiries/inquiries_spec.rb +37 -32
- data/spec/features/refinery/inquiries/mailer_spec.rb +15 -14
- data/spec/models/refinery/inquiries/inquiry_spec.rb +62 -20
- data/spec/models/refinery/inquiries/setting_spec.rb +19 -0
- data/spec/spec_helper.rb +3 -3
- metadata +39 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f72e5741f8019cc82253bc2479aa1e87ea3ebc96
|
4
|
+
data.tar.gz: 7062094890592ac5fa41531e7848f3d978610d75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddcd85adb7c887f5be98bf117abaf28fe2e2ac1839efadb52dbb2093bf8fa6bbbf9cc033d09360c164be25f139a3fa2637fe5a7b4af1e63c01fa43e4c6e139da
|
7
|
+
data.tar.gz: c4412b554ae3000ad8f5f4832471b46750fd38ee9f3fc7d01df64f8164e3ed24f553981499714b9c5e0879255f839c4c1ed233d8250229fb088315556f2ea705
|
data/.travis.yml
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
language: ruby
|
2
|
+
sudo: false
|
3
|
+
cache: bundler
|
2
4
|
bundler_args: --without development
|
3
5
|
before_script:
|
4
6
|
- "sh -e /etc/init.d/xvfb start"
|
@@ -17,14 +19,11 @@ notifications:
|
|
17
19
|
on_failure: always
|
18
20
|
rooms:
|
19
21
|
- secure: "JaX+Ckvdd2wqL2bD6t8PHvMDBHxWBlCrkBKPcDKxV0t0DOwzzzwxMryVqcRi\nPsmM/zvmWFATDyRmivhNOpu4lRg9RytSroxZ9nkmbLDqjCyEAZ6tv4yZXME/\nPaxPwmfwgS9g8TKjj3lSWS7rEpqqg0D5S0XIfIHrj6KB6LUmFHc="
|
22
|
+
webhooks:
|
23
|
+
- https://webhooks.gitter.im/e/b5d48907cdc89864b874
|
20
24
|
env:
|
21
25
|
- DB=postgresql
|
22
26
|
- DB=mysql
|
23
|
-
matrix:
|
24
|
-
allow_failures:
|
25
|
-
- rvm: rbx-19mode
|
26
27
|
rvm:
|
28
|
+
- 2.1
|
27
29
|
- 2.0.0
|
28
|
-
- 1.9.3
|
29
|
-
- rbx-19mode
|
30
|
-
- jruby-19mode
|
data/Gemfile
CHANGED
@@ -2,39 +2,35 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
gem 'refinerycms',
|
6
|
-
gem 'refinerycms-
|
5
|
+
gem 'refinerycms', github: 'refinery/refinerycms'
|
6
|
+
gem 'refinerycms-settings', github: 'refinery/refinerycms-settings'
|
7
7
|
|
8
8
|
group :test do
|
9
|
-
gem 'refinerycms-testing',
|
10
|
-
gem 'capybara-email', '~> 2.
|
9
|
+
gem 'refinerycms-testing', github: 'refinery/refinerycms'
|
10
|
+
gem 'capybara-email', '~> 2.4.0'
|
11
|
+
gem 'poltergeist'
|
11
12
|
end
|
12
13
|
|
13
14
|
# Database Configuration
|
14
15
|
unless ENV['TRAVIS']
|
15
|
-
gem 'activerecord-jdbcsqlite3-adapter', :
|
16
|
-
gem 'sqlite3', :
|
16
|
+
gem 'activerecord-jdbcsqlite3-adapter', platform: :jruby
|
17
|
+
gem 'sqlite3', platform: :ruby
|
17
18
|
end
|
18
19
|
|
19
20
|
if !ENV['TRAVIS'] || ENV['DB'] == 'mysql'
|
20
|
-
gem 'activerecord-jdbcmysql-adapter', :
|
21
|
-
gem 'jdbc-mysql', '= 5.1.13', :
|
22
|
-
gem 'mysql2', :
|
21
|
+
gem 'activerecord-jdbcmysql-adapter', platform: :jruby
|
22
|
+
gem 'jdbc-mysql', '= 5.1.13', platform: :jruby
|
23
|
+
gem 'mysql2', platform: :ruby
|
23
24
|
end
|
24
25
|
|
25
26
|
if !ENV['TRAVIS'] || ENV['DB'] == 'postgresql'
|
26
|
-
gem 'activerecord-jdbcpostgresql-adapter', :
|
27
|
-
gem 'pg', :
|
27
|
+
gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
|
28
|
+
gem 'pg', platform: :ruby
|
28
29
|
end
|
29
30
|
|
30
|
-
gem 'jruby-openssl', :platform => :jruby
|
31
|
-
|
32
31
|
# Refinery/rails should pull in the proper versions of these
|
33
|
-
|
34
|
-
|
35
|
-
gem 'coffee-rails'
|
36
|
-
gem 'uglifier'
|
37
|
-
end
|
32
|
+
gem 'sass-rails', '~> 4.0.0'
|
33
|
+
gem 'coffee-rails', '~> 4.0.0'
|
38
34
|
|
39
35
|
# Load local gems according to Refinery developer preference.
|
40
36
|
if File.exist? local_gemfile = File.expand_path('../.gemfile', __FILE__)
|
data/Rakefile
CHANGED
@@ -9,9 +9,9 @@ module Refinery
|
|
9
9
|
|
10
10
|
helper_method :group_by_date
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
before_action :find_all_ham, :only => [:index]
|
13
|
+
before_action :find_all_spam, :only => [:spam]
|
14
|
+
before_action :get_spam_count, :only => [:index, :spam]
|
15
15
|
|
16
16
|
def index
|
17
17
|
@inquiries = @inquiries.with_query(params[:search]) if searching?
|
@@ -44,6 +44,12 @@ module Refinery
|
|
44
44
|
@spam_count = Refinery::Inquiries::Inquiry.where(:spam => true).count
|
45
45
|
end
|
46
46
|
|
47
|
+
private
|
48
|
+
|
49
|
+
def inquiry_params
|
50
|
+
params.require(:inquiry).permit(:name, :phone, :message, :email)
|
51
|
+
end
|
52
|
+
|
47
53
|
end
|
48
54
|
end
|
49
55
|
end
|
@@ -3,41 +3,59 @@ module Refinery
|
|
3
3
|
module Admin
|
4
4
|
class SettingsController < Refinery::AdminController
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
before_action :find_setting, :only => [:edit, :update]
|
7
|
+
after_action :save_subject_for_confirmation,
|
8
|
+
:save_message_for_confirmation, :save_notification_recipients, :only => :update
|
8
9
|
|
9
10
|
def edit
|
10
|
-
@setting = Refinery::Setting.find(params[:id])
|
11
11
|
end
|
12
12
|
|
13
13
|
def update
|
14
|
-
|
14
|
+
flash[:notice] = t('refinery.crudify.updated', :what => @setting.name.gsub("inquiry_", "").titleize)
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
redirect_back_or_default(refinery.inquiries_admin_inquiries_path)
|
21
|
-
else
|
22
|
-
render :text => "<script type='text/javascript'>parent.window.location = '#{refinery.inquiries_admin_inquiries_path}';</script>"
|
23
|
-
end
|
16
|
+
unless request.xhr? or from_dialog?
|
17
|
+
redirect_back_or_default(refinery.inquiries_admin_inquiries_path)
|
18
|
+
else
|
19
|
+
render text: "<script type='text/javascript'>parent.window.location = '#{refinery.inquiries_admin_inquiries_path}';</script>"
|
24
20
|
end
|
25
21
|
end
|
26
22
|
|
27
23
|
protected
|
28
24
|
|
29
|
-
def
|
25
|
+
def find_setting
|
30
26
|
setting = params[:id].gsub("inquiry_", "")
|
31
27
|
|
32
|
-
|
28
|
+
if Refinery::Inquiries::Setting.respond_to?(setting)
|
29
|
+
Refinery::Inquiries::Setting.send(setting)
|
30
|
+
end
|
31
|
+
|
32
|
+
@setting = Refinery::Setting.friendly.find(params[:id])
|
33
|
+
end
|
34
|
+
|
35
|
+
def save_notification_recipients
|
36
|
+
if setting_params.include?('value')
|
37
|
+
Refinery::Inquiries::Setting.notification_recipients = setting_params[:value]
|
38
|
+
end
|
33
39
|
end
|
34
40
|
|
35
41
|
def save_subject_for_confirmation
|
36
|
-
|
42
|
+
if setting_params.include?('subject')
|
43
|
+
Refinery::Inquiries::Setting.confirmation_subject = setting_params[:subject]
|
44
|
+
end
|
37
45
|
end
|
38
46
|
|
39
47
|
def save_message_for_confirmation
|
40
|
-
|
48
|
+
if setting_params.include?('message')
|
49
|
+
Refinery::Inquiries::Setting.confirmation_message = setting_params[:message]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def setting_params
|
56
|
+
params.require(:setting).permit(:value,
|
57
|
+
subject: Refinery::I18n.frontend_locales,
|
58
|
+
message: Refinery::I18n.frontend_locales)
|
41
59
|
end
|
42
60
|
|
43
61
|
end
|
@@ -2,44 +2,60 @@ module Refinery
|
|
2
2
|
module Inquiries
|
3
3
|
class InquiriesController < ::ApplicationController
|
4
4
|
|
5
|
-
|
5
|
+
before_action :find_page, only: [:create, :new]
|
6
|
+
before_action :find_thank_you_page, only: :thank_you
|
6
7
|
|
7
8
|
def thank_you
|
8
|
-
@page = ::Refinery::Page.find_by_link_url("/contact/thank_you")
|
9
9
|
end
|
10
10
|
|
11
11
|
def new
|
12
|
-
@inquiry =
|
12
|
+
@inquiry = Inquiry.new
|
13
13
|
end
|
14
14
|
|
15
15
|
def create
|
16
|
-
@inquiry =
|
16
|
+
@inquiry = Inquiry.new(inquiry_params)
|
17
17
|
|
18
18
|
if @inquiry.save
|
19
|
-
if @inquiry.ham? ||
|
19
|
+
if @inquiry.ham? || Inquiries.send_notifications_for_inquiries_marked_as_spam
|
20
20
|
begin
|
21
|
-
|
21
|
+
InquiryMailer.notification(@inquiry, request).deliver_now
|
22
22
|
rescue
|
23
23
|
logger.warn "There was an error delivering an inquiry notification.\n#{$!}\n"
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
if Setting.send_confirmation?
|
27
|
+
begin
|
28
|
+
InquiryMailer.confirmation(@inquiry, request).deliver_now
|
29
|
+
rescue
|
30
|
+
logger.warn "There was an error delivering an inquiry confirmation:\n#{$!}\n"
|
31
|
+
end
|
32
|
+
end
|
31
33
|
end
|
32
34
|
|
33
35
|
redirect_to refinery.thank_you_inquiries_inquiries_path
|
34
36
|
else
|
35
|
-
render :
|
37
|
+
render action: 'new'
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
39
41
|
protected
|
40
42
|
|
41
43
|
def find_page
|
42
|
-
@page =
|
44
|
+
@page = Page.find_by(link_url: Refinery::Inquiries.page_path_new)
|
45
|
+
end
|
46
|
+
|
47
|
+
def find_thank_you_page
|
48
|
+
@page = Page.find_by(link_url: Refinery::Inquiries.page_path_thank_you)
|
49
|
+
end
|
50
|
+
|
51
|
+
def inquiry_params
|
52
|
+
params.require(:inquiry).permit(permitted_inquiry_params)
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def permitted_inquiry_params
|
58
|
+
[:name, :phone, :message, :email]
|
43
59
|
end
|
44
60
|
|
45
61
|
end
|
@@ -3,27 +3,37 @@ module Refinery
|
|
3
3
|
class InquiryMailer < ActionMailer::Base
|
4
4
|
|
5
5
|
def confirmation(inquiry, request)
|
6
|
-
@inquiry = inquiry
|
6
|
+
@inquiry, @request = inquiry, request
|
7
7
|
mail :subject => Refinery::Inquiries::Setting.confirmation_subject(Globalize.locale),
|
8
8
|
:to => inquiry.email,
|
9
|
-
:from =>
|
10
|
-
:scope => 'refinery.inquiries.config',
|
11
|
-
:site_name => Refinery::Core.site_name,
|
12
|
-
:name => @inquiry.name) + " <#{Refinery::Inquiries.from_name}@#{request.domain}>",
|
9
|
+
:from => from_info,
|
13
10
|
:reply_to => Refinery::Inquiries::Setting.notification_recipients.split(',').first
|
14
11
|
end
|
15
12
|
|
16
13
|
def notification(inquiry, request)
|
17
|
-
@inquiry = inquiry
|
14
|
+
@inquiry, @request = inquiry, request
|
18
15
|
mail :subject => Refinery::Inquiries::Setting.notification_subject,
|
19
16
|
:to => Refinery::Inquiries::Setting.notification_recipients,
|
20
|
-
:from =>
|
21
|
-
:scope => 'refinery.inquiries.config',
|
22
|
-
:site_name => Refinery::Core.site_name,
|
23
|
-
:name => @inquiry.name) + " <#{Refinery::Inquiries.from_name}@#{request.domain}>",
|
17
|
+
:from => from_info,
|
24
18
|
:reply_to => inquiry.email
|
25
19
|
end
|
26
20
|
|
21
|
+
private
|
22
|
+
|
23
|
+
def from_info
|
24
|
+
"\"#{from_name}\" <#{from_mail}>"
|
25
|
+
end
|
26
|
+
|
27
|
+
def from_name
|
28
|
+
::I18n.t('from_name',
|
29
|
+
:scope => 'refinery.inquiries.config',
|
30
|
+
:site_name => Refinery::Core.site_name,
|
31
|
+
:name => @inquiry.name)
|
32
|
+
end
|
33
|
+
|
34
|
+
def from_mail
|
35
|
+
"#{Refinery::Inquiries.from_name}@#{@request.domain}"
|
36
|
+
end
|
27
37
|
end
|
28
38
|
end
|
29
39
|
end
|
@@ -5,19 +5,21 @@ module Refinery
|
|
5
5
|
module Inquiries
|
6
6
|
class Inquiry < Refinery::Core::BaseModel
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
validates :email, :format => { :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i }
|
16
|
-
validates :message, :presence => true
|
8
|
+
if Inquiries.config.filter_spam
|
9
|
+
filters_spam message_field: :message,
|
10
|
+
email_field: :email,
|
11
|
+
author_field: :name,
|
12
|
+
other_fields: [:phone],
|
13
|
+
extra_spam_words: %w()
|
14
|
+
end
|
17
15
|
|
18
|
-
|
16
|
+
validates :name, presence: true, length: { maximum: 255 }
|
17
|
+
validates :email, format: {
|
18
|
+
with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
|
19
|
+
}, length: { maximum: 255 }
|
20
|
+
validates :message, presence: true
|
19
21
|
|
20
|
-
|
22
|
+
default_scope { order('created_at DESC') }
|
21
23
|
|
22
24
|
def self.latest(number = 7, include_spam = false)
|
23
25
|
include_spam ? limit(number) : ham.limit(number)
|
@@ -1,61 +1,63 @@
|
|
1
|
+
require 'refinery/setting'
|
2
|
+
|
1
3
|
module Refinery
|
2
4
|
module Inquiries
|
3
|
-
class Setting
|
5
|
+
class Setting < ::Refinery::Setting
|
4
6
|
|
5
7
|
class << self
|
6
8
|
def confirmation_body
|
7
|
-
|
9
|
+
find_or_set(:inquiry_confirmation_body,
|
8
10
|
"Thank you for your inquiry %name%,\n\nThis email is a receipt to confirm we have received your inquiry and we'll be in touch shortly.\n\nThanks."
|
9
11
|
)
|
10
12
|
end
|
11
13
|
|
12
14
|
def confirmation_subject(locale='en')
|
13
|
-
|
14
|
-
|
15
|
-
|
15
|
+
find_or_set(:"inquiry_confirmation_subject_#{locale}",
|
16
|
+
"Thank you for your inquiry",
|
17
|
+
scoping: "inquiries"
|
18
|
+
)
|
16
19
|
end
|
17
20
|
|
18
|
-
def confirmation_subject=(
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
def confirmation_subject=(locales_subjects)
|
22
|
+
locales_subjects.each do |locale, subject|
|
23
|
+
set(:"inquiry_confirmation_subject_#{locale}", {
|
24
|
+
value: subject,
|
25
|
+
scoping: "inquiries"
|
26
|
+
})
|
24
27
|
end
|
25
28
|
end
|
26
29
|
|
27
30
|
def confirmation_message(locale='en')
|
28
|
-
|
29
|
-
Refinery::Setting[:inquiry_confirmation_body],
|
30
|
-
:scoping => "inquiries")
|
31
|
+
find_or_set(:"inquiry_confirmation_message_#{locale}", confirmation_body, scoping: "inquiries")
|
31
32
|
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
})
|
34
|
+
def confirmation_message=(locales_messages)
|
35
|
+
locales_messages.each do |locale, message|
|
36
|
+
set(:"inquiry_confirmation_message_#{locale}", {
|
37
|
+
value: message,
|
38
|
+
scoping: "inquiries"
|
39
|
+
})
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
def notification_recipients
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
recipients = ((Role[:refinery].users.first.email rescue nil) if defined?(Role)).to_s
|
45
|
+
find_or_set(:inquiry_notification_recipients, recipients, scoping: "inquiries")
|
46
|
+
end
|
47
|
+
|
48
|
+
def notification_recipients=(recipients)
|
49
|
+
set(:inquiry_notification_recipients, {
|
50
|
+
value: recipients,
|
51
|
+
scoping: "inquiries"
|
52
|
+
})
|
47
53
|
end
|
48
54
|
|
49
55
|
def notification_subject
|
50
|
-
|
51
|
-
"New inquiry from your website",
|
52
|
-
:scoping => "inquiries")
|
56
|
+
find_or_set(:inquiry_notification_subject, "New inquiry from your website", scoping: "inquiries")
|
53
57
|
end
|
54
|
-
|
58
|
+
|
55
59
|
def send_confirmation?
|
56
|
-
|
57
|
-
true,
|
58
|
-
:scoping => "inquiries")
|
60
|
+
find_or_set(:inquiry_send_confirmation, true, scoping: "inquiries")
|
59
61
|
end
|
60
62
|
end
|
61
63
|
end
|