Skip to content

Commit 4fc6b72

Browse files
author
Kenn K. Lau
committed
Please view description
Spud Inquiries Updates - Added send_recipt flag to configuration.rb and default to false. - Added new column, :receipt_content, this will be the message the user will receive via email after submission of form - :receipt_content will toggle depending on :send_receipt flag - Added help text for content, thank you text, and receipt content - Added :reply_to field for mail method, it will default to from_address if none is found, this is only applicable to the send_receipt method - Added send_receipt.html.erb and .text.erb view
1 parent 666b154 commit 4fc6b72

File tree

9 files changed

+147
-72
lines changed

9 files changed

+147
-72
lines changed

Diff for: Gemfile.lock

+92-64
Original file line numberDiff line numberDiff line change
@@ -9,94 +9,124 @@ PATH
99
GEM
1010
remote: http://rubygems.org/
1111
specs:
12-
actionmailer (4.0.4)
13-
actionpack (= 4.0.4)
14-
mail (~> 2.5.4)
15-
actionpack (4.0.4)
16-
activesupport (= 4.0.4)
17-
builder (~> 3.1.0)
18-
erubis (~> 2.7.0)
19-
rack (~> 1.5.2)
12+
actionmailer (4.2.0)
13+
actionpack (= 4.2.0)
14+
actionview (= 4.2.0)
15+
activejob (= 4.2.0)
16+
mail (~> 2.5, >= 2.5.4)
17+
rails-dom-testing (~> 1.0, >= 1.0.5)
18+
actionpack (4.2.0)
19+
actionview (= 4.2.0)
20+
activesupport (= 4.2.0)
21+
rack (~> 1.6.0)
2022
rack-test (~> 0.6.2)
23+
rails-dom-testing (~> 1.0, >= 1.0.5)
24+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
2125
actionpack-action_caching (1.1.1)
2226
actionpack (>= 4.0.0, < 5.0)
2327
actionpack-page_caching (1.0.2)
2428
actionpack (>= 4.0.0, < 5)
25-
activemodel (4.0.4)
26-
activesupport (= 4.0.4)
27-
builder (~> 3.1.0)
28-
activerecord (4.0.4)
29-
activemodel (= 4.0.4)
30-
activerecord-deprecated_finders (~> 1.0.2)
31-
activesupport (= 4.0.4)
32-
arel (~> 4.0.0)
33-
activerecord-deprecated_finders (1.0.3)
34-
activesupport (4.0.4)
35-
i18n (~> 0.6, >= 0.6.9)
36-
minitest (~> 4.2)
37-
multi_json (~> 1.3)
38-
thread_safe (~> 0.1)
39-
tzinfo (~> 0.3.37)
40-
arel (4.0.2)
41-
authlogic (3.4.2)
29+
actionview (4.2.0)
30+
activesupport (= 4.2.0)
31+
builder (~> 3.1)
32+
erubis (~> 2.7.0)
33+
rails-dom-testing (~> 1.0, >= 1.0.5)
34+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
35+
activejob (4.2.0)
36+
activesupport (= 4.2.0)
37+
globalid (>= 0.3.0)
38+
activemodel (4.2.0)
39+
activesupport (= 4.2.0)
40+
builder (~> 3.1)
41+
activerecord (4.2.0)
42+
activemodel (= 4.2.0)
43+
activesupport (= 4.2.0)
44+
arel (~> 6.0)
45+
activesupport (4.2.0)
46+
i18n (~> 0.7)
47+
json (~> 1.7, >= 1.7.7)
48+
minitest (~> 5.1)
49+
thread_safe (~> 0.3, >= 0.3.4)
50+
tzinfo (~> 1.1)
51+
arel (6.0.0)
52+
authlogic (3.4.4)
4253
activerecord (>= 3.2)
4354
activesupport (>= 3.2)
4455
request_store (~> 1.0)
45-
bcrypt (3.1.7)
56+
scrypt (~> 1.2)
57+
bcrypt (3.1.9)
4658
bootstrap-will_paginate (0.0.10)
4759
will_paginate
4860
breadcrumbs_on_rails (2.3.0)
49-
builder (3.1.4)
50-
codemirror-rails (4.4)
61+
builder (3.2.2)
62+
codemirror-rails (4.8)
5163
railties (>= 3.0, < 5)
5264
database_cleaner (1.0.0.RC1)
5365
diff-lcs (1.2.5)
5466
erubis (2.7.0)
5567
factory_girl (3.6.2)
5668
activesupport (>= 3.0.0)
57-
ffi (1.9.3)
69+
ffi (1.9.6)
5870
ffi-compiler (0.1.3)
5971
ffi (>= 1.0.0)
6072
rake
73+
globalid (0.3.0)
74+
activesupport (>= 4.1.0)
6175
hike (1.2.3)
62-
i18n (0.6.9)
63-
jquery-rails (3.1.0)
64-
railties (>= 3.0, < 5.0)
76+
i18n (0.7.0)
77+
jquery-rails (4.0.3)
78+
rails-dom-testing (~> 1.0)
79+
railties (>= 4.2.0)
6580
thor (>= 0.14, < 2.0)
66-
liquid (2.6.1)
67-
mail (2.5.4)
68-
mime-types (~> 1.16)
69-
treetop (~> 1.4.8)
81+
json (1.8.2)
82+
liquid (3.0.0)
83+
loofah (2.0.1)
84+
nokogiri (>= 1.5.9)
85+
mail (2.6.3)
86+
mime-types (>= 1.16, < 3)
7087
metaclass (0.0.4)
71-
mime-types (1.25.1)
72-
minitest (4.7.5)
88+
mime-types (2.4.3)
89+
mini_portile (0.6.2)
90+
minitest (5.5.1)
7391
mocha (0.14.0)
7492
metaclass (~> 0.0.1)
75-
multi_json (1.9.2)
76-
mysql2 (0.3.15)
77-
polyglot (0.3.5)
93+
multi_json (1.10.1)
94+
mysql2 (0.3.17)
95+
nokogiri (1.6.5)
96+
mini_portile (~> 0.6.0)
7897
protected_attributes (1.0.8)
7998
activemodel (>= 4.0.1, < 5.0)
80-
rack (1.5.2)
81-
rack-test (0.6.2)
99+
rack (1.6.0)
100+
rack-test (0.6.3)
82101
rack (>= 1.0)
83-
rails (4.0.4)
84-
actionmailer (= 4.0.4)
85-
actionpack (= 4.0.4)
86-
activerecord (= 4.0.4)
87-
activesupport (= 4.0.4)
102+
rails (4.2.0)
103+
actionmailer (= 4.2.0)
104+
actionpack (= 4.2.0)
105+
actionview (= 4.2.0)
106+
activejob (= 4.2.0)
107+
activemodel (= 4.2.0)
108+
activerecord (= 4.2.0)
109+
activesupport (= 4.2.0)
88110
bundler (>= 1.3.0, < 2.0)
89-
railties (= 4.0.4)
90-
sprockets-rails (~> 2.0.0)
111+
railties (= 4.2.0)
112+
sprockets-rails
113+
rails-deprecated_sanitizer (1.0.3)
114+
activesupport (>= 4.2.0.alpha)
115+
rails-dom-testing (1.0.5)
116+
activesupport (>= 4.2.0.beta, < 5.0)
117+
nokogiri (~> 1.6.0)
118+
rails-deprecated_sanitizer (>= 1.0.1)
119+
rails-html-sanitizer (1.0.1)
120+
loofah (~> 2.0)
91121
rails-observers (0.1.2)
92122
activemodel (~> 4.0)
93-
railties (4.0.4)
94-
actionpack (= 4.0.4)
95-
activesupport (= 4.0.4)
123+
railties (4.2.0)
124+
actionpack (= 4.2.0)
125+
activesupport (= 4.2.0)
96126
rake (>= 0.8.7)
97127
thor (>= 0.18.1, < 2.0)
98-
rake (10.3.1)
99-
request_store (1.0.8)
128+
rake (10.4.2)
129+
request_store (1.1.0)
100130
retina_tag (1.3.1)
101131
jquery-rails
102132
rails (>= 3.1)
@@ -127,16 +157,16 @@ GEM
127157
multi_json (~> 1.0)
128158
simplecov-html (~> 0.5.3)
129159
simplecov-html (0.5.3)
130-
sprockets (2.12.1)
160+
sprockets (2.12.3)
131161
hike (~> 1.2)
132162
multi_json (~> 1.0)
133163
rack (~> 1.0)
134164
tilt (~> 1.1, != 1.3.0)
135-
sprockets-rails (2.0.1)
165+
sprockets-rails (2.2.2)
136166
actionpack (>= 3.0)
137167
activesupport (>= 3.0)
138-
sprockets (~> 2.8)
139-
spud_core (1.0.4)
168+
sprockets (>= 2.8, < 4.0)
169+
spud_core (1.0.6)
140170
actionpack-action_caching
141171
actionpack-page_caching
142172
authlogic (~> 3.4.0)
@@ -153,14 +183,12 @@ GEM
153183
tinymce-rails (= 3.5.9)
154184
will_paginate
155185
thor (0.19.1)
156-
thread_safe (0.3.3)
186+
thread_safe (0.3.4)
157187
tilt (1.4.1)
158188
tinymce-rails (3.5.9)
159189
railties (>= 3.1.1)
160-
treetop (1.4.15)
161-
polyglot
162-
polyglot (>= 0.3.1)
163-
tzinfo (0.3.39)
190+
tzinfo (1.2.2)
191+
thread_safe (~> 0.1)
164192
will_paginate (3.0.7)
165193

166194
PLATFORMS

Diff for: app/controllers/contacts_controller.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def inquire
3636
val = params[:spud_inquiry][field.field_name]
3737
if field.required && val.blank?
3838
flash[:error] = "Not all required fields were entered"
39-
@spud_inquiry.errors.add field.field_name,"is a required field"
39+
@spud_inquiry.errors.add field.field_name,"is a required field. "
4040
end
4141

4242
if field.validation_rule
@@ -60,6 +60,10 @@ def inquire
6060
if !@spud_inquiry.recipients.blank?
6161
Spud::InquiryMailer.inquiry_notification(@spud_inquiry).deliver
6262
end
63+
64+
if Spud::Inquiries.send_receipt && @spud_inquiry.email != 'Unknown Sender' && !@inquiry_form.receipt_content.blank?
65+
Spud::InquiryMailer.send_receipt(@spud_inquiry, @inquiry_form).deliver
66+
end
6367
else
6468
flash[:error] = "Whoops! Something went wrong. Please try again!"
6569
respond_to do |format|

Diff for: app/controllers/spud/admin/inquiry_forms_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ def load_form
5454
end
5555

5656
def inquiry_form_params
57-
params.require(:spud_inquiry_form).permit(:name,:url_name,:recipients,:content,:subject,{:spud_inquiry_form_fields_attributes => [:id,:name,:options,:default_value,:field_type,:spud_inquiry_form_id,:field_order,:required, :placeholder, :class_name, :validation_rule, :validation_error_message, :_destroy]}, :created_at, :updated_at, :thank_you_content, :submit_title)
57+
params.require(:spud_inquiry_form).permit(:name,:url_name,:recipients,:content, :receipt_content, :subject,{:spud_inquiry_form_fields_attributes => [:id,:name,:options,:default_value,:field_type,:spud_inquiry_form_id,:field_order,:required, :placeholder, :class_name, :validation_rule, :validation_error_message, :_destroy]}, :created_at, :updated_at, :thank_you_content, :submit_title)
5858
end
5959
end

Diff for: app/mailers/spud/inquiry_mailer.rb

+7
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,11 @@ def inquiry_notification(inquiry)
77
# @url = "/spud/admin/inquiries/#{@inquiry.id}"
88
mail(:from =>Spud::Inquiries.from_address,:to => @inquiry.recipients.split(","), :subject => @inquiry.subject.blank? ? "No Subject" : @inquiry.subject)
99
end
10+
11+
def send_receipt(inquiry, form)
12+
@inquiry = inquiry
13+
@form = form
14+
15+
mail(:from => Spud::Inquiries.from_address, :reply_to => Spud::Inquiries.reply_to.blank? ? Spud::Inquiries.from_address : Spud::Inquiries.reply_to, :to => @inquiry.email, :subject => @inquiry.subject.blank? ? "No Subject" : @inquiry.subject)
16+
end
1017
end

Diff for: app/views/spud/admin/inquiry_forms/_form.html.erb

+16-4
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,29 @@
2222
</div>
2323
</div>
2424
<div class="form-group">
25-
<%=f.label :content, :required=>true, :class=>"control-label col-sm-4"%>
26-
<div class="col-sm-8">
27-
<%=f.text_area :content,:cols => 75,:rows => 5,:class => "spud-formatted-editor form-control"%>
28-
</div>
25+
<%=f.label :content, :required=>true, :class=>"control-label col-sm-4"%>
26+
<div class="col-sm-8">
27+
<%=f.text_area :content,:cols => 75,:rows => 5,:class => "spud-formatted-editor form-control"%>
28+
</div>
2929
</div>
3030
<div class="form-group">
3131
<%=f.label :thank_you_content,"Thank You Text", :required=>true, :class=>"control-label col-sm-4"%>
3232
<div class="col-sm-8">
3333
<%=f.text_area :thank_you_content,:cols => 75,:rows => 5,:class => "spud-formatted-editor form-control"%>
34+
<p class="help-block">The above message will be display on the page to the user immediately after submission of inquiry. </p>
35+
</div>
36+
</div>
37+
38+
<% if Spud::Inquiries.send_receipt %>
39+
<div class="form-group">
40+
<%=f.label :receipt_content, :class=>"control-label col-sm-4"%>
41+
<div class="col-sm-8">
42+
<%=f.text_area :receipt_content,:cols => 75,:rows => 5,:class => "spud-formatted-editor form-control"%>
43+
<p class="help-block">We will email the above message after submission of inquiry. Also, please ensure one of the inquiry fields below has the name of 'email'.</p>
3444
</div>
3545
</div>
46+
<% end %>
47+
3648
<div class="form-group">
3749
<%=f.label :submit_title, "Submit Button Title", :required=>true, :class=>"control-label col-sm-4"%>
3850
<div class="col-sm-8">

Diff for: app/views/spud/inquiry_mailer/send_receipt.html.erb

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
5+
</head>
6+
<body>
7+
8+
<%= @form.receipt_content.html_safe %>
9+
10+
</body>
11+
</html>
12+

Diff for: app/views/spud/inquiry_mailer/send_receipt.text.erb

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
Inquiry Received
3+
=================
4+
5+
<%= strip_tags @form.receipt_content %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddReceiptContentToSpudInquiryForm < ActiveRecord::Migration
2+
def change
3+
add_column :spud_inquiry_forms, :receipt_content, :text
4+
end
5+
end

Diff for: lib/spud_inquiries/configuration.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ module Spud
22
module Inquiries
33
include ActiveSupport::Configurable
44

5-
config_accessor :default_contact_form,:enable_routes,:mail_delivery_format,:base_layout,:from_address,:enable_sitemap,:enable_action_caching, :automount
5+
config_accessor :default_contact_form,:enable_routes,:mail_delivery_format,:base_layout,:from_address,:enable_sitemap,:enable_action_caching, :automount, :reply_to, :send_receipt
66

77
self.enable_routes = true
88
self.automount = true
99
self.default_contact_form = "contact"
1010
self.base_layout = "application"
1111
self.mail_delivery_format = :html
1212
self.from_address = "[email protected]"
13+
self.reply_to = "[email protected]"
1314
self.enable_sitemap = true
1415
self.enable_action_caching = false
16+
self.send_receipt = false
1517
end
16-
end
18+
end

0 commit comments

Comments
 (0)